Repository navigation
CLEANUP
Status: Implemented
Last Updated: 2026-11-13
Audience: Developers and coding agents
Last verified: 2026-11-13 against b1688a8de
Code: scripts/Clean-Martlet.ps1
Martlet builds, tests and agent sessions make a large quantity of files that Git ignores. Each Copilot worktree (a separate checkout of a task branch) gets its own copy. This page tells you what Martlet makes, where, how large it gets, and how to remove it safely.
Measured on 2026-10-09 on the developer PC with 159 worktrees:
- Each worktree grew to 2.7-4.5 GB and 9,000-11,700 files.
- Across all worktrees:
bin\145 GB,obj\12.5 GB andnode_modules\9.8 GB (about 297,000 files, most insrc\Martlet.Avatar.Vrm\node_modules\). - The shared Git folder had about 26,000 loose objects, more than 300
[branch]sections in its config, about 111 local-only branches, 147 registered worktrees (many for archived sessions) and stale.lockfiles. - Many small files made new worktree checkouts very slow, and archiving sessions timed out.
- Never delete tracked files, uncommitted changes or commits that are not on
origin/mainor another remote branch. - Delete only output that a build,
npm cior a test run makes again. - Agents clean only their own checkout. Never clean another session's worktree or the main checkout unless the developer asks.
- Do not delete
src\Martlet.Avatar.Live2D\local-sdk\orvendor\. Git ignores them, but they hold Live2D SDK files that you put there. A build cannot make them again. - Do not delete
.vs\,*.user,~\.martlet-dev\(the developer profile),~\.nuget\packages\(the shared NuGet cache) or Martlet user data.
| What | Where | Typical size | Made by | Safe to delete |
|---|---|---|---|---|
| .NET build output |
bin\ in every project under src\ and tests\
|
145 GB across 159 worktrees (average 0.9 GB each) |
dotnet build, Test-Martlet.ps1, Invoke-MartletMcp.ps1 -Build
|
Yes. The next build makes it again. |
| .NET intermediate output |
obj\ in every project |
12.5 GB across 159 worktrees (average 80 MB each) | The same builds and restores | Yes. The next restore and build make it again. |
| npm packages |
src\Martlet.Avatar.Vrm\node_modules\, and src\Martlet.Avatar.Live2D\node_modules\ when you installed it |
9.8 GB and about 297,000 files across 159 worktrees |
npm ci, run by the Companion and Desktop builds and by Test-Martlet.ps1
|
Yes. npm ci restores it from package-lock.json (needs the network). |
| Web bundles |
dist\ and dev-dist\ in the avatar packages, src\Martlet.Avatar.RendererHost\web\dist\ and web\live2d-dist\
|
Small | The avatar builds | Yes. |
| Validation output |
artifacts\validation\ (summary.md, logs, TRX files, Linux test staging) |
Small to some MB | Test-Martlet.ps1 |
Yes, after you copy summary.md into the pull request. |
| Test results and Python caches |
TestResults\, __pycache__\
|
Small |
dotnet test, worker tests |
Yes. |
| Disposable data folders |
%TEMP%\Martlet.<name>.<guid> and %TEMP%\martlet-<name>-<guid> (for example Martlet.Mcp.Verify.<guid>) |
Small each, but hundreds collect |
Invoke-MartletMcp.ps1 (kept by -KeepDesktop or a stopped run), Smoke-Doctor.ps1, tests, Martlet.Dev.<guid> from the quick start |
Yes, when they are older than one day. |
| Git data | The shared Git folder of the repository (git rev-parse --git-common-dir shows it). All worktrees use it. |
Loose objects, branches, config sections, worktree registrations, .lock files |
Every session, fetch, commit and worktree | See Git housekeeping. |
The Docker volume martlet-validation-nuget is a NuGet cache that the Linux
tests use again on each run. Keep it. Linux test containers use --rm, so
Docker removes their other volumes.
-
Agents: before you finish a session, after the pull request is merged or
after you copied
artifacts\validation\summary.mdinto it. - Developers: when free disk space gets low, or when new worktree checkouts or session archiving become slow.
-
Git housekeeping: when
git count-objects -vshows more than a few thousand loose objects (count), whengit worktree listshows manyprunableentries, when the Git config has hundreds of[branch]sections, or when Git stops because a.lockfile exists and no Git process runs.
scripts\Clean-Martlet.ps1 removes only folders that Git lists as ignored and
untracked and that have a generated name. It never deletes tracked files,
untracked source files or local-sdk\ and vendor\.
-
Show what the script would remove, with sizes. This changes nothing:
.\scripts\Clean-Martlet.ps1 -WhatIf
-
Remove the build output of this checkout and old disposable
%TEMP%folders:.\scripts\Clean-Martlet.ps1
-
Developer only: show, then do, the Git housekeeping on the shared Git folder:
.\scripts\Clean-Martlet.ps1 -Git -WhatIf .\scripts\Clean-Martlet.ps1 -Git
-
Developer only: clean the build output of every worktree of the repository:
.\scripts\Clean-Martlet.ps1 -AllWorktrees -WhatIf .\scripts\Clean-Martlet.ps1 -AllWorktrees
| Parameter | What it does |
|---|---|
-WhatIf |
Shows what the script would remove and changes nothing. |
-Git |
Does the Git housekeeping. |
-AllWorktrees |
Cleans every worktree of the repository, including the main checkout, not only this checkout. |
-KeepNodeModules |
Keeps node_modules\, so the next build does not run npm ci again. |
-SkipTemp |
Does not touch %TEMP%. |
-TempAgeHours |
Minimum age of a %TEMP% folder before the script removes it. The default is 24. |
-LockAgeMinutes |
Minimum age of a Git .lock file before the script deletes it. The default is 60. |
If a file is in use, the script keeps it and says "partly removed". Stop the Martlet processes that run from that folder (Desktop, MCP server, worker hosts), then run the script again. The script does not stop shared build servers, because other worktrees can use them.
-Git does these steps on the shared Git folder:
-
git worktree pruneremoves the registrations of worktrees whose folder is gone. -
git fetch origin --pruneremoves remote-tracking branches that were deleted on GitHub. - It deletes local branches that are fully merged into
origin/mainand that no worktree has checked out. It prints each deleted branch with its commit. It keeps every branch that is not merged. - It removes
[branch]config sections for branches that do not exist. - It deletes
.lockfiles older than one hour by timestamp. The script does not check whether a Git process holds a lock. Do not run-Gitwhile Git operations use the shared repository. See the cleanup lock issue. -
git gcpacks loose objects. It keeps unreachable objects for the default two weeks, so it is safe while other sessions use the repository.
To restore a deleted branch, use the commit that the script printed:
git branch <name> <commit>.
Use these commands when you cannot use the script. Run them in the checkout that you clean.
# List the ignored folders in this checkout. Delete only generated ones.
git ls-files --others --ignored --exclude-standard --directory
Remove-Item -Recurse -Force src\Martlet.Avatar.Vrm\node_modules
# Git housekeeping
git worktree prune --verbose
git fetch origin --prune
git branch --merged origin/main # "+" or "*" marks a branch checked out in a worktree: keep it and main
git branch -D <branch> # only for a branch that the line above lists
git count-objects -vH
git gcTo remove the worktree of a finished session, archive the session in the
Copilot app. The app removes the worktree. To remove a worktree by hand, first
make sure that git -C <path> status --short shows nothing and that its
commits are merged or pushed. Then run git worktree remove <path>.
Do not use these commands:
-
git clean -xorgit clean -Xwithout a review. They also deletelocal-sdk\,vendor\,.vs\and*.user. -
git gc --prune=nowwhile other sessions work. It can delete objects that a running Git command just wrote. -
git branch -Don a branch that is not merged. It can lose work. -
git worktree remove --forceon a worktree with changes. - Deleting a
.lockfile while a Git process uses it.
Martlet: download · repository · changelog · issues
These pages come from docs/wiki in the repository. To suggest a change, open an issue or a pull request there.
- Home
- Accounts and households
- Accounts and Household
- Android phones and tablets: what it takes, and the plan
- Martlet's API for other apps and scripts
- App Guides
- App Settings and Updates
- App guides: game and app knowledge from the web
- Architecture
- Bounded PCM playback
- Audio dependency inventory and notices
- Avatar guide: Live2D, VRM and speech animation
- V01a explicit microphone capture
- Chatterbox voice engines
- Cleaning up disk space
- One Martlet on all your computers
- Companion controls and behavior requirements
- Components, jobs and placement (design)
- Live conversation
- Creations
- Decision map: which file owns each decision
- Deep research: web search and long research jobs
- The desktop app: updates, notification area, exiting and appearance
- Linux and macOS desktop companion: research, decision and plan
- Developer Guide
- Dia voice engine
- Diagnostics
- Discord
- Architecture and provider contracts
- Discord
- Memory (P03a/P03b/P03c)
- Singing
- Desktop troubleshooting and local support
- Recognizing people by voice, and Parakeet
- Echo cancellation
- ElevenLabs voice: your cloned voice with tones
- F5 worker and reference-voice foundation
- FAQ
- First Steps
- Game state plan: implementation history
- Glossary: one name for each concept
- GPT-SoVITS voice
- Hosted Thinking: cloud models when Thinking can't run on this PC
- Installation and support
- Installing Martlet
- iOS and iPadOS: what it takes, and the plan
- Repository instructions for coding agents
- Repository knowledge base
- Knowledge base maintenance
- GitHub Wiki mirror
- Linux and Mac
- Listening and Voice ID
- Local model apps
- Lorebooks
- macOS: what it takes, and the plan
- Martlet MCP Server
- MCP in Martlet
- MCP: The app's window
- MCP: Apps, home and memory
- MCP: Characters
- MCP: Diagnostics and logs
- MCP: Computers, network and accounts
- MCP: Other
- MCP: Tool permissions
- MCP pages
- MCP: Server and protocol internals
- MCP: Settings
- MCP: Start here
- MCP: Thinking and models
- MCP: Voice and listening
- Memory
- Messaging apps
- Model catalog: sources, conflicts and design
- Motion host role
- Multiple Computers
- Your Martlet network
- OCR host role
- Share your language models: the OpenAI-compatible endpoint
- Packaging
- Perception worker contracts
- Personality and Characters
- Picture making
- Pictures and Creations
- Picture making host role
- Platforms: what each device can do
- Prerequisites: what Martlet bundles, installs for you, or needs from you
- Privacy and Safety
- Reading the text on your screen
- Wiki source
- Recommendation design: ask three questions, plan for three situations
- Recommended setups: one machine to unlimited budget
- Releasing
- Repository Layout
- Research and provenance ledger
- Resource footprints
- Roadmap
- Watch my screen: screen-aware commentary
- Search engine
- Image and audio models: who sees, who hears, who answers
- Setting Up a Host
- Setup, Windows credentials and local audio
- Sharing with Friends
- Singing
- Smart Home
- Smart home and cameras
- Source Projects
- Talking to Martlet
- Telegram and WhatsApp
- The Character
- Thinking
- Tools and MCP
- Troubleshooting
- Martlet desktop UI design
- User stories and target flows
- Voice activity detection
- Validating changes
- Validation and Testing
- Vision
- Voice latency: from you stopping talking to Martlet's voice
- Voice recognition host role
- Multi-engine voice setup and comparison
- Voices
- The welcome wizard
- XTTS-v2 voice engine