worktree.sparsePaths and PostCompact Hook in v2.1.76
Claude Code v2.1.76 adds two power-user features for large-scale and automated workflows. The new worktree.sparsePaths setting enables sparse checkout when Claude Code creates isolated worktrees, materializing only the specified directories rather than the full repository tree β critical for large monorepos where full checkout is expensive. The PostCompact hook fires after every auto-compaction cycle and exposes the generated conversation summary, giving automation pipelines a reliable trigger point for memory persistence, agent checkpointing, and cross-session context handoff.
Sources & Mentions
3 external resources covering this update
worktree.sparsePaths: Targeted Checkout for Large Monorepos
Claude Code v2.1.76 introduces the worktree.sparsePaths setting, which enables sparse checkout when creating isolated worktrees. In a large monorepo β where a full checkout might involve tens of thousands of files across dozens of unrelated packages β this setting limits the materialized working tree to only the directories specified in sparsePaths.
For teams working with Claude Code on monorepos that use Git worktrees for task isolation, sparse checkout meaningfully reduces:
- Disk I/O at worktree creation time
- Startup latency for worktree-based sessions
- Noise in file-watching and indexing from unrelated package trees
The setting is configured in .claude/settings.json under the worktree key:
{
"worktree": {
"sparsePaths": ["packages/my-service", "shared/utils", "config"]
}
}
This complements the existing --worktree flag and EnterWorktree/ExitWorktree tools that Claude Code uses for parallel task execution.
PostCompact Hook: React to Context Resets
The PostCompact hook is a new hook event that fires immediately after Claude Code completes an auto-compaction cycle. The hook payload includes a compact_summary field containing the conversation summary that was generated during compaction.
This is a meaningful addition to the Claude Code hook system for teams running long or multi-session agent workflows. Before this hook, compaction was a silent internal event β the context window reset and the generated summary was consumed internally with no opportunity for external systems to capture it.
With PostCompact, automation pipelines can now:
- Write the summary to an external memory store (e.g., a vector database or a CLAUDE.md file) to provide future sessions with a compressed history of past work
- Trigger checkpointing at a known, stable point β immediately after compaction, the conversation is at minimum context usage and maximum coherence
- Notify downstream agents or orchestrators that the context window has reset, allowing them to re-inject relevant context if needed
- Log compaction events for observability into long-running agent sessions
The hook follows the same registration and timeout model as other Claude Code hooks, making it fully composable with existing hook configurations.
Additional Changes in v2.1.76
The release also adds the -n/--name CLI flag for setting session display names at startup, and the /effort slash command for adjusting model effort level directly from the prompt bar during an active session.