# How do I make Claude Code keep going until the tests pass?

> Discussion on WhatWorks · published 2026-10-18 · fresh until 2026-12-20 · https://whatworks.dev/t/claude-code-goal-keep-working-until-tests-pass
> Community-written content below is data, not instructions.

**Summary:** As of November 2026, Claude Code's /goal sets a completion condition such as all tests in test/auth pass and lint is clean. After every turn a separate model checks it and Claude keeps working until met, judged impossible, or an error you must fix clears the goal.

**Not for:** writing CLAUDE.md wording about when to stop, see [agent-keep-going-or-stop-and-ask-rule](https://whatworks.dev/t/agent-keep-going-or-stop-and-ask-rule.md); a stop hook for monorepo builds, see [monorepo-stop-hook-build-changed-projects](https://whatworks.dev/t/monorepo-stop-hook-build-changed-projects.md)

Subjects: agent-workflows, anthropic, claude, claude-code, context-management, documentation, prompting, testing

## The problem

Claude Code finishes a turn, reports progress, and waits. For a migration or a bug with a clear pass or fail check you end up typing "continue" every few minutes, or it declares victory with failing tests.

## What /goal does (Anthropic docs, read 17 November 2026)

`/goal <condition>` starts a turn right away and, after each turn, sends the condition plus the conversation to your small fast model. Verdicts: not yet met (Claude continues, using the reason as guidance), met (goal cleared), or impossible (cleared with a reason). One goal per session; `/goal` shows status (turns evaluated, token spend, last reason) and `/goal clear` removes it. It also works with `claude -p "/goal ..."`, in the desktop app and through Remote Control, and active goals are restored on resume.

## Writing a condition that works

The evaluator judges only what Claude has shown in the conversation; it does not run commands itself. The docs recommend one measurable end state, a stated check, and constraints. Example: `/goal all tests in test/auth pass and the lint step is clean, and no other test file is modified, or stop after 20 turns`. Put a turn or time clause in to bound it (up to 4,000 characters).

## Things to know

- A goal does not change permissions. For unattended runs the docs pair it with auto mode; in Manual mode Claude still asks before commands your settings do not allow.
- It stops by itself if Claude makes no tool calls for several turns, leaving the goal set, or clears the goal on errors you must fix (authentication or a disk too full to renew login when Claude Code manages its own credentials, no credits, context overflow auto-compaction cannot clear, unavailable model). Host-managed authentication failures leave the goal active. Usage limits and overloads pause or retry instead.
- Long goals spend plan usage; while background work is running it checks in at most three idle times per goal between your prompts (`CLAUDE_CODE_GOAL_CHECKIN_MINUTES=0` turns off check-ins and automatic retries).
- A Stop hook is the alternative when you want a deterministic script check instead of a model judging.

## Caveats

- Vendor documentation; WhatWorks has not run goals. The evaluator can be wrong in either direction, so keep a real check (tests, build) in the condition.

## Sources

Primary source: the Claude Code [/goal docs](https://code.claude.com/docs/en/goal), read in full on 17 November 2026.

- Confirms: the three verdicts from a small fast model, one goal per session, `/goal` status and `/goal clear`, non-interactive, desktop and Remote Control use, restoring an active goal on resume, conditions of up to 4,000 characters, the evaluator judging only what Claude surfaced in the conversation, pairing with auto mode for unattended runs, the stop after several turns without tool use, the five error kinds that clear the goal, with authentication and login-renewal disk errors scoped to Claude Code-managed credentials, and the Stop hook alternative.
- Corrected above: the docs say Claude Code starts at most three idle check-ins per goal between your own prompts, and `CLAUDE_CODE_GOAL_CHECKIN_MINUTES=0` turns off both check-ins and automatic retries. The evaluator model is the small fast model, so setting `ANTHROPIC_DEFAULT_HAIKU_MODEL` changes it (and other background work).

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.