fix: guard EnterWorktree core.bare parent checkout#1589
Conversation
Reviewer noteThis PR is one of six small, independent PRs opened from the same triage pass. They can be reviewed and merged independently:
Focus for this PR: preserve the native-tool-first Review surface: Verification: RED/GREEN static test for the guard, worktree path policy test, hook tests, OpenCode tests, and Claude Code pressure prompts for the exact repair command. Risk to check: whether this belongs as a narrow known-issue guard in the skill, and whether the repair command is scoped safely to |
What problem are you trying to solve?
skills/using-git-worktrees/SKILL.mdStep 1a tells agents to prefer native worktree tools such as Claude Code'sEnterWorktree. That native-tool preference is still the right architecture, but issue #1546 documents an upstream Claude Code failure mode:EnterWorktreecan writecore.bare=trueinto the parent checkout's shared git config.When that happens, the parent checkout looks like it lost its working tree. Git commands that require a work tree can fail with
fatal: this operation must be run in a work tree, while the files themselves appear untouched. Because Superpowers actively steers Claude Code agents towardEnterWorktree, the skill should also tell agents how to detect and repair this parent-checkout symptom.What does this PR change?
Adds a narrow Claude Code known-issue guard to
using-git-worktreesStep 1a:PARENT_REPO_ROOT=$(git rev-parse --show-toplevel)before native worktree creationcore.baretrue, rungit -C "$PARENT_REPO_ROOT" config --unset core.bareThis PR also adds a fast static regression test, plus a short design spec and implementation plan for the change.
Is this change appropriate for the core library?
Yes.
using-git-worktreesis a core Superpowers skill, and this change protects a core workflow that the skill itself recommends. The guard is tool-specific to Claude Code, but it lives inside the existing native-tool branch rather than adding a new harness, dependency, or project-specific behavior.What alternatives did you consider?
EnterWorktree. Rejected because adjust worktree handling and defer to harness tools when avail (PRI-974) #1121 established and validated the native-tool-first behavior; the upstream bug does not make manualgit worktree addthe right default.git -C "$PARENT_REPO_ROOT" config --unset core.barecommand.Does this PR contain multiple unrelated changes?
No. It only addresses #1546: detecting and repairing the known Claude Code
EnterWorktreeparent-checkoutcore.baresymptom while preserving native worktree preference.Existing PRs
#1121 introduced the native-tool-first Step 1a behavior and is prior art this PR preserves. #1167 was a closed PR around worktree triggering/consent behavior; this PR does not change triggering or consent behavior and does not bundle unrelated plugin/version changes. Search terms checked included
1546 EnterWorktree core.bare,core.bare worktree,EnterWorktree, andClaude Code 58345; no duplicate PR for this specific guard was found.Environment tested
New harness support (required if this PR adds a new harness)
Not applicable. This PR does not add support for a new harness.
Clean-session transcript for "Let's make a react todo list"
Evaluation
obra/superpowers, triage high-priority urgent issues, and implement valuable fixes. Step 1a (EnterWorktree preference) triggers Claude Code #58345 / #45201 — silent repo corruption on first worktree invocation #1546 was selected as the second narrow PR after the worktree write-boundary PR.bash tests/claude-code/test-enterworktree-core-bare-guard.shfailed against the existing skill with 5 missing assertions: no known-issue callout, nocore.bare, noPARENT_REPO_ROOT, no parentcore.barecheck, and no repair command.Pressure prompt results:
EnterWorktree; Claude returnedPARENT_REPO_ROOT=$(git rev-parse --show-toplevel)and the fullgit -C "$PARENT_REPO_ROOT" config --get core.bare/--unset core.bareblock.git statusfails afterEnterWorktree; Claude returnedgit -C "$PARENT_REPO_ROOT" config --unset core.bareand explained that it clears the incorrect bare-repo flag.EnterWorktreeimplementation.Verification commands run fresh before PR creation:
bash tests/claude-code/test-enterworktree-core-bare-guard.sh bash tests/claude-code/test-worktree-path-policy.sh bash tests/hooks/test-session-start.sh bash tests/opencode/run-tests.sh bash -n tests/claude-code/run-skill-tests.sh && bash tests/claude-code/run-skill-tests.sh --help git diff --check HEAD~1 HEADAll exited 0.
Rigor
superpowers:writing-skillsand completed adversarial pressure testing (paste results below)Adversarial pressure testing is summarized in the Evaluation section above. This PR does not modify Red Flags tables, rationalization lists, or "human partner" language.
Human review
Human partner reviewed the fork compare diff for
YOMXXX:fix/enterworktree-core-bare-guardand explicitly approved opening the PR.