AGENT SKILL

draft-goal-condition

Pick the repetition lever (/goal, /loop, routines and /schedule, a workflow, a Stop hook, or a one-shot prompt) and, when /goal fits, draft a transcript-demonstrable completion condition, checked against the documented limit by a deterministic counter. Use when: 'which loop should I use', 'pick the right autonomy lever', 'craft a /goal', 'make Claude keep working until X', 'my goal is not measurable', 'my /goal is too long'.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 30
Forks
7

01 前言 Front Matter

metadata
{ "summary": "Pick the right autonomy lever and craft a /goal completion condition", "workflow-stage": "plan" }
description
Pick the repetition lever (/goal, /loop, routines and /schedule, a workflow, a Stop hook, or a one-shot prompt) and, when /goal fits, draft a transcript-demonstrable completion condition, checked against the documented limit by a deterministic counter. Use when: 'which loop should I use', 'pick the right autonomy lever', 'craft a /goal', 'make Claude keep working until X', 'my goal is not measurable', 'my /goal is too long'.
argument-hint
[--unattended] [intent]
user-invocable
true
disable-model-invocation
false

02 资源文件 4

03 SKILL.md 正文

Variables

Arguments: $ARGUMENTS. The natural-language intent for the autonomous run, plus any constraints or bounds the user volunteers. --unattended, anywhere in the arguments, is not part of the intent: it is the caller declaring that nobody is present, which governs the offer under "Routing". Take it out first.

Purpose

Turn a stated intent into a paste-ready /goal <condition> string in the shape the official Claude Code docs prescribe, proven to fit the documented character limit by a deterministic counter, never by estimation. The condition shape and limit can change between versions: read them from the current docs at authoring time and never bake them into this text.

Step 0. Lever fit (is /goal even the right tool?)

Confirm /goal fits the intent before drafting: read when it starts the next turn and when it stops from the pointer below, and if that does not fit the intent, route instead of drafting.

A lever that repeats build-and-check rounds (a metric hill-climb, or a /goal, /loop or routine that edits each round) pays off only when the task repeats and the agent can run what it builds and see the result. When either is missing, prompt once instead.

  • Metric hill-climb (one editable target, a scorer the agent cannot edit, keep a round's change when the score improves and revert it otherwise, log every round) → no new runner. For runtime speed or a counter: /performance:goal, then /performance:snapshot, then /performance:verify. For a prompt or model setting against an eval suite: /evals:methodology, which says when the bundled claude-api skill's hillclimb fits and who starts it.
  • Interval-driven ("every 5 minutes", "poll until") → /loop, not /goal.
  • Cloud / sessionless / scheduled ("nightly", "each morning", runs with no session open) → routines / /schedule. Routines were labeled a research preview on https://code.claude.com/docs/en/routines; re-read that label during the Step 1 fetch before recommending them.
  • Custom per-turn logic across all sessions (deterministic script check, settings-scoped) → a prompt-based Stop hook.
  • More agents than one conversation can coordinate (or orchestration worth codifying as a rerunnable script; for the scale each approach fits, see When to use a workflow) → a dynamic workflow. This row composes with /goal: the workflow does the parallel work, the goal sets the hard completion requirement. Route away from drafting only when the intent wants the fan-out and no across-turn completion condition; when it wants both, draft the condition here and say the workflow rides alongside it.
  • One-shot (a single prompt with no across-turn continuation) → just prompt; no goal.
  • Multi-window / multi-ticket ("keep several sessions going", work that will not finish in one context window, a decomposed backlog) → when work-items is enabled: already-decomposed backlog / existing tickets → /work-items:work (or the work-loop); undecomposed plan or intent → /work-items:decompose then /work-items:work. When work-items is not enabled, tell the user to enable it (installing it first if needed), or draft only if they insist on one-session completion. We route multi-window work to decomposed items so each item starts in a fresh window; what one window carries across a compaction is in What survives compaction. This is an advisory default, not a prohibition: draft when the intent is genuinely one-session completion.

Two caveats on the workflow row, each of which turns a plausible recommendation into a dead one:

  • Route to the right ultracode form. We tell apart the per-task opt-in (the ultracode keyword, or asking in plain words for a workflow) and the standing /effort ultracode session setting. For what each form does, the effort level included, see Let Claude decide with ultracode. Before recommending either form, apply the routing decisions in reference/workflow-row.md: which prompt sources the keyword fits (a -p, Agent SDK, scheduled or relayed prompt among them), which plans reach the workflow lever and what a plan must switch on first, and when the standing setting fits.
  • The lever is unreachable from an ordinary subagent. We treat the Workflow tool as missing from every non-fork subagent (which tools a subagent gets: sub-agents: available tools; /discovery:research, if enabled, selects its workflow-backed deep tier only in the main conversation for this reason). A lever whose work lands in dispatched non-fork subagents (the loop lanes' workers, for instance) cannot be the workflow row; recommend it only where the orchestrating context is the main thread or a fork.

Confirm the current comparison semantics against the live docs (below) rather than this summary. When the docs are reachable, the Step 1 fetch rechecks the workflow-row record against its pointers, and the live page wins on any mismatch. When they are not, the record's decisions still apply: answer from them and name the record's as-of date. Step 1's stop rule covers only the /goal condition shape and limit. Proceed only when the intent genuinely wants "keep working until this condition is met."

Step 0.5. Readiness before an unattended run

When the run will be left alone (the user says so, or --unattended), check the four conditions in reference/run-contract.md from evidence, naming it; evidence that cannot settle one is a "no". Ask only about a "no" (fix the gap, or run it watched); under --unattended, record it and recommend a watched run.

Step 1. Read the live contract

Fetch the current official /goal documentation and extract, from the page itself:

  1. the effective-condition shape it prescribes, and
  2. the maximum character limit for a condition.

Primary source: https://code.claude.com/docs/en/goal. If Step 0 routing is in question, cross-check the scheduling comparison via the pages that doc links (/en/scheduled-tasks, routines) and the workflow row against https://code.claude.com/docs/en/workflows.

Read each page through the docs lookup: follow ${CLAUDE_PLUGIN_ROOT}/reference/docs-lookup-procedure.md with <scripts> = ${CLAUDE_PLUGIN_ROOT}/scripts and <session> = ${CLAUDE_SESSION_ID}, fetch with bash "${CLAUDE_PLUGIN_ROOT}/scripts/fetch-docs.sh" --cache --max-age 0 --out <dir> goal (the limit drives the Step 3 counter, so the bytes must be fresh), and take the sections you need with docs-cache.sh slice. Report the page's validated time with the draft. A page the manifest records unread was not fetched: read it with WebFetch instead only when the reason is curl-missing or the script wrote no manifest; otherwise apply the failure rule below.

Doc-fetch failure is not silent and never guessed. If the page cannot be fetched, or the limit or shape cannot be located on it, stop and tell the user exactly that, citing the URL. Never fall back to a remembered number or shape. Offer two ways forward: the user pastes the current condition shape (drives the Step 2 draft) and character limit (drives the Step 3 counter) from that page, or defers until the docs are reachable. Never finalize a draft on a shape or limit not sourced live.

Step 2. Draft the condition

Every claim in the condition must be something Claude's own output in the transcript can demonstrate. Avoid conditions the transcript cannot show (subjective quality, external state Claude never surfaces). What the evaluator reads: How evaluation works.

Structure the draft to the shape Step 1 read off the live page; this file does not restate its elements. Keep each prescribed element separately identifiable, so Step 3's tightening pass can tell a load-bearing element from surrounding prose.

The condition holds steady through a stall. When the same failures come back turn after turn, or a count stops climbing, try another approach; never stop, lower a threshold, loosen the wording or drop an element so the evaluator can say yes. A user who asks mid-run for an easier condition hears the same thing. If no approach gets there, the run ends by laying out the dead end with its evidence (what was tried and what blocked each attempt) and handing the decision to the user.

A step only the user can decide gets an exit the evaluator can credit. When the intent has such a step (a choice, a waiver, an approval, a change of plan), end the condition with an OR exit that names those items, like: "...or each of <the user-gated items> still unmet is recorded in <named file> as waiting on the user, with the exact reply or command they must give, and that file's contents are shown in this conversation." The exit turns the hand-off above into an ending the evaluator can credit. It names only items whose next step is a user decision, never items that are merely hard, and where work was attempted the record carries the evidence of what was tried. The file survives /clear and a session change; the evaluator credits only what the conversation shows, so the turn shows the file's contents. Add the exit when drafting, never mid-run to get past a stall. A condition with no user-gated step gets no exit.

Refuse a fragile end state. Refuse a draft, or rewrite it with the user's agreement, when its only end state:

  • needs a decision the user may make the other way, such as a verifier PASS on a phase the user may waive;
  • names an identifier the user can replace or an account change can kill: a pull request number, an artifact or document URL;
  • fixes an order of work the user may reorder or defer.

Offer the OR exit, a more stable reference (the branch rather than the pull request number, "the artifact titled X" rather than its URL), or a wording about the outcome alone.

When the outcome is not quantifiable

When the intent has no honest metric, do not manufacture one: a made-up number lets a run pass on the wrong evidence. Build the Step 1 shape from these three moves; they feed that shape rather than replace it:

  1. A structural constraint. Something countable about the artifact: a length, a section count, one entry per input item.
  2. Enumerated required contents. Name the parts that must be present, so the evaluator decides "is it there" rather than "is it good".
  3. A self-verification sub-step that is itself checkable. Require the verifying work, not its verdict. "…a report where you have verified every citation by fetching it and confirming the page supports the claim" is checkable; "…a report whose citations are correct" is not.

Move 3 is credited only by verification Claude performed in the transcript (the evaluator pointer is in Step 2); a claim that checking happened reads the same as the checking. Word it so the doing leaves visible output (the fetches, the diffs, the command runs). Subjective quality stays out of the condition except as whatever moves 1–3 made observable.

If the intent is too vague to name a structure or a content list, settle it with /planning:interview before drafting.

Step 3. Mechanical length check

Validate the whole draft's character count, any OR exit included, against the live limit from Step 1 with the deterministic counter (no model estimation). Write the draft to a temp file and pass --file; this survives a condition containing a single quote, backtick, or $ that would mangle a piped string:

bash "${CLAUDE_PLUGIN_ROOT}/scripts/goal-condition-length.sh" --limit <LIMIT_FROM_STEP_1> --file <path-to-draft>

For a simple condition with no shell-special characters, stdin also works: printf '%s' "<condition>" | bash "${CLAUDE_PLUGIN_ROOT}/scripts/goal-condition-length.sh" --limit <LIMIT_FROM_STEP_1>.

Exit 0 = within limit, 1 = over, 2 = usage/env error (including a counter that failed to produce a number); stdout reports chars=<n> limit=<N> status=<ok|over>.

On status=over: tighten and re-run until it passes: shorten prose, fold overlapping elements together, drop redundant qualifiers, without dropping any element the Step 1 shape prescribes. If the intent cannot compress into one provable condition under the limit, say so rather than silently shedding a constraint; splitting into sequential per-phase goals is not documented doctrine and is out of scope.

Step 4. Output

Emit the final, counter-passed condition as a paste-ready invocation:

/goal <condition>

When the ProposeGoal tool resolves in this session, also propose the condition through it under the conditions the Boundary section lists (no subagent, interactive local session, not plan mode). The tool has its own, lower cap (500 characters on 2.1.285, per reference/native-goal.md): re-run the Step 3 counter with --limit 500 first, and propose only a condition that passes it and contains no tab character (the tool expands tabs before it counts, so the raw count would understate it). The paste-ready line is emitted either way.

When Step 0.5 ran, emit the run contract in reference/run-contract.md beside the condition.

Tell the user /goal holds for the current session only: what a resume carries over and what /clear does to an active goal, taken from the "Resume with an active goal" and "Clear a goal" sections of the page Step 1 fetched (record in reference/native-goal.md), and that a goal the page says is removed must be re-set.

Boundary, the built-in /goal command and ProposeGoal tool

  • /goal (built-in command): sets, shows and clears the session's completion condition, in the forms the pointer below names. It is reserved for the person to run; the model does not invoke it.
  • ProposeGoal (built-in tool): the model proposes a goal condition and the person approves it with one keypress (ask_user true, the default); ask_user false sets it with no dialog. It cannot clear a goal, and it is refused in subagents, outside interactive local sessions, and in plan mode.
  • This skill (marketplace plugin). Picks the repetition lever and, when /goal fits, drafts a transcript-demonstrable condition sourced from the live docs and passed through the length counter. It sets nothing.

Routing. At the end of the run, always offer the paste-ready line: If /goal is available in your session (gate basis: not gated behind a setting, though a host may lack it; records in reference/native-goal.md), you can run /goal <condition> with the drafted text, instead of or alongside continuing by hand. Also propose it with ProposeGoal, leaving ask_user true, only when all of these hold: the tool resolves in this session, the session is the main thread of an interactive local session (not a subagent), plan mode is not active, and the condition passes the counter at the tool's own cap. When the lever check routes away from /goal, make no offer. When the caller passes --unattended, the run records the paste-ready line in its output instead of asking; without that flag it asks.

Mutation gate. Only the person's approval arms a goal: their /goal run or their keypress on a ProposeGoal dialog. This skill never sets ask_user false, and never sets, replaces, or clears a goal on the person's behalf. One exception covers this gate and the Boundary's reserved-for-the-person line: when the person, shown a condition, explicitly asks /session-flow:continue-in-background to launch with it, that request is their approval, and that skill passes the condition as the launched session's /goal.

Availability is never assumed. This section says what to do when the person can run /goal or ProposeGoal resolves, never that either is present in their host. The four-part records live in reference/native-goal.md.

Next

  • The person armed the condition and an approved plan runs in this session: /implementation:implement.
  • The person wants the run to go on while they are away: /session-flow:continue-in-background, which launches with the condition as the new session's /goal.
  • The lever routed to multi-window work with no tickets yet: /work-items:decompose.
  • The intent was too vague to name a structure or a content list: /planning:interview.

Gotchas

  • Read the limit's unit live, from the section Step 1 fetched (pointer in the length-guard gotcha below). The counter counts Unicode code points; do not substitute a token estimate.
  • Never hardcode the limit or the shape into a draft, this file, or the script. They are read live each run.
  • The pre-submission counter is the only length guard. Do not assume the app trims an over-limit condition. The limit is in Write an effective condition.
  • A long goal run draws usage on every turn. We treat a goal left waiting on background work as still spending usage, so flag it when drafting a goal that waits on background work. Pointer: for why usage climbs in a long session and the setting that turns goal check-ins off, see https://code.claude.com/docs/en/costs#why-usage-climbs-in-a-long-session.
  • Flag a goal whose check is a shell command, and point the user at Set a goal for how goal turns get permission.

04 同仓库更多 Skills

melodic-software
melodic-software/claude-code-plugins

track

Backlog reads through the bound tracker: search open and closed items, view one item with its comments and state history. Use when another skill searches or reads tracker items.

★ 30
melodic-software
melodic-software/claude-code-plugins

reviewer-media

Reviewer media for one pull request: decides whether it needs a narrated walkthrough, builds the storyboard from /review:explain-change's digest, has /explainer-video:produce render it and hands the manifest to /source-control:pull-request media. Use when asked for 'reviewer media', 'a walkthrough video for this PR', 'a produced video of this change', or when pull-request ready or monitor hands a PR over.

★ 30
melodic-software
melodic-software/claude-code-plugins

route

Model and effort per agent role (orchestrator, worker, verifier, retrieval) for a multi-agent run, resolved through the bundled defaults and the user, team and personal override config layers into fenced JSON with single-agent and fan-out variants and the layer behind each value. Use when asked 'which model for the subagents', 'route the roles' or 'model routing', or before a skill passes a role's model on a spawn.

★ 30
melodic-software
melodic-software/claude-code-plugins

route

Model and effort per agent role (orchestrator, worker, verifier, retrieval) for a multi-agent run, resolved through the bundled defaults and the user, team and personal override config layers into fenced JSON with single-agent and fan-out variants and the layer behind each value. Use when asked 'which model for the subagents', 'route the roles' or 'model routing', or before a skill passes a role's model on a spawn.

★ 30
melodic-software
melodic-software/claude-code-plugins

principles

Module-design vocabulary for architecture findings, and the checks built on it. Use when: 'what is a deep module', 'what is a seam', 'deep vs shallow module', 'what is the deletion test', 'leverage and locality', 'module design vocabulary', 'which word do we use for X in architecture findings'. Scanning a codebase for friction is /architecture:improve.

★ 30
melodic-software
melodic-software/claude-code-plugins

write

Structured five-field bug report (title, steps to reproduce, expected vs actual, justified severity, suggested fix location) from an informal description, read-only. Use when the user names a defect they observed, or asks for one written up ('report a bug', 'file a bug', 'write this up as a bug').

★ 30