Paths Subjects Questions Quizzes Pricing Search
Intermediate Open Free

Keeping a Worktree From Checking Out the Whole Monorepo

You spin up an isolated worktree for a subagent to work in packages/api/, but by default --worktree checks out the entire repository to disk — wasteful in a huge monorepo.

What setting scopes it down to just the directories you need?

Solution

The correct answer is "worktree.sparsePaths."

worktree.sparsePaths writes only the listed directories (plus root-level files) to disk for a new worktree, instead of the whole repository. additionalDirectories grants extra access to a running session, it doesn't control what a worktree checks out; claudeMdExcludes only affects which CLAUDE.md files load; and --bare skips loading hooks/MCP/CLAUDE.md entirely, unrelated to what files a worktree contains.

Share this question

← Back to Claude Code Best Practices: Reliable, Cheap, High-Leverage Sessions practice

We use cookies for product analytics to improve OmniAtlas. See our Privacy Policy.