Keep a worktree small with sparse-checkout
internals & scripting
// what it does
In a monorepo, an agent working on one package doesn't need the other hundred materialized. Create the worktree with --no-checkout, select directories with git sparse-checkout set, then git checkout writes only that slice — faster creation, less disk, less noise for tools that scan the tree.
// shell
$ git worktree add --no-checkout -b agent-web ../myapp-web main$ cd ../myapp-web && git sparse-checkout set apps/web packages/ui && git checkout// gotcha
Sparse patterns are per-worktree only when worktree-specific config is active — modern Git enables the worktreeConfig extension automatically when you run sparse-checkout inside a worktree, but verify with git sparse-checkout list in each worktree rather than assuming they're independent.