
Stop Re-Prompting Every Five Minutes: /goal Lets Claude Code Run Until Your Tests Pass
Chris Harper
2 min read
Aug 4, 2026 · 12:07 UTC
/goal turns Claude Code from a turn-by-turn assistant into a persistent agent that loops until a measurable condition — "all tests pass," "no lint errors" — becomes true.
When you're debugging a flaky test suite or migrating a large codebase, the workflow usually looks like: edit, run, see result, prompt Claude again, repeat. /goal collapses that loop into one setup step.
You describe a verifiable finish line, and Claude keeps going — reading files, running tests, editing code, interpreting output — until the condition holds or it needs to ask you something:
/goal All TypeScript compilation errors are resolved and `npm test` exits 0.
- Don't delete tests; fix the source.
- Ask before modifying package.json.
Claude then runs npm run build, reads the errors, fixes them, reruns, and loops. When the condition is true, it stops. No re-prompting.
What works well with /goal:
- Test-pass targets: "jest exits with code 0 and no skipped tests"
- Lint clean: "eslint reports zero warnings across the src/ directory"
- Migration completion: "every
require()in the repo is replaced with ES import syntax" - Deployment health: "the /healthz endpoint returns 200 after
pnpm run build"
Boundaries matter. Add them to the goal string itself, not as a separate message — Claude reads the whole goal each loop iteration. "Don't touch the vendor/ directory" and "ask before deleting any file" are constraints worth encoding directly.
Combine with /fork for parallel experiments. If your goal is ambiguous ("make the auth tests pass"), fork two sessions with different fix strategies and let both run to completion, then compare results.
Sources: Claude Code /goal Command Guide — amitray.com · /goal and /loop for Autonomous Tasks — MindStudio · What's New: Week 20 — Claude Code Docs