AI News Daily한국어
← AI tool tips
Claude Code✓ Confirmed in official docsAdded Dec 4

How to check out only the folders you need in Claude Code worktrees with worktree.sparsePaths

claude --worktree and subagent worktrees check out the whole repository by default. In a large repository, worktree.sparsePaths uses git sparse-checkout to write only the directories you list, so worktrees start faster and use less disk.

Add it to .claude/settings.json, next to any keys already there:

{
  "worktree": {
    "sparsePaths": [
      ".claude",
      "packages/api",
      "packages/shared"
    ],
    "symlinkDirectories": [
      "node_modules"
    ]
  }
}
  • Paths are relative to the repository root. List directories, not files; root-level files such as package.json and lock files are always checked out.
  • Root-level directories are not, so include .claude if worktrees need the root .claude/settings.json or .claude/rules/.
  • symlinkDirectories links each worktree's node_modules back to the main checkout instead of duplicating it.
  • Every worktree in a session shares the same sparsePaths. If one subagent needs packages/api and another packages/web, list both.
  • Commit the shared list to .claude/settings.json and add personal paths in .claude/settings.local.json. The lists merge, so a local file can add paths but not remove them.

While a sparse worktree exists, git needs extensions.worktreeConfig enabled in the repository's .git/config. Claude Code removes that entry after the last worktree is gone, but only if it added it.

Get notified when a new tip lands

Tip alerts only go out in the app. Install it and turn notifications on.

Get the app

All tips →