/prime:goalfrom prime
Speed-first goal-oriented loop — set an objective, agent picks next concrete action, captures evidence, stops at PR. Different from /autopilot (rigor-first multi-issue queue).
Ships in prime. Installing the plugin adds it to Claude Code.
/goal <objective> is a lightweight, fast autonomous loop for one freeform objective.
Different from /autopilot (which ranks a backlog and works items P0–P5 with full risk
classification). /goal is single-objective, speed-optimized — you tell it the destination,
it figures out the steps, captures evidence, and stops at PR creation for your approval.
| Need | Use |
|---|---|
| "Cut the homepage LCP under 2s" | /goal (single objective, exploratory path) |
| "Work through my backlog" | /autopilot (ranked queue, risk-classified) |
| "Add user avatars" (well-defined feature) | /planning → /implement |
| "Fix this bug #141" | /fix |
/goal shines when the destination is clear but the path is not.
/goal <objective> — set a freeform goal and start the loop--prototype — speed mode: happy-path build, targeted tests only, discovered
scope may be deferred to issues. For demos, spikes, "show me it working".--full — production mode (default when the objective says "production",
"customer", "polish", "end to end", or "don't defer"): NOTHING is deferred
without user sign-off, every deliverable independently verified, E2E required.--merge-on-green — after each PR, watch CI and merge on green instead of
stopping (user pre-authorizes the merge gate for this goal). Without it,
every PR remains a hard stop./goal pause — pause the active goal (state preserved)/goal resume — resume the paused goal/goal clear — discard the active goal (archives state)/goal status — show current goal, completed sub-tasks, evidence, next actionIf invoked with no arguments AND a goal is active, treat it as status.
All goal state lives under .claude/.goals/:
.claude/.goals/
├── current.json # active goal (one at a time)
└── archive/
├── {id}-{slug}.json # completed/cleared goals
└── ...
The current.json schema:
{
"id": "g_20260501_180412",
"slug": "cut-homepage-lcp",
"objective": "Cut homepage LCP below 2s on mobile",
"status": "clarifying|proposed|active|paused|awaiting_pr|done|cleared",
"mode": "prototype|full",
"agents": [
{"name": "lane-a", "lane": "accuracy fixes", "worktree": "../wt-a", "started_at": "…", "last_seen_at": "…", "status": "running|idle|done|taken_over"}
],
"clarifications": [
{"q": "Replace existing approach or add alongside?", "a": "Add alongside"},
{"q": "Web only or web+mobile?", "a": "Web only for v1"}
],
"started_at": "2026-05-01T18:04:12Z",
"updated_at": "2026-05-01T18:11:00Z",
"approach": {
"summary": "Profile -> defer non-critical JS -> compress hero image -> inline critical CSS",
"proposed_by": "explore-light",
"proposed_at": "2026-05-01T18:04:30Z"
},
"requirements": [
{
"id": "r1",
"text": "LCP < 2s on Moto G4 throttled",
"evidence_type": "metric",
"artifact_hint": "lighthouse JSON for /",
"satisfied": false
},
{
"id": "r2",
"text": "No regression in CLS or TBT",
"evidence_type": "metric",
"artifact_hint": "lighthouse JSON before/after",
"satisfied": false
}
],
"subtasks": [
{
"id": "s1",
"text": "Audit current homepage with lighthouse",
"done_when": "lighthouse JSON saved AND top 3 blockers identified",
"status": "pending|in_progress|done|skipped",
"evidence": []
}
],
"evidence": [
{
"turn": 3,
"kind": "git-diff|test-result|pr|file|metric|note",
"ref": "abc123 (3 files, +42/-8)",
"summary": "Deferred analytics + compressed hero",
"satisfies": ["s2"],
"captured_at": "2026-05-01T18:09:11Z"
}
],
"turns": [
{
"n": 1,
"action": "Run lighthouse, capture baseline",
"outcome": "LCP 3.4s, hero image 1.8MB",
"at": "2026-05-01T18:05:00Z"
}
],
"stops": {
"at_pr": true,
"blocked_reason": null,
"auto_continue": true
},
"cost": {
"agents_spawned": 1,
"turns_taken": 3
}
}
/goal is project-aware. Before scouting, before clarifying, before doing
anything, you MUST read the project knowledge files (skip silently if a
file doesn't exist — first run on a fresh project is fine):
| File | What it gives you | When it changes the goal |
|---|---|---|
.claude/project-profile.md | Tech stack, architecture patterns, testing style | Always — informs subtask shape and tooling |
.claude/knowledge/shared/conventions.md | Coding rules learned from corrections | When writing or editing any code |
.claude/knowledge/shared/domain.md | Business rules beyond what's in the code | When the goal touches domain logic |
.claude/knowledge/shared/patterns.md | Architecture patterns | When adding new modules or services |
.claude/knowledge/shared/vocabulary.md | What the team calls things | Always — use these terms in subtasks, evidence, PR body |
.claude/knowledge/shared/deployment.md | Deploy landscape | When the goal involves infra or release |
.claude/knowledge/shared/behavior-corrections.md | Past mistakes — DO NOT repeat | Always — guards against known footguns |
Treat these as hard inputs to the scout's prompt. Pass relevant excerpts into Phase 1 so explore-light's findings are calibrated to the project's actual conventions, not generic best practices.
When you discover something non-obvious during the loop, write it back
immediately — don't wait for goal completion. Future agents (including the next
/goal run) inherit the lesson.
| Discovery | Write to |
|---|---|
| Reusable architecture pattern | .claude/knowledge/shared/patterns.md |
| Coding rule (style, convention) | .claude/knowledge/shared/conventions.md |
| Business rule not in the code | .claude/knowledge/shared/domain.md |
| New term the team uses | .claude/knowledge/shared/vocabulary.md |
| Deployment gotcha | .claude/knowledge/shared/deployment.md |
| Mistake you (or a previous agent) made | .claude/knowledge/shared/behavior-corrections.md |
| Skill-specific learning | .claude/knowledge/skills/goal.md (create if missing) |
Format each entry with date, the lesson, and a 1-line "why this matters". Keep entries terse — append, don't rewrite.
If kg-write.sh exists (plugin: ${CLAUDE_PLUGIN_ROOT}/skills/knowledge-graph/, symlink install: .claude/skills/knowledge-graph/), also push reusable
patterns to the KG so other skills benefit:
KG_WRITE="${CLAUDE_PLUGIN_ROOT}/skills/knowledge-graph/kg-write.sh" # plugin install: Claude Code substitutes the root at load
[ -f "$KG_WRITE" ] || KG_WRITE=".claude/skills/knowledge-graph/kg-write.sh" # symlink install
[ -f "$KG_WRITE" ] && "$KG_WRITE" pattern "<terse insight>" "goal"
Inside current.json, capture the relationships the goal touches. These make
future audits and impact analysis trivial:
"connections": {
"files_touched": ["app/page.tsx", "app/components/Hero.tsx"],
"tests_affected": ["app/components/Hero.test.tsx"],
"patterns_discovered": ["dynamic imports for non-critical analytics"],
"knowledge_files_updated": [".claude/knowledge/shared/patterns.md"],
"related_goals": ["g_20260420_141200"],
"pr": null,
"review_outcome": null
}
Update connections after each turn — it's the graph projection of the
evidence log.
READ THIS CAREFULLY. The model that runs
/goalis YOU. You will be tempted to skip verification because "the change looks right." DO NOT. Models that skip verification ship broken code. This protocol exists because verification is the single highest-leverage step in the loop.
You MUST run verification after EVERY code change. You MUST NOT mark a subtask complete without verification evidence. You MUST NOT say "I'll verify later." Verification is now, not later.
For every subtask whose action involved writing or editing code, the following
checklist must be fully complete with cited evidence before status flips
to done:
If the project has /precheck (toolkit-installed), run it before any commit.
Cite the output.
If the changed code has no test coverage:
.claude/project-profile.md and existing test files).This is not optional. Untested code is unverified code.
verified booleanWhen appending to evidence[], every entry that represents a code change or
test run carries:
{
"id": "eN",
"kind": "git-diff|test-result|lint-result|type-result|file|...",
"ref": "<command or sha>",
"summary": "<what>",
"verified": true,
"verification_evidence_id": "eM",
"satisfies": ["sN"],
"captured_at": "<iso>"
}
verified: true is set only when another evidence entry (test run, lint
pass, etc.) confirms the change works. The verification_evidence_id points
at that confirming entry.verified: false for "I made the change but haven't yet run tests" — this is
a transient state. The next turn must run verification before any further
changes.verified: false. No exceptions. Re-run verification or mark the subtask
blocked.The model running this skill will be tempted to skip verification — especially when the change "obviously works" or when running tests is slow. The skill enforces these rules:
in_progress and verify in the next turn — never skip ahead.behavior-corrections.md entry
describing what went wrong.verified: false, the next turn must verify them — not
add more changes.evidence[].verified. A run with
stale verified: false entries is "not making progress" for loop-guard
purposes — the hook will eventually bail and force user intervention.When tests fail or types break:
behavior-corrections.md, and ask the user.Don't. Pause the goal and explain the risk. The user can /goal clear if they
truly want to abandon the verification gate, but the loop won't ship unverified
code.
Detect the mode from the objective (or explicit flag) and RECORD it in
current.json as "mode". It changes the loop's spine:
| Dimension | --prototype | --full |
|---|---|---|
| Scope discipline | Happy path; edge cases → issues | Never defer. Discovered scope is IN scope unless the user explicitly moves it out |
| Tests | Targeted tests for the change | Unit + integration + E2E; suites green before every merge |
| Verification of agents | Trust + spot-check | Independently re-run every agent's claimed evidence |
| Skipped/weakened tests | Allowed with a comment | Banned — a skipped test needs a tracked issue + user ack |
| UI work | Functional | Visually verified (screenshots/browser) against design intent |
| Ship gate | Single PR at the end is fine | Stream of small CI-watched PRs |
"Never compromise" in full mode means: when an agent hands back something
that almost meets the bar (tests skipped, assertion weakened, scope quietly
narrowed, "works locally"), the orchestrator REJECTS it and either sends it
back with a precise gap list or takes the work over. Log every rejection in
turns[] — rejections are progress.
/goal is an ORCHESTRATOR loop. The main session PLANS, VERIFIES, and ARBITRATES on the strongest available model; execution is delegated to cheaper models.
Model policy (record deviations in turns[]): when ARTH_ROUTER_URL is
set, a per-spawn Arth Router decision (see Phase 4) takes precedence for that
spawn — this table is the router-absent fallback.
| Role | Model | Why |
|---|---|---|
| Vision → architecture → task plan, requirement design | Strongest available model tier — the main loop itself | Judgment concentrates here |
| Root-cause analysis when agents are stuck; final goal-completeness review | Strongest available | Debugging novel failures is judgment work |
| Implementation subtasks (backend/frontend/tests/docs) | Sonnet subagents | 80% of the work at ~1/6 the cost |
| Scouting, file inventory, mechanical sweeps | Haiku (explore-light) | Cheap breadth |
Parallel lanes (the biggest speed lever):
git worktree add ../wt-<lane> -b <branch> origin/main).
Never let two agents share a working tree.git rebase origin/main + union-resolve, force-push.Every agent prompt MUST carry (non-negotiable):
behavior-corrections.md; never let an agent run suites bare)Toolkit-first routing: before executing any subtask inline, check the installed skill catalog — is there a skill/agent that encodes this workflow? Typical mappings: design audits → hallmark/design skills; QA passes → /qa; pre-push checks → /precheck; PR mechanics → /pr; incident triage → /incident; tech-debt sweeps → /tech-debt; deep review → code-review. Record what was routed where. If nothing fits and the pattern recurs, note it as a toolkit gap in the goal's learnings.
Orchestrator judgment rules:
Track every spawned agent in current.json under agents[]:
{name, lane, worktree, started_at, last_seen_at, status, decision_id?}
(decision_id only when the lane's spawn was router-routed — Phase 4).
git log/status) — commits/dirty files = alive; nothing new
since last check = stalled.agents[] entry has a
decision_id): when the lane lands, or on takeover/abandonment, run ONE
trivial command: bash "$(echo "${CLAUDE_PLUGIN_ROOT}" | sed 's|^$|.claude|')/skills/_lib/arth-router.sh" outcome <decision_id> <true|false> [overridden true|false] — true on a clean
landing, false on takeover/abandonment; pass overridden true only when a
router decision was returned but a different model was deliberately used.
Silent, fail-open, never blocks.stops.auto_continue=false with blocked_reason: "wait-mode: ..." and
schedule a fallback wakeup (20–30 min). Re-enable on the first completion
event. Never burn turns polling.Auto-continue is for progress, not for spinning. STOP and ask the user when:
| Trigger | Threshold |
|---|---|
| Same failure surviving distinct fix theories | 2 theories tried with evidence → present findings + options |
| Same subtask without a verified deliverable | 4 turns (the hook's stuck-guard) |
| CI red on main after a merge | Fix-forward once; if the second attempt fails, escalate |
| Anything destructive/irreversible beyond the repo (prod systems, data deletion, force-push to shared branches) | Always, before acting |
| Data loss discovered | Immediately: report scope + containment + recovery options before continuing |
| Architecture forks that change the goal's shape | Present 2–3 options with a recommendation |
| Spawn/cost budget exceeded | Report burn + remaining plan, get an explicit go |
Escalation format: what broke (exact error), why (root cause or best theory), what was tried, 2–3 options with a recommendation. Never a bare "it failed."
The user should always be able to answer "what's happening, what's left, when is it done" from the last message.
GOAL turn {n}: {action} — {outcome}. Subtasks {x}/{y}.{N} merged · {list in-CI} · {list building} · reqs {a}/{b}/goal status): requirements table with per-req proof,
lanes with per-lane state, incidents/escalations so far, ETA.behavior-corrections.md.reuseExistingServer + a stale server = testing stale code, an
invisible false signal). One stale process can invalidate hours of "results"..env* files leak into dev-server children and
can silently flip feature flags in "flag-off" test servers. Flag-sensitive
test configs must set the flag env EXPLICITLY (empty string beats dotenv).Look at the user's argument:
| Argument | Action |
|---|---|
pause | Set status: "paused", write state, report briefly. STOP. |
resume | Read current.json, set status: "active", jump to Phase 4 (NEXT ACTION). |
clear | Move current.json → archive/{id}-{slug}.json, report briefly. STOP. |
status | Print compact status block. STOP. |
| (empty + active goal) | Treat as status. |
| (empty + no goal) | Print: "No active goal. Use /goal <objective> to start." STOP. |
<objective> text | Phase 1 (NEW GOAL). |
The rest of this skill describes the new-goal flow.
If current.json already exists with status ∈ {clarifying, proposed, active, paused, awaiting_pr}:
Existing goal active: "{objective}" (status: {status}).
Replace it? [r] replace [k] keep current [c] cancel
Wait for the user. If r: archive the existing goal first. If k or c: stop.
Otherwise, create the new goal.
Generate the goal id and slug:
id: g_YYYYMMDD_HHMMSS (UTC)slug: lowercase-kebab of first 4-5 meaningful words from objective, max 40 charsThe knowledge base is the project's accumulated wisdom. Read it before reaching for grep. What the team already documented should not be rediscovered by scanning files.
Read these files in order (skip silently if a file doesn't exist):
# Project meta
.claude/project-profile.md # stack, architecture, testing style
# Shared knowledge (the team's institutional memory)
.claude/knowledge/shared/conventions.md # coding rules
.claude/knowledge/shared/domain.md # business rules
.claude/knowledge/shared/patterns.md # architecture patterns
.claude/knowledge/shared/vocabulary.md # team terminology
.claude/knowledge/shared/deployment.md # deploy landscape
.claude/knowledge/shared/behavior-corrections.md # past mistakes (do NOT repeat)
.claude/knowledge/shared/goals-history.md # what /goal runs have done before
.claude/knowledge/skills/goal.md # /goal-specific learnings (if it exists)
# External sources (where team knowledge lives outside the repo)
.claude/knowledge/external/sources.md
Synthesize what the knowledge base already tells you about the goal:
domain.md or project-profile.md)conventions.md and project-profile.md)patterns.md)goals-history.md)behavior-corrections.md)If the knowledge base answers something definitively, do not ask the user
about it in CLARIFY. State it as an assumption ("I see from domain.md that
auth is Stytch — Google SSO will be added alongside, not replacing it") and
let the user override if wrong.
Scan .claude/.goals/archive/*.json (and current.json if any) for prior goals
that touched related files or covered related topics. Read their
approach.summary, clarifications, connections, and final outcomes.
# List archived goals
ls .claude/.goals/archive/ 2>/dev/null
# For each, read approach + connections.files_touched + connections.patterns_discovered
# Match against the new objective's keywords + likely files.
Compiled Memory Context (arth-memory Tier 0.5 — if configured): the first
rung of the 3-rung ladder (full contract: skills/_lib/arth-memory-tier05.md).
Attempted ONLY when both bash gates below pass — each line is a single
trivial command (a compound block trips the Bash guard):
bash skills/_lib/arth-memory.sh status # must print "configured" — anything else → skip to the ranked-context fallback below (marketplace-plugin path: "${CLAUDE_PLUGIN_ROOT}/skills/_lib/arth-memory.sh")
grep -m1 '^ARTH_MEMORY_HEALTH=' .claude/.arth-memory.env 2>/dev/null # must be ARTH_MEMORY_HEALTH=ok — anything else (or missing file) → skip to the ranked-context fallback below
bash skills/_lib/arth-memory.sh scope-key # → owner/repo; becomes the compile_context scope_key arg
If both gates pass, call mcp__arth-memory__compile_context with:
scope_key — the scope-key output abovetask — the same <objective keywords> that the kg-query call below uses
(extract once, reuse for both — do not derive a second keyword set)budget: 2000If the tool is unavailable, errors, or returns empty: inject nothing and fall through to the kg-query call below, unchanged.
On success: prepend the result under ## Compiled Memory Context (arth-memory), [mem:…] citation tokens preserved verbatim.
If kg-query.sh exists (plugin: ${CLAUDE_PLUGIN_ROOT}/skills/knowledge-graph/, symlink install: .claude/skills/knowledge-graph/), also pull ranked
context (fallback rung — fires when arth-memory is absent, unhealthy, or
returned nothing above):
KG_QUERY="${CLAUDE_PLUGIN_ROOT}/skills/knowledge-graph/kg-query.sh" # plugin install: Claude Code substitutes the root at load
[ -f "$KG_QUERY" ] || KG_QUERY=".claude/skills/knowledge-graph/kg-query.sh" # symlink install
[ -f "$KG_QUERY" ] && "$KG_QUERY" "<objective keywords>" --top 8 --threshold 0.3
Note any related goals — they go into connections.related_goals[] later.
Now spawn explore-light to fill gaps the knowledge base didn't answer. The
prompt must include the knowledge findings so the scout doesn't re-derive
them. The codebase scan is supplementary, not primary:
Use the Task tool with subagent_type="explore-light" and this prompt:
"Goal: {objective}
What we already know from the knowledge base (DO NOT re-derive these — only
verify if needed):
- Stack: {from project-profile.md}
- Relevant conventions: {extracted from conventions.md}
- Domain rules: {extracted from domain.md}
- Existing patterns: {extracted from patterns.md}
- Past relevant goals: {summarized from goals-history.md and prior .goals/}
- Footguns to avoid: {extracted from behavior-corrections.md}
Knowledge gaps you need to fill (focus your scan on these):
{specific list of things the KB didn't cover for this goal — typically: exact
file paths to touch, current behavior of a specific function, recent test
patterns for the changed area}
Scan rules:
- Do NOT re-discover what's listed above. If you find conflicting info, flag
it (the KB may be stale).
- Sample 1-2 files at most for pattern confirmation.
- Under 300 words total.
Return JSON-ish structure:
- kb_confirmed: list of KB facts you confirmed still apply
- kb_stale: list of KB facts that look out-of-date (with new file/line refs)
- new_findings: things the KB didn't cover that matter for this goal
- ambiguities: 0-5 places where the objective is still under-specified.
For each: the question, why it matters, the most likely default
- approach: 1-3 sentences (best guess given KB + codebase)
- requirements: 2-5 measurable acceptance items
- subtasks: 3-7 ordered steps, each with a 'done_when' clause
- relevant_files: top 5-10 file paths"
Wait for the report. If the scout flagged kb_stale items, schedule a
write-back to update the affected knowledge file (do this in Phase 7 LEARNINGS,
not now — don't fork the loop).
Save scout output + KB findings to current.json partial state with
status: "clarifying" so a session interruption can resume from CLARIFY.
Record what informed the goal in current.json:
"context_sources": {
"kb_files_read": [".claude/project-profile.md", ".claude/knowledge/shared/conventions.md", "..."],
"related_goals": ["g_20260420_141200"],
"kg_results": 5,
"scout_files_sampled": 3
}
Move to Phase 2 (CLARIFY).
Don't skip this phase. A goal is "understand intent fully, then execute autonomously" — not "guess and hope." Even when the user is impatient, a 30-second Q&A loop saves whole-day rework.
Build the question list from scout's ambiguities:
For each ambiguity, decide whether to ASK or ASSUME-AND-CONFIRM:
| Situation | Action |
|---|---|
| Codebase clearly answers the question (only one option fits the existing patterns) | ASSUME-AND-CONFIRM (state the assumption in the plan, don't ask) |
| Two+ options are equally plausible AND the choice changes the approach | ASK |
| Ambiguity is downstream (only matters in subtask 5) | DEFER (handle when we get there) |
| Trivial detail (naming, formatting) | ASSUME silently — senior engineer judgment |
Question quality rules (this is the difference between useful and a footgun):
backend/app/auth/stytch.py — replace it or add
Google as a second option?") Generic ("which auth provider?") is wrong.ApiError shape in backend/app/errors.py, (b) introduce a new AuthError
class, or (c) propagate upstream without wrapping?"Present questions in one block — don't drip-feed. Users prefer answering all at once. Format:
GOAL: "{objective}"
I read the project knowledge first, then scanned the codebase. Before I start,
a few questions to make sure I solve the right problem:
What I already know (from .claude/knowledge/ + project-profile.md):
• {kb_fact_1}
• {kb_fact_2}
• {kb_fact_3 — e.g., "behavior-corrections.md says: don't auto-generate Alembic migrations"}
Codebase findings (gaps the KB didn't cover):
• {finding_1}
• {finding_2}
Questions:
Q1. {question_1}
(a) {option_a}
(b) {option_b}
(c) {option_c}
Default if unanswered: {most_likely_default}
Q2. {question_2}
(a) {option_a}
(b) {option_b}
Q3. {question_3}
(open-ended — answer freely if you have a preference, otherwise I'll {default})
Assumptions I'm making (tell me if any are wrong):
• {assumption_1}
• {assumption_2}
Answer all at once or one at a time. Or just say "go" to accept all defaults.
Wait for the user's answer. Parse it — answers can be:
If anything is unclear, ask one focused follow-up — never re-ask the whole list.
Update scout output with answers. Adjust approach, requirements,
subtasks based on what the user said. Note overridden assumptions in
current.json under clarifications[]:
"clarifications": [
{"q": "Replace Stytch or add Google alongside?", "a": "Add alongside — keep Stytch as fallback"},
{"q": "Web only or web+mobile?", "a": "Web only for v1"}
]
Move to Phase 3 (CONFIRM PLAN).
Build current.json (now with clarified info):
objective, id, slug, started_at, clarifications[]approach → approach.summaryrequirements → requirements[] (ids r1, r2...)subtasks → subtasks[] with status: "pending"stops.at_pr: true and stops.auto_continue: false for now (flips to
true after user confirms)status: "proposed"Present the final plan to the user (compact):
GOAL CONFIRMED: "{objective}"
Approach: {1-line summary, post-clarification}
Clarifications captured:
• {clarification_1}
• {clarification_2}
Requirements:
r1 {text} — evidence: {artifact_hint}
r2 {text} — evidence: {artifact_hint}
Subtasks:
s1 {text} (done when: {done_when})
s2 {text} (done when: {done_when})
s3 {text} (done when: {done_when})
Auto-continue: ON (will pick next action after each turn)
Hard stop at: PR creation
Proceed? [y] yes, start [n] no, let me adjust [d] dry-run (no edits, evidence only)
Wait for confirmation.
| User says | Do |
|---|---|
y / yes / go / start | Set status: "active", stops.auto_continue: true. Move to Phase 4. |
n / specific changes | Apply changes to plan, re-show, re-ask. |
d / dry-run | Set status: "active", stops.auto_continue: true, add mode: "dry_run" flag. Phase 4 will execute but skip writes. |
| anything else | Treat as a clarification — apply if applicable, otherwise ask one focused follow-up. |
This is the only confirmation gate before autonomous execution. After this point, the loop self-paces until PR creation.
This is the heart of the loop. Each turn picks ONE concrete action and executes it.
Read current.json. Find the next subtask:
in_progress subtask, if anypending subtaskIf all subtasks are done:
satisfied: true, jump to Phase 6 (PR).Pick the action. For the active subtask, decide what concrete step makes progress. Keep it small — one tool call's worth of work, or one file edit, or one test run. Avoid multi-day excursions.
Execute it. Use whatever tools are appropriate — Read, Edit, Bash, or spawn a Sonnet agent for non-trivial code work:
| Subtask shape | Tool |
|---|---|
| Read/explore/grep | Inline (Read, Grep) |
| Single file edit | Inline (Edit) |
| Multi-file backend code | Task subagent_type=python-backend (or detected backend), model=sonnet |
| Multi-file frontend code | Task subagent_type=frontend, model=sonnet |
| Run tests/lint | Inline Bash |
| Architecture decision | Stop and ask the user (escalation) |
Router-aware spawns (optional, fail-open): if ARTH_ROUTER_URL is set,
before each Task spawn run ONE trivial command (single binary — a compound
block trips the Bash guard):
bash "$(echo "${CLAUDE_PLUGIN_ROOT}" | sed 's|^$|.claude|')/skills/_lib/arth-router.sh" route implementation "<lane task summary>"
(type_hint implementation for build lanes, research for scouting spawns.)
Non-empty output (model=... effort=... decision_id=...) → use that model +
effort for the spawn, store the decision_id in the lane's agents[] entry
in current.json, and note it in this turn's evidence. Empty output (router
unset, unreachable, denied, or unmappable) → the table above stands unchanged.
Never blocks, never prompts.
Spawn budget: Per goal, do not exceed 6 Sonnet/Opus agent spawns without checking
in with the user — UNLESS the user explicitly authorized broad parallelism
("parallelize as much as possible", "use workflows/subagents", a token budget);
then state the standing authorization once at the confirm gate and track
spawns in cost.agents_spawned anyway. Prefer the Orchestration Protocol's
parallel lanes over serial spawns whenever subtasks are file-disjoint.
Capture evidence (mandatory). After the action completes, append to evidence[]:
| Action | Evidence to capture |
|---|---|
| Code edit | kind: "git-diff", ref: <sha-or-WIP>, summary: "<files +X/-Y>" |
| Test run | kind: "test-result", ref: "<command>", summary: "<N passed / M failed>" |
| Lighthouse / metric | kind: "metric", ref: "<file path or URL>", summary: "<key numbers>" |
| File created | kind: "file", ref: "<path>", summary: "<purpose>" |
| Decision/finding | kind: "note", summary: "<insight>" |
For git-diffs, capture stats only (don't store the diff itself):
git diff --stat HEAD
git diff --shortstat HEAD
Write the evidence with a satisfies: ["sN"] array linking to subtask ids.
Increment cost.turns_taken. Append to turns[] with n, action, outcome, at.
Run verification (NON-NEGOTIABLE — see "Verification Protocol" above). If this turn made any code change:
kind: "lint-result" evidence.kind: "type-result" evidence.kind: "test-result"
evidence.verified: true only after the verifying evidence
is captured. Link via verification_evidence_id.You MUST NOT skip verification. "I'll verify later" is not allowed. If the
turn ran out before verification, leave the subtask in_progress and verify
in the next turn — but never advance to a new subtask while previous changes
have verified: false.
Update connections in current.json with the files touched, tests
affected, and any patterns discovered this turn.
Self-evaluate done_when: For the active subtask, check its done_when
clause against the verified evidence. If done_when mentions tests, you
need a passing kind: "test-result" entry — not just a code edit. If
satisfied, mark status: "done". Otherwise leave in_progress for the next
turn.
Self-evaluate requirements: For each unsatisfied requirement, check if the
new evidence (with verified: true) advances or satisfies it. If satisfied,
mark satisfied: true and link the evidence id.
Write back to knowledge during execution: If this turn surfaced something
non-obvious (a new pattern, a footgun, a stale KB entry), write it to the
appropriate .claude/knowledge/shared/*.md file now. Don't wait for Phase 7
— future agents inherit the lesson immediately.
Write current.json. Update updated_at.
Print a one-line update:
GOAL turn {n}: {action} — {outcome}. Subtasks {done}/{total}.
The Stop hook (hooks/goal-auto-continue.sh) handles auto-continuation only
during autonomous execution. The hook is silent during clarifying and
proposed statuses — those phases require user input (CLARIFY questions and
plan confirmation), so the model must wait for the user, not auto-continue.
Once status flips to active (after Phase 3 confirmation), the hook fires on
each Stop event when stops.auto_continue: true and there are unfinished
subtasks. It injects a nudge on stdout with exit code 2:
"Goal active — pick the next concrete action for subtask {sN}: '{text}'. Don't ask, just do."
This makes the model self-pace through the loop without the user having to type "continue" each turn. The user can always interrupt with a regular message — the triage router pauses /goal automatically when intent is clearly off-topic.
When all subtasks are done and all requirements are satisfied:
Verification gate (MANDATORY): Before moving to PR, scan evidence[]. If
any entry of kind git-diff, file, or lint-result has verified: false,
STOP. Re-run verification or pause the goal. Goal completion cannot proceed
with unverified evidence — that's the entire point of the verification
protocol.
If the project has /precheck, run it now. Append the output as evidence.
status: "awaiting_pr", stops.auto_continue: false. Write current.json.gh pr create yourself:GOAL "{objective}" — ready for PR review.
Subtasks: 5/5 done
Requirements: 2/2 satisfied
r1 LCP < 2s on Moto G4 → 1.7s (lighthouse-after.json)
r2 No CLS/TBT regression → CLS 0.02 (was 0.03), TBT 180ms (was 200ms)
Files changed: 4 (+218/-94)
Tests: 47 passed, 0 failed
Agents spawned: 2 | Turns: 7
Suggested PR title: "perf: cut homepage LCP from 3.4s to 1.7s"
Suggested branch: goal/cut-homepage-lcp
Run `/pr` to create the PR (recommended), or tell me to do it.
Goal stays paused at this point — no auto-continue past PR creation.
Wait for the user. Auto-continue is OFF for awaiting_pr status — the human gate is mandatory.
When the user confirms PR was created (or explicitly closes the goal):
Set status: "done". Append final summary to state.
Move current.json → archive/{id}-{slug}.json.
Always append to .claude/knowledge/shared/goals-history.md (create
the file if missing). This is non-optional — institutional memory is the
point. Format:
### {date} — {objective}
- **id**: {goal_id}
- **PR**: {url}
- **status**: done | abandoned (with reason)
- **approach**: {1-2 sentence summary}
- **subtasks completed**: {N}/{total}
- **verification**: {summary — tests run, results}
- **what worked**: {brief}
- **what didn't / footguns**: {brief — link to behavior-corrections.md if added}
- **lessons**: {1-3 bullets future /goal runs should know}
- **files touched**: {top 5 paths}
- **related goals**: {ids of prior goals this built on, if any}
Conditionally write to other knowledge files when something non-routine surfaced:
| Discovery | Append to |
|---|---|
| Reusable pattern | .claude/knowledge/shared/patterns.md |
| Coding rule | .claude/knowledge/shared/conventions.md |
| Domain rule | .claude/knowledge/shared/domain.md |
| Footgun / mistake | .claude/knowledge/shared/behavior-corrections.md |
| New term | .claude/knowledge/shared/vocabulary.md |
| Deploy gotcha | .claude/knowledge/shared/deployment.md |
| Stale KB entry the scout flagged | (correct the affected file in place) |
Skip these for routine goals. Only write when a future agent would benefit.
Knowledge graph write-back (if KG is enabled):
KG_WRITE="${CLAUDE_PLUGIN_ROOT}/skills/knowledge-graph/kg-write.sh" # plugin install: Claude Code substitutes the root at load
[ -f "$KG_WRITE" ] || KG_WRITE=".claude/skills/knowledge-graph/kg-write.sh" # symlink install
if [ -f "$KG_WRITE" ]; then
"$KG_WRITE" decision "{objective} — {one-line outcome}" "goal"
# Per pattern discovered:
"$KG_WRITE" pattern "{terse insight}" "goal"
fi
connections.pr and connections.review_outcome in the archived
state file so future goals can query the relationship.Stay terse in all writes — append, don't rewrite. The goal is durable institutional memory, not narrative documentation.
The loop pauses or stops in these cases:
| Trigger | Status | Auto-continue |
|---|---|---|
| Phase 1 finished, awaiting CLARIFY answers | clarifying | OFF (mandatory user input) |
| Phase 2 finished, awaiting plan confirmation | proposed | OFF (mandatory user input) |
| Verification failed in Phase 4 | stays active but blocked_reason set | OFF until fixed |
| Unverified evidence at Phase 6 entry | stays active with blocked_reason: "unverified" | OFF |
| All subtasks done AND requirements satisfied AND all evidence verified | awaiting_pr | OFF (human gate) |
User says /goal pause | paused | OFF |
User says /goal clear | cleared (archived) | OFF |
| Spawn budget exceeded (>6) | stays active but auto-continue OFF | OFF until user OKs |
| Risk escalation needed (e.g. infra change) | paused with blocked_reason | OFF |
| Same subtask in_progress for 4+ turns | paused with blocked_reason: "stuck" | OFF |
| Escalation trigger fired (see Escalation table) | paused with blocked_reason: "needs-user" | OFF |
| All lanes blocked on running agents | stays active, wait-mode (blocked_reason: "wait-mode"), wakeup scheduled | OFF until an agent returns |
When auto-continue is OFF and the user types again, treat their message as guidance — re-evaluate, possibly amend the plan, then re-enable auto-continue if appropriate.
--merge-on-green pre-authorized the gate).gh pr merge. /goal stops at PR creation.goal/{slug} if user
isn't on a branch yet).gh issue create and note in turns[], do not fix inline.| Phase | Model | Cost |
|---|---|---|
| Scout (Phase 1) | Haiku via explore-light | 1x |
| Inline edits/reads/grep | parent (Opus/Sonnet) | 0x extra |
| Backend/frontend agent spawn (when needed) | Sonnet | 10x per spawn |
| Auto-continue nudge | Stop hook (no model) | 0x |
A typical goal completes in 4-8 turns with 1-2 agent spawns. If it grows beyond that, either the objective is too broad (split it) or it's the wrong fit for /goal (use /planning + /implement instead).
| Dimension | /autopilot | /goal |
|---|---|---|
| Scope | Multi-issue queue, P0–P5 ranked | One freeform objective |
| Risk gating | Mandatory CLASSIFY phase | Implicit (escalate when needed) |
| Pace | Item → PR → wait → next item | Action → action → action → PR |
| Default model | Sonnet (auto-detect) | Inline + Sonnet only when needed |
| Stops at | PR per item, every time | PR for the goal, once |
| Best for | Backlog burndown | Targeted, exploratory objectives |
Both stop at PR creation. Both preserve state. Both can pause/resume. /goal is the "find the path" tool; /autopilot is the "drain the queue" tool.
After 5+ turns, the context is heavy. When the loop pauses (awaiting PR, blocked, or user-initiated), print this block:
─────────────────────────────────────────────
💡 Context tip — /goal accumulates each turn's reads, edits, and tool output.
Paused for PR review?
/compact focus on goal — "{objective}" — {N} turns, {M} agents
Then /clear before next goal. State is in .claude/.goals/current.json.
Resume with: /goal resume
Goal complete?
/clear — state is archived. Start fresh with /goal <new objective>.
─────────────────────────────────────────────
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
2 plugins in one repository ship this exact command · first indexed Dec 1, 2026
53 commands in this plugin
/adapters:READMEDiagram AdaptersThis directory contains push adapters for `/kb-diagram --push <adapter>`./arth-helpAnswer questions about installing, using, trusting and removing Arth, from the docs bundled with the plugin only — cites the page, says when the docs do not cover it, and makes no network call. Usage: /arth-help <question>/arth-setupSet up Arth in one command. Open edition: Arth Intelligence (/otel-setup, local Docker) plus Arth Decisions (off by default); memory and model routing are built in. `/arth-setup local` does the whole local setup with defaults and no questions. Pro edition adds memory (/memory-setup), router (/router-setup) and the Central posture. Also handles `switch <local|cloud|off>` (plus `switch <shadow|enforce> decisions`) and `uninstall`. Usage: /arth-setup, /arth-setup local, /arth-setup switch <local|cloud|off> <product|all>, /arth-setup switch <off|shadow|enforce> decisions, /arth-setup uninstall <product|all> --purge-datanpx claudepluginhub arthtech-ai/sarathi --plugin primeOther plugins' commands for the same job