Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
docs(claim): use a sub-agent for the claude reviewer instead of claude -p
Adam Eivyd8d145fd42e6
diff --git a/.claude/commands/claim.md b/.claude/commands/claim.mdindex c66d642308..8855c5b1e1 100644--- a/.claude/commands/claim.md+++ b/.claude/commands/claim.md@@ -25,7 +25,7 @@ The two sources never mix in one run. In issues mode, treat `issue-<num>` as the- **`<slug>` / `#<issue>`** — claim THAT specific item instead of auto-picking. Useful for cherry-picking out-of-order work. In PLAN.md mode the token is a slug that must already exist in PLAN.md as a `- [ ]` line (this command never assigns new IDs — that's `/do:replan`'s job). In `--issues` mode the token is an issue number, written either bare (`123`) or with a leading `#` (`#123`); strip the `#` when parsing. The issue must be open and filed by the repo creator (see `--issues` below).- **`--issues`** — switch the work source from PLAN.md to **GitHub issues**. Auto-pick walks open issues *filed by the repo creator* (the repository owner — resolve with `gh repo view --json owner -q .owner.login`) oldest-first and claims the first one not already in flight. In this mode PLAN.md is never read or edited, and any major issue discovered during code review is filed as a **new GitHub issue** rather than appended to PLAN.md. Mutually compatible with `--review-with` / `--no-review`.- **`--plan`** — before writing any code, enter an **interactive plan-mode session**: present a written implementation plan, surface open questions, and get the user's explicit approval before implementing. The plan step runs in Phase 3.5 — *after* the worktree is claimed and the item is verified valid (Phase 1–3), so you plan with full worktree context and, in issues mode, the cross-machine `@me` marker already protects the claim while you deliberate. If the user rejects the plan or asks to stop, run Phase 7 cleanup (and, in issues mode, release the in-progress marker) exactly as a Phase 3 skip does. When omitted, `/claim` proceeds straight from verification to implementation with no interactive pause. Compatible with every other flag.-- **`--review-with=<reviewer>[,<reviewer>…]`** — name which reviewer(s) run the post-PR review loop in Phase 6, where each `<reviewer>` is `copilot|codex|agy|claude` (the `agy` slug also accepts the aliases `gemini` and `antigravity`, which normalize to `agy` — the Antigravity CLI's binary, successor to the Gemini CLI). Comma-separate to request several (e.g. `--review-with=claude,codex` runs both review loops and converges when all agree). This flag expresses a **preference, not an absolute mandate**: it says "if a review runs, use these reviewer(s)" and leans strongly toward actually reviewing — but the agent may still skip `/simplify` and/or trim the external pass (down to a single reviewer, or skip it entirely) when the diff is *genuinely trivial* (a literal value swap, a typo/comment fix, a PLAN-only edit, a doc-only revert). Always state any skip/trim and why. **No default — when omitted, the agent decides from scratch in Phase 6 whether the diff warrants `/simplify` and/or an external review at all** (a 3-line value swap doesn't; a multi-file feature change does). `copilot` drives the GitHub Copilot review-and-fix loop via `/do:pr`; `codex`/`agy`/`claude` skip Copilot and run an iterative CLI-based review against the PR diff. Record the parsed value as `REVIEWER` (a list of reviewer names, with any `gemini`/`antigravity` normalized to `agy`; or `auto` when omitted) and reference it in Phase 6.+- **`--review-with=<reviewer>[,<reviewer>…]`** — name which reviewer(s) run the post-PR review loop in Phase 6, where each `<reviewer>` is `copilot|codex|agy|claude` (the `agy` slug also accepts the aliases `gemini` and `antigravity`, which normalize to `agy` — the Antigravity CLI's binary, successor to the Gemini CLI). Comma-separate to request several (e.g. `--review-with=claude,codex` runs both review loops and converges when all agree). This flag expresses a **preference, not an absolute mandate**: it says "if a review runs, use these reviewer(s)" and leans strongly toward actually reviewing — but the agent may still skip `/simplify` and/or trim the external pass (down to a single reviewer, or skip it entirely) when the diff is *genuinely trivial* (a literal value swap, a typo/comment fix, a PLAN-only edit, a doc-only revert). Always state any skip/trim and why. **No default — when omitted, the agent decides from scratch in Phase 6 whether the diff warrants `/simplify` and/or an external review at all** (a 3-line value swap doesn't; a multi-file feature change does). `copilot` drives the GitHub Copilot review-and-fix loop via `/do:pr`; `codex`/`agy`/`claude` skip Copilot and run an iterative independent review against the PR diff. Note the dispatch difference (see Phase 6.2b): inside a Claude Code harness, the `claude` reviewer runs as a **sub-agent** (Agent/Task tool), not a `claude -p` subprocess — same independent-context review, native to the harness; `codex`/`agy` are reached via their CLI binaries. Record the parsed value as `REVIEWER` (a list of reviewer names, with any `gemini`/`antigravity` normalized to `agy`; or `auto` when omitted) and reference it in Phase 6.- **`--no-review`** — explicit opt-out from BOTH `/simplify` and the external review pass. Use when you want the agent to just ship without deliberation (e.g. a doc-only revert). Mutually exclusive with `--review-with`.## Phase 1: Pick@@ -285,12 +285,16 @@ When `/simplify` is deferred but an external review will run, run `/simplify` fi--body "<PR body>" # issues mode: include a "Closes #<num>" line so merge auto-closes the issue```Capture the PR number as `PR_NUM`.- 3. **Pick the CLI invocation per requested reviewer** (run each one when several are requested). **Pass the whole prompt — including the inlined diff — as the prompt ARGUMENT, never via stdin.** `agy -p` (`--print`) and `claude -p` take the prompt as the positional argument right after the flag; piping into them (`… | agy -p`, `agy -p < file`) fails with `agy --print takes the prompt as an argument, not stdin` and wastes an invocation. Build the prompt once with `PROMPT="$(cat /tmp/claim-${SLUG}-prompt.md)"` and pass `"$PROMPT"` as the argument. `codex exec` still *opens* stdin even when the prompt is an argument and will block forever waiting on it, so its row redirects `< /dev/null`:- | reviewer | Command |- |---|---|- | `codex` | `codex --sandbox danger-full-access exec "$PROMPT" < /dev/null` |- | `agy` | `agy --dangerously-skip-permissions -p "$PROMPT"` |- | `claude` | `claude -p "$PROMPT" --dangerously-skip-permissions` |+ 3. **Dispatch each requested reviewer** (run each one when several are requested). The dispatch mechanism differs by reviewer:++ - **`claude` → dispatch a sub-agent, NOT `claude -p`.** When you are already running inside a Claude Code harness (you are — `/claim` is a Claude Code command), the `claude` reviewer must be a fresh **sub-agent** via the Agent/Task tool, not a `claude -p` subprocess. A sub-agent gives the same value `claude -p` was meant to provide — an independent, context-isolated Claude review — but native to the harness: structured return value, no separate auth/billing, no backgrounding quirks, and access to the session's tools so it can read repo files for context. Spawning `claude -p` from inside Claude Code launches a redundant second process and is the wrong call here. Pass the review prompt (with the inlined diff, or instruct the sub-agent to run `git diff origin/main...HEAD` itself) as the sub-agent prompt; have it return findings in the same `[SEVERITY] file:line — …` format ending in a `CLEAN`/`FINDINGS` verdict line.+ - **`codex` / `agy` → CLI invocation.** These are genuinely different engines with no in-harness sub-agent equivalent, so they're reached via their binaries. **Pass the whole prompt — including the inlined diff — as the prompt ARGUMENT, never via stdin.** `agy -p` (`--print`) takes the prompt as the positional argument right after the flag; piping into it (`… | agy -p`, `agy -p < file`) fails with `agy --print takes the prompt as an argument, not stdin` and wastes an invocation. Build the prompt once with `PROMPT="$(cat /tmp/claim-${SLUG}-prompt.md)"` and pass `"$PROMPT"` as the argument. `codex exec` still *opens* stdin even when the prompt is an argument and will block forever waiting on it, so its row redirects `< /dev/null`. Run these in the background (so the loop can run codex + a claude sub-agent concurrently for the initial pass):+ | reviewer | Command |+ |---|---|+ | `codex` | `codex --sandbox danger-full-access exec "$PROMPT" < /dev/null` |+ | `agy` | `agy --dangerously-skip-permissions -p "$PROMPT"` |++ (If for some reason you are NOT in a Claude Code harness — e.g. this flow is being driven by codex or agy as the main loop — then `claude` has no in-harness sub-agent and falls back to the CLI form `claude -p "$PROMPT" --dangerously-skip-permissions`. Inside Claude Code, always prefer the sub-agent.)4. **Review-and-fix loop — converge to mutual agreement, no iteration cap.** Loop until the main agent AND every requested review CLI agree the PR is ready to merge. The agent (you) decides when the review is producing real value vs. nit-grade churn; each review CLI decides when nothing actionable remains for it. With multiple reviewers, gather all of their findings each iteration, dedup, and converge only when they are all CLEAN. Each iteration:```bash# 1. Capture the latest diff@@ -313,10 +317,13 @@ Context: iteration <N>. Prior iterations flagged + fixed:$(cat /tmp/claim-${SLUG}-pr.diff)EOF- # 3. Run the chosen CLI against the prompt — pass it as the ARGUMENT, not via stdin.- # (agy/claude -p read the prompt from the argument; `< file` is ignored and agy errors out.)+ # 3. Run each requested reviewer against the prompt:+ # - claude → dispatch a sub-agent (Agent/Task tool) with the prompt; capture its returned findings.+ # - codex/agy → run the CLI, passing the prompt as the ARGUMENT (not stdin; `< file` is ignored+ # and agy errors out). codex needs `< /dev/null` so it doesn't block on stdin.PROMPT="$(cat /tmp/claim-${SLUG}-prompt.md)"- <CLI_CMD for REVIEWER, with "$PROMPT" as the prompt argument per the table above> > /tmp/claim-${SLUG}-review.md+ <codex/agy CLI for each requested CLI reviewer, with "$PROMPT" as the argument per the table above> > /tmp/claim-${SLUG}-review-<reviewer>.md+ # (the claude reviewer's findings come back as the sub-agent's return value, not a file)```**Loop-exit decision tree** (your call as the main agent):