feat(implement): pre-flight check skips closed/already-merged issues (#936)#1113
Open
akaszubski wants to merge 4 commits into
Open
feat(implement): pre-flight check skips closed/already-merged issues (#936)#1113akaszubski wants to merge 4 commits into
akaszubski wants to merge 4 commits into
Conversation
Add three pieces of automation for unattended /implement runs: - scripts/drain-backlog.sh: one-shot sequential drainer for 16 thematic batches. Each batch runs in its own `claude -p` process (fresh context, full harness, all hooks/agents/gates active). Uses --permission-mode acceptEdits (auto-approves writes; hook decisions still block) plus --max-budget-usd cap. Stream-json + hook-event capture per batch. Resume via --from N. - scripts/triage-and-implement.sh: recurring entry point for cron/launchd. Runs /triage --auto-improvement --json, picks the top cluster's first N issues (default 8), filters out closed/PR-linked, then runs the harness headless. Aborts cleanly when working tree is dirty (cron-safe — never destroys in-progress work). - scripts/launchd/: macOS launchd plist + README to wire the recurring script to 02:30 daily local. No --bare, no --dangerously-skip-permissions — the full harness runs exactly as it does interactively, just without the prompt loop. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ktree) The first scheduled run hit a hook deadlock at ~5 minutes: - /implement --batch creates a worktree (.worktrees/batch-TIMESTAMP) for multi-issue isolation - This repo gitignores .claude/* (line 141 of .gitignore) - `git worktree add` skips untracked files → worktree gets empty .claude/hooks/ - Once the coordinator cd's into the worktree, $(git rev-parse --show-toplevel) in the PreToolUse hook resolves to the worktree root - Hook can't find its own script → every tool call blocked → hook-deadlock protocol fires → Claude correctly waits for a user that isn't there → run exits with 0 work done Workaround: run /implement one issue at a time. Single-issue mode stays on master, no worktree, no deadlock. Slightly slower per-issue (no batch-wide research/plan-critic caching) but reliable for unattended runs. Also: drop --max-budget-usd flag from both scripts and the launchd plist. User is on Max plan subscription auth (claude.ai, firstParty), not API billing — the cap was synthetic and irrelevant. Subscription usage quotas remain the real limit, handled by the CLI directly. The --batch path still works in scripts/drain-backlog.sh for manual attended use where the user can resolve hook deadlocks if they surface. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…cklog Lists all open issues (excluding epics and PR-linked), runs single-issue /implement N on each in sequence. Per-issue markers in logs/drain-all/state/ make the script idempotent and resumable — re-running picks up where it left off, skipping completed and previously-failed issues. Single-issue mode avoids the /implement --batch worktree-hook-deadlock bug. Background-friendly: progress.log is human-readable; events.json per issue captures the full stream for diagnostics. Two modes: --phase1 top auto-improvement cluster (~36 issues, focused) (default) full backlog (~80 issues after epic/PR exclusion) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
STEP 0 of /implement now exits with BLOCKED + exit 1 when the target issue is CLOSED, or when a recent commit (last 20) references the issue number. Honors --force to override. No-op for free-text mode and graceful when gh CLI is unavailable. Prevents ~10min of wasted pipeline cycles per occurrence (cf. session 2026-04-25 burn on already-merged #926). Closes #936 Known follow-ups (file post-batch): - security-auditor MEDIUM: --force grep matches --force-something substrings; should use word-boundary regex - reviewer WARNING: \\b in git --grep is not portable to Linux git Co-Authored-By: Claude Opus 4.7 (1M context) <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
STEP 0 of
/implementnow fast-fails when the target issue is already CLOSED or recently merged, preventing wasted pipeline cycles.gh issue view --json title,bodyto also fetchstate(no additional API call)ISSUE_STATE != "OPEN"git log -n 20 --grep "#${N}\b"returns matches#Nin args) and whenghis unavailable--forceflag overrides both checkstests/unit/commands/test_implement_preflight_issue_check.py--forceflag and BLOCKED behavior indocs/PIPELINE-MODES.mdCloses #936
Test plan
tests/unit/commands/: 152 passed, 2 pre-existing failures (stash-verified), 2 pre-existing skipsKnown follow-ups (will file separately)
grep -q -- "--force"matches substrings like--force-push; should use word-boundary regex\bingit --grepnot portable to Linux git (BRE doesn't recognize); use[^0-9]insteadPipeline notes
Ran via /implement batch mode in worktree
.worktrees/batch-20260523-214713. 9 agents dispatched (planner, plan-critic, planner re-plan, implementer, spec-validator, reviewer, security-auditor, doc-master, CIA). Spec-validator PASS 9/9 ACs. Doc-master also updated CHANGELOG.🤖 Generated with Claude Code