CC-301e · Module 3

Stash and Worktree Patterns

3 min read

Git stash is context suspension — you park your current changes, handle an interruption, and restore them later. Claude Code can manage stashes effectively but needs clear instructions about what to stash and when to pop. The common failure: Claude stashes your changes, does other work, and then forgets to pop the stash. The fix is explicit: "Stash current changes, switch to main, pull latest, switch back, pop stash." The full workflow in one prompt, so Claude does not lose track of the stashed state.

Worktrees are the superior alternative for planned parallel work. A stash is temporary and fragile — it is easy to forget about stashed changes, and stash conflicts are harder to resolve than branch conflicts. A worktree is permanent and clean — each task gets its own directory, its own branch, and its own Claude Code instance. Use stash for unplanned interruptions. Use worktrees for planned parallel work.

Do This

  • Use worktrees for planned parallel work — one directory per task
  • Use stash only for unplanned interruptions — quick context switches
  • Give Claude the full stash lifecycle in one prompt: stash → work → pop
  • Name your stashes: git stash push -m "auth-refactor-in-progress"

Avoid This

  • Use stash for long-term work suspension — you will forget about it
  • Let Claude stash without instructions to pop later
  • Stack multiple stashes — stash@{3} is a memory leak waiting to happen
  • Use stash when a worktree or branch would be cleaner