Draft goal condition

From melodic-software/claude-code-plugins · View interactive version

Draft goal condition is an AI agent skill from the GitHub repository melodic-software/claude-code-plugins. 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

How to use this skill

Skill file

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.

<https://code.claude.com/docs/en/goal#compare-ways-to-keep-a-session-running>, for when /goal,

/loop and a Stop hook start the next turn and when each stops.

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.

when the score improves and revert it otherwise, log every round) → no new runner. For runtime

speed or a counter: /performance:goal (if enabled), then /performance:snapshot (if enabled), then

/performance:verify (if enabled). For a prompt or model setting against an eval suite: /evals:methodology (if enabled),

which says when the bundled claude-api skill's hillclimb fits and who starts it.

routines / /schedule. Before recommending them, read their release status on

https://code.claude.com/docs/en/routines during the Step 1 fetch, and name it in the

recommendation, so the user knows whether the surface may still change.

prompt-based Stop hook.

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.

context window, a decomposed backlog) → when work-items is enabled: already-decomposed

backlog / existing tickets →

/work-items:work (if enabled) (or the work-loop); undecomposed plan or intent → /work-items:decompose (if enabled) then

/work-items:work (if enabled). 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:

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.

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.

evaluator returns and when a loop that makes no progress stops.

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

only end state:

may waive;

an artifact or document URL;

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.

  1. Enumerated required contents. Name the parts that must be present, so the evaluator decides

"is it there" rather than "is it good".

  1. 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 region the person copies after typing /goal and a space

themselves, since the copied text holds the condition only. One instruction line, then the

condition alone; no line of the region starts with /goal:

Type `/goal ` (with a trailing space), then paste everything between the dashed lines. Confirm the `◎ /goal active` indicator appears after you send it; if it is missing, redo it:

──────────────────────────────────────────────────────────
<condition>
──────────────────────────────────────────────────────────

In the terminal the rails are literal ─ lines, as shown. On a markdown surface, detected as

session-flow's

Markdown surfaces

section says, the instruction line ends `then paste this.` before its confirm sentence and the

condition sits in a fenced text block. Both shapes match the goal region

/session-flow:handoff (if enabled) writes, so a goal drafted here pastes the same way after a handoff.

When the ProposeGoal tool resolves in this session, also propose the condition through it under

the conditions the Routing paragraph below lists. The tool has its own, lower cap: read it from

reference/native-goal.md at run time, re-run the Step 3 counter with

--limit <that cap> first, and propose only a condition that passes it and contains no tab

character (why: reference/native-goal.md). 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

the forms the pointer below names. It is reserved for the person to run; the model does not

invoke it.

<https://code.claude.com/docs/en/goal#check-status> and

<https://code.claude.com/docs/en/goal#clear-a-goal> for the other two forms.

approve. Its ask_user default, what it cannot do, and the contexts that refuse it are

recorded in reference/native-goal.md. Our gate: this skill proposes

only with ask_user true, under the conditions in Routing below.

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 (if enabled) 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

Related

Gotchas

gotcha below). The counter counts Unicode code points; do not substitute a token estimate.

live each run.

over-limit condition. The limit is in

Write an effective condition.

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>.

Set a goal for how goal turns get permission.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.