fix: worktree support with .worktrees/ convention and cd-first approach#10
Merged
Conversation
Addresses #7 - three worktree support gaps: 1. git-guard.py: Parse -C <path> from git commands so the commit-on-main check queries the correct worktree branch instead of always checking the main repo. Also anchor the commit regex to line start (^\s*git) to avoid false positives from heredoc content. 2. SKILL.md: Replace sibling directory pattern (../repo-feature) with internal .worktrees/BRANCH_NAME pattern that stays within Claude Code's permission scope. Use git -C instead of cd for worktree ops. 3. implementer.md: Replace "don't use git -C" guidance with "use git -C .worktrees/<branch>" for worktree operations. 4. .gitignore: Add .worktrees/ entry. Closes #7 https://claude.ai/code/session_0133wuXFfTNKJjnaTuc12Zco
The original commit overcorrected toward git -C for all worktree operations. In practice, git -C triggers repeated permission approval prompts in Claude Code. Agents should cd into their worktree and work normally; git -C is reserved as a fallback. Changes: - implementer.md: "work from within worktree directly, fall back to git -C only when necessary" - using-git-worktrees SKILL.md: restore cd-based workflow for Phase 3, Working in Worktrees, example flow, and troubleshooting sections - agent-team-development SKILL.md: migrate from sibling directory pattern (../REPO-team-BRANCH-impl-N) to internal .worktrees/ pattern; add explicit cd-into-worktree instructions in implementer spawn prompt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @tombakerjr's task in 1m 26s —— View job Review Complete
LGTM - no blocking issues I verified the following: git-guard.py (hooks/git-guard.py:19-26, hooks/git-guard.py:28-40, hooks/git-guard.py:68-72)
Worktree convention migration
Documentation (skills/using-git-worktrees/SKILL.md, skills/agent-team-development/SKILL.md)
agents/implementer.md:18
|
…sitives
- parse_git_c_path: handle both quoted ("path with spaces") and
unquoted paths in git -C arguments
- commit detection: remove re.MULTILINE (which made ^ match every
line, including heredoc content) and instead match git commit at
string start or after shell operators (&&, ;, |)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-C <path>from git commands so the commit-on-main check queries the correct worktree branch. Anchor commit regex to^\s*gitto avoid false positives from heredoc content.../repo-feature) with internal.worktrees/BRANCH_NAME. Use cd-into-worktree as the primary workflow;git -Cdocumented only as a fallback.../REPO-team-BRANCH-impl-Nto.worktrees/team-BRANCH-impl-N. Add explicit cd-into-worktree instructions in the implementer spawn prompt.git -Cis a fallback only..worktrees/entry.Closes #7
Test plan
git-guard.pyallows commits in worktrees viagit -C .worktrees/<branch> commitgit-guard.pyblocks commits on main from worktree contextgit-guard.pydoesn't false-positive on heredoc content containing "git commit"../sibling directory references in skills or agents.worktrees/is gitignored🤖 Generated with Claude Code