feat(agents): enforce worktree-per-ticket in /implement's first step - #222
Merged
Merged
Conversation
…QR221-01, #QR221-02, #QR221-03] - ai-agents/skills/implement/SKILL.md: bare-worktree detection now requires more than one git worktree list entry, not just the current worktree showing (always true) - ai-agents/skills/implement/SKILL.md: scope the EnterWorktree path claim to the main session's own launch directory; add the pinned-subagent fallback (stop and hand back, or EnterWorktree name:) - ai-agents/skills/implement/SKILL.md: add an explicit stop-and-ask fallback when Codex CLI/Pi cd persistence can't be confirmed and no runtime primitive exists Refs: AB#221
…tch [#QR221-04] - ai-agents/skills/dispatch-implement/SKILL.md: step 5's parent branch-off now names the branch explicitly for a multi-ticket run (epic/spec slug when shared, else the first ticket listed) instead of relying on /implement's single-ticket naming rule Refs: AB#221
- docs/adr/implement-enforces-worktree-per-ticket-in-its-own-first-step.md: reword the
title and three body instances of 'X, not Y' phrasing to state the positive directly,
per AGENTS.md; leave the Rejected alternatives section's contrast untouched
- align the title's wording with the filename ('worktree-per-ticket')
Refs: AB#221
… reference [#QR221-06, #QR221-07] - ai-agents/skills/dispatch-implement/SKILL.md: step 5's branch-off paragraph now states the instruction plus one why-sentence, with a resolvable pointer to the ADR instead of restating its rejected-alternative rationale inline - ai-agents/skills/dispatch-implement/SKILL.md: step 6 drops the changelog-style 'same as before this ADR' phrasing (unlinked, references history rather than current state) Refs: AB#221
…mplement enforcement - ai-agents/AGENTS.d/git-worktrees.md: don't hardcode the default branch name; note that /implement's first step now enforces the branch-per-ticket rule automatically Refs: AB#221
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.
Problem
AGENTS.d/git-worktrees.mddocuments the bare-worktree layout's core rule: a new branch meansa new worktree, never
git checkout -binside the default-branch worktree. The rule wasadvisory only, so nothing stopped
/implementfrom running directly onmain.Solution
/implement's own first step now detects the repo's default branch (never hardcoded, so itstill works on a repo whose default isn't
main) and, if the current branch is the defaultbranch, branches off automatically before doing anything else:
git worktree addin thebare-worktree layout,
git checkout -bin a normal clone. No hook, no marker file, no newstate, just plain skill-instruction text.
dispatch-implement's dispatch step now branches off once, before dispatching any child(parallel or sequential), whenever the invoking session itself starts on the default branch.
Otherwise
/implement's new check would spawn one throwaway worktree per ticket, and theintegration step would cherry-pick every child's commits back onto the default branch.
Full rationale and rejected alternatives (a
PreToolUsehook + marker file, a hard-blockinghook, confirm-before-create) are recorded in
docs/adr/implement-enforces-worktree-per-ticket-in-its-own-first-step.md.Review
Reviewed with
quick-review(Fable folded reviewer plus Codex ongpt-5.6-sol); all 7findings raised were fixed: a bare-worktree-detection bug (
git worktree listalways showsthe current worktree, so the original check misclassified every normal clone), an
EnterWorktreescoping gap for pinned subagents, an explicit stop-and-ask fallback for CodexCLI/Pi's unverified
cdpersistence, multi-ticket branch naming fordispatch-implement, andthree documentation-quality fixes.
Fixes #221