ClaudeHack
0.000

Set /goal with a testable condition and let Claude decide when it is done

Testing / Debugging·15 hours ago·verified 15 hours ago·easy·~5 min setup·verified

Write the tests first, then set the goal to making them pass. Claude keeps working across turns until the condition is met instead of stopping after each reply.

The problem

Long tasks stall because the agent has no standard for done. It finishes a turn, declares success, and waits — so you spend the session nudging it forward one "keep going" at a time.

The hack

Run `/goal <condition>` with a condition that can actually fail. Claude keeps working across turns until it is met. Pair it with a test suite so the condition is machine-checkable rather than a judgement call.

Why it works

A goal turns your session into a loop with a real exit check. When the main agent decides a task is done, a smaller model verifies the work against the requirements and reprompts it to finish whatever it missed, so "done" is not self-assessed.

Setup

1. Write the failing tests for the feature before asking for any code. 2. Run `/goal every test in tests/checkout.spec.ts passes`. 3. Let it work — it will write code, run tests and iterate without you prompting each round. 4. Run `/goal` with no argument to see the current or most recently achieved goal. 5. Clear it early with `/goal clear` (or `stop`, `off`, `cancel`). 6. Add a line to `CLAUDE.md` telling Claude to commit each working version so you can roll back to the last one that passed.

Prompt

/goal npm test passes with zero failures and npx tsc --noEmit reports no errors

Additional details

The failure mode of an unsupervised goal is a vague condition. "The feature works" leaves the model to grade itself, which it will do generously. "Every test in this file passes" cannot be fudged. Writing the tests first is what makes this work, and it has a second benefit: a goal scoped to a test file will not let Claude quietly break something else to satisfy it, because the rest of the suite still has to stay green. `/goal` is for a condition within one session. For a prompt that should run repeatedly while the session stays open, use `/loop`; for recurring jobs in the cloud, use `/schedule`.

Source

youtube·View original →·by AI LABS

Does this still work?

0 said it works · 0 said it's broken

Related

Discussion

No comments yet. Be the first to say whether this worked for you.