Skip to content

fix: place agent worktrees consistently under <repo>/.worktrees/#462

Merged
zigrivers merged 4 commits into
mainfrom
worktree-location-consistency
May 31, 2026
Merged

fix: place agent worktrees consistently under <repo>/.worktrees/#462
zigrivers merged 4 commits into
mainfrom
worktree-location-consistency

Conversation

@zigrivers
Copy link
Copy Markdown
Owner

Problem

setup-agent-worktree.sh created agent worktrees as repo siblings
(../<repo>-<agent>), scattering them outside the project and diverging from
where other tooling expects worktrees. Worktree placement was inconsistent
across mechanisms; this standardizes scaffold's own worktrees on a single,
project-local location.

Change

Standardize on <repo>/.worktrees/<agent>, matching the superpowers
using-git-worktrees convention.

  • scripts/setup-agent-worktree.sh — compute the worktree path under
    .worktrees/ and ensure .worktrees/ is gitignored before creating the
    worktree, so a worktree's full checkout is never accidentally committed.
  • src/project/gitignore.ts (+ test) — add .worktrees/ to the
    scaffold-managed .gitignore block so downstream-scaffolded projects ignore
    it automatically.
  • content/pipeline/environment/git-workflow.md — the meta-prompt that
    generates each downstream project's worktree script now specifies the
    .worktrees/ convention and the gitignore guard.
  • Docsdocs/git-workflow.md §7, the worktree-management knowledge entry,
    and the multi-agent guide (md + regenerated html, :cite lines re-pointed to
    the shifted script lines).
  • tests/setup-agent-worktree.bats — assert the new location, that no
    sibling dir is created, and that .worktrees/ ends up gitignored.

Scope notes

  • Harness-native worktrees (Claude Code .claude/worktrees/, Codex
    ~/.codex/worktrees/) are created by those tools, not scaffold, and are
    intentionally left alone — per best practice, don't fight the harness.
  • Existing sibling worktrees are not auto-migrated; only newly created ones use
    .worktrees/.

Verification

make check-all green: 690 TS tests pass, bats suite passes, ShellCheck clean,
knowledge validation 0 errors, guides drift + security scan pass. TDD followed
(tests red → implementation → green).

🤖 Generated with Claude Code

zigrivers and others added 4 commits May 31, 2026 09:58
setup-agent-worktree.sh created worktrees as repo siblings
(../<repo>-<agent>), which scattered them outside the project and
diverged from where other tooling expects them. Standardize on a single
project-local location, <repo>/.worktrees/<agent>, matching the
superpowers using-git-worktrees convention.

- setup-agent-worktree.sh: compute worktree path under .worktrees/ and
  ensure .worktrees/ is gitignored before creating the worktree so a
  worktree's checkout is never accidentally committed
- gitignore.ts: add .worktrees/ to the scaffold-managed block so
  downstream-scaffolded projects ignore it automatically
- git-workflow.md meta-prompt: instruct downstream-generated worktree
  scripts to use the .worktrees/ convention + gitignore guard
- docs/git-workflow.md, worktree-management knowledge, multi-agent guide
  (md + regenerated html, cite lines re-pointed): document the new path
- tests: assert new location, no sibling dir, and .worktrees/ ignored

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Address multi-channel review findings on the worktree gitignore guard:

- The pre-create check `git check-ignore -q .worktrees` false-negatived
  when `.worktrees/` was already ignored but the directory did not yet
  exist (a directory-only pattern only matches a path git knows is a
  dir). That caused a duplicate `.worktrees/` rule to be appended,
  including when src/project/gitignore.ts had already added it. Use the
  trailing-slash form `.worktrees/` so the check matches correctly
  regardless of whether the dir exists. Adds a regression test.
- Remove the redundant `git worktree prune` from the bats teardown; the
  whole clone (with its .git/worktree metadata) is rm -rf'd right after.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Re-point :cite line numbers in content/guides/multi-agent to the
  shifted lines in setup-agent-worktree.sh (branch add, worktree add,
  mkdir .scaffold, identity printf, beads check) and rebuild index.html.
- Align the "ensures .worktrees/ is gitignored" test to use the
  trailing-slash check-ignore form the script uses.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A git add -A swept the Claude Code scheduler lock file (session id, PID,
process start time) into the branch. Untrack it and add .claude/*.lock to
.gitignore so runtime locks are never committed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@zigrivers zigrivers merged commit bbf4a46 into main May 31, 2026
2 checks passed
@zigrivers zigrivers deleted the worktree-location-consistency branch May 31, 2026 16:59
zigrivers added a commit that referenced this pull request May 31, 2026
Document the worktree-location standardization (#462): agent worktrees now
created under <repo>/.worktrees/<agent> with a gitignore guard, downstream
propagation via the git-workflow meta-prompt and the scaffold-managed
.gitignore block, plus a migration note for existing sibling worktrees.

Bump version 3.32.0 -> 3.32.1 and align the README harvest example to the
new convention.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
zigrivers added a commit that referenced this pull request May 31, 2026
Document the worktree-location standardization (#462): agent worktrees now
created under <repo>/.worktrees/<agent> with a gitignore guard, downstream
propagation via the git-workflow meta-prompt and the scaffold-managed
.gitignore block, plus a migration note for existing sibling worktrees.

Bump version 3.32.0 -> 3.32.1 and align the README harvest example to the
new convention.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant