Claude Code with Git Worktrees¶
| Category | Claude Code |
| Status | ๐ก Partially completed |
| Repo | nextwork-claude-code-with-git-worktrees |
| Original NextWork guide | nextwork.ai |
Learning project
Practice work following a NextWork guide, separate from my production projects.
๐ NextWork learning project. This is a practice project I built while working through NextWork's Claude Code with Git Worktrees guide. It is part of my Learning portfolio and is fully separate from my production projects.
Category: Learning โบ Claude Code
Status: ๐ก Partial
Overview¶
Git worktrees give each parallel task its own folder and branch from the same repository, so several AI sessions (or people) can edit simultaneously without stepping on each other. Each feature is merged when ready. This repo holds the final budget tracker and a script that replays the whole worktree workflow from scratch.
Summary¶
I built the budget tracker through a real git worktree workflow: one base commit, three feature worktrees with commits made in parallel, then all three merged, including resolving a real merge conflict between the summary and export branches, and tested (4 tests). I also wrote the worktree-isolated subagent (secret mission). The parallel work was scripted, not done in claude -w sessions (needs a Claude account).
The checks behind this are in docs/verification.txt.
Skills & tools¶
Git worktrees, Parallel development, Branching and merging, Python, Claude Code subagents
What I built¶
budget.py: the CLI (add, balance, categories, monthly summary, CSV export).test_budget.py: 4 tests.scripts/worktree-session.sh: replays base โ 3 parallel worktrees โ merge โ cleanup and checks the result equalsbudget.py.docs/worktree-session.txt: the recorded run..claude/agents/test-writer.md: the subagent withisolation: worktree(secret mission).
How to run¶
python budget.py add 2026-12-02 -12.50 lunch --category food
python budget.py summary
bash scripts/worktree-session.sh
Verification¶
I ran the verification command on 2026-12-02. The full output is in docs/verification.txt.
export PATH=/workspace/nextwork-portfolio/.venv/bin:$PATH; python3 -m pytest -q -p no:cacheprovider test_budget.py && set -o pipefail && mkdir -p docs && bash scripts/worktree-session.sh | tee docs/worktree-session.txt
What isn't done, and why¶
In the guide, each worktree is a separate Claude Code session started with claude -w. Here, scripts/worktree-session.sh makes the same git moves (worktree add, parallel commits on separate branches, merge, worktree remove) with scripted edits standing in for the three sessions. .claude/agents/test-writer.md is written but wasn't run.
Original project: https://nextwork.ai/projects/7b738cc2-e7c9-5626-9562-c1dc9a733fc6 ยท Part of my NextWork Learning portfolio (hub).
Verification output¶
From docs/verification.txt:
$ export PATH=/workspace/nextwork-portfolio/.venv/bin:$PATH; python3 -m pytest -q -p no:cacheprovider test_budget.py && set -o pipefail && mkdir -p docs && bash scripts/worktree-session.sh | tee docs/worktree-session.txt
.... [100%]
4 passed in 0.02s
== base commit
060589d feat: base budget tracker (add, balance)
== three worktrees, one per parallel session
<tmp>/budget-tracker <sha> [main]
<tmp>/wt-categories <sha> [feature/categories]
<tmp>/wt-export <sha> [feature/export]
<tmp>/wt-summary <sha> [feature/summary]
session in wt-export committed on feature/export
session in wt-categories committed on feature/categories
session in wt-summary committed on feature/summary
== merge back into main
merged feature/categories (clean)
Auto-merging budget.py
merged feature/summary (clean)
Auto-merging budget.py
CONFLICT (content): Merge conflict in budget.py
Automatic merge failed; fix conflicts and then commit the result.
CONFLICT merging feature/export: budget.py, 3 conflict hunk(s)
(summary and export both added code at the same spots; resolution = keep both sides)
resolved and committed the merge
== merged result is identical to budget.py in this repo
.... [100%]
4 passed in 0.02s
== worktrees removed, branches deleted
<tmp>/budget-tracker <sha> [main]
* Merge branch 'feature/export'
|\
| * feat(export): add export
* | Merge branch 'feature/summary'
|\ \
| * | feat(summary): add summary
| |/
* / feat(categories): add categories
|/
* feat: base budget tracker (add, balance)
[exit code 0]