Skip to content

feat(harness): per-worktree setup/teardown lifecycle hooks (#9) - #29

Closed
robercano-ghbot wants to merge 1 commit into
mainfrom
feat/issue-9-worktree-lifecycle
Closed

feat(harness): per-worktree setup/teardown lifecycle hooks (#9)#29
robercano-ghbot wants to merge 1 commit into
mainfrom
feat/issue-9-worktree-lifecycle

Conversation

@robercano-ghbot

Copy link
Copy Markdown
Collaborator

What

Adds an optional per-worktree lifecycle to the adapter so isolated implementer/reviewer worktrees can bootstrap toolchain state that lives outside the tree — node_modules, Foundry libs from forge install, shared caches — making "every gate runs in isolation" actually true instead of some gates only being runnable in the main checkout.

How

  • .claude/scripts/worktree.sh (new) — a gate.sh-style runner: worktree.sh setup|teardown reads .worktree.<phase> from the adapter, honors GATES_FILE, resolves the repo root from its own location (so inside a worktree it installs into that worktree), skips cleanly (exit 0) when empty/unconfigured, exits 2 on an invalid phase, and propagates a non-zero hook exit so a failed bootstrap surfaces.
  • .claude/gates.json + .claude/self/gates.json — new "worktree": { setup, teardown } block documenting the hook. Self ships both empty (node/bash-only gates need no external state).
  • implementer.md — new step 1 "Bootstrap your worktree" (run worktree.sh setup before exploring), teardown after opening the PR; remaining steps renumbered 2–7.
  • test-runner.md — run worktree.sh setup first when gating a fresh worktree.

Scope

Harness-module slice of #9 (adapter .claude/self/gates.json, module harness = .claude/). All 5 files under .claude/. Docs coverage (GETTING_STARTED/USAGE) of the hook is a module:docs follow-up, deliberately kept out of this harness-only PR.

Gates & review

GATES_FILE=.claude/self/gates.json build + lint + test green. Runner exercised across its input space: skip→0, invalid-phase→2, no-arg→usage error, configured hook runs, failing hook propagates its code, GATES_FILE relative/absolute both resolve.

Reviewer lenses per self-adapter (correctness, tests), consensus=all: both approved (high confidence). Two cosmetic nits raised were confirmed to intentionally mirror gate.sh's existing convention (no-arg exit 1; basename in the skip message) — left as-is for consistency with the sibling script.

Closes #9.

🤖 Generated with Claude Code

Isolated implementer/reviewer worktrees lack toolchain state that lives outside
the tree (node_modules, Foundry libs from `forge install`, shared caches), so some
gates could only run in the main checkout — defeating in-worktree gating. Adds an
optional per-worktree lifecycle to the adapter so "every gate runs in isolation"
becomes actually true.

- .claude/scripts/worktree.sh — gate.sh-style runner for `setup`/`teardown`, reads
  .worktree.<phase> from the adapter, honors GATES_FILE, skips when empty, exits 2
  on a bad phase. Resolves root from its own location so inside a worktree it
  installs into that worktree.
- .claude/gates.json + .claude/self/gates.json — new "worktree" block ({setup,
  teardown}) documenting the hook; self ships both empty (node/bash-only gates).
- implementer.md — new step 1 "Bootstrap your worktree" (run worktree.sh setup
  before exploring), teardown after opening the PR; subsequent steps renumbered.
- test-runner.md — run worktree.sh setup first when gating a fresh worktree.

Docs (GETTING_STARTED/USAGE) coverage of the hook is a module:docs follow-up, kept
out of this harness-only slice. Self gates build+lint+test green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011HosUeuSvhetARboEfDW6K
@robercano-ghbot

Copy link
Copy Markdown
Collaborator Author

Superseded by #30 — this branch was cut from a stale base and went CONFLICTING on .claude/agents/implementer.md. #30 is the identical change rebased onto current main so it merges cleanly. Closing.

robercano-ghbot pushed a commit that referenced this pull request Jul 2, 2026
Rebased onto current main to resolve the conflict on .claude/agents/implementer.md
that blocked the approved PR #29 (its branch was cut from a stale base). Content is
identical to #29 — merged cleanly onto main: keeps the GitHub-identity + explicit-staging
rules already on main and layers the worktree bootstrap step + teardown + renumbering.

- .claude/scripts/worktree.sh — gate.sh-style setup/teardown runner (GATES_FILE-aware).
- .claude/gates.json + .claude/self/gates.json — new "worktree" {setup,teardown} block.
- implementer.md — step 1 bootstrap + teardown after PR; steps renumbered.
- test-runner.md — run worktree.sh setup first when gating a fresh worktree.

Supersedes #29.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011HosUeuSvhetARboEfDW6K
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.

Per-worktree setup/teardown lifecycle hooks so isolated workers can run all gates

2 participants