Claude Code 2.1.139 adds /goal command: set completion conditions and let agents work across multiple turns until met
Anthropic released Claude Code version 2.1.139 on May 12, 2026, introducing the /goal command that allows setting a completion condition for AI agents to work autonomously across multiple turns—sometimes for days—until the goal is met. Available in interactive mode, -p, and Remote Control, with tracking of elapsed time, turns, and tokens.
Claude CodeAnthropicAI AgentsAutomationLong-running tasks
On May 12, 2026, Anthropic released Claude Code version 2.1.139, introducing the /goal command—a feature that lets you set a completion condition and allows Claude to work autonomously across multiple turns until that goal is met.
Early adopters are calling it "the single most underrated AI feature of 2026" because it enables long-running agent workflows that can work for hours or even days without manual intervention, tracking elapsed time, turns, and tokens as Claude iterates toward completion.
The feature is available in interactive mode, with the -p flag, and in Remote Control, and has been integrated into Codex and Claude Code Mobile.
This article breaks down what /goal does, how it works across different modes, why it matters for agent development, and how to use it effectively.
What the /goal command does
The /goal command allows you to define a completion condition for Claude Code agents. Once you set a goal, Claude:
Works autonomously across multiple turns — no manual intervention required
Tracks progress toward the completion condition
Monitors resource usage — elapsed time, turns, and tokens
Continues iterating until the goal is satisfied or you manually stop it
Example workflow
bash
# Traditional approach (manual iteration)
$ claude "fix the bug in server.ts"
[Claude fixes one issue]
$ claude "now add tests"
[Claude adds tests]
$ claude
[Claude checks CI]
$ claude
> /goal All tests passing CI, no TypeScript errors, server.ts bug fixed
[Claude works across multiple turns autonomously goal is met]
[Tracks: 45 minutes elapsed, 12 turns, 89,000 tokens]
The feature has also been integrated into Codex (OpenAI's agentic harness, ironically) and Claude Code Mobile, suggesting Anthropic is positioning /goal as a platform-wide capability for autonomous agent workflows.
Why developers are calling /goal the "most underrated feature of 2026"
"It's official. Claude Code just released /goal. The single most underrated AI feature of 2026. Now Claude Code, Codex, and Hermes agent has it. It allows your agent to complete long running tasks, sometimes for days."
"Claude Code 2.1.139 added /goal. You set a completion condition and Claude keeps working across turns until it's met. Works in interactive, -p, and Remote Control."
Miles Deutscher (@milesdeutscher) emphasized the time-saving potential:
"/goal is f*cking insane. You can literally get your AI agents to work for HOURS without manual intervention. Already active in Claude Code and Codex - you need to use it now."
What makes /goal different from traditional agent prompting?
Traditional agent workflows require manual iteration:
Give Claude a task
Wait for completion
Check the result
Give next task
Repeat
/goal collapses this into a single invocation:
Define completion condition
Let Claude iterate autonomously
Check in when done (or monitor progress)
This is especially valuable for:
Complex refactoring that touches multiple files
Test-driven development where you want "all tests passing" as the goal
Security remediation where you want "all vulnerabilities patched"
Performance optimization where you want "load time under 2 seconds"
CI/CD workflows where you want "green build with coverage > 80%"
How /goal tracks progress: elapsed time, turns, tokens
One of the most useful aspects of /goal is the built-in tracking of resource usage:
Elapsed time — how long Claude has been working toward the goal
Turns — how many interaction cycles have occurred
Tokens — total token usage across all turns
This helps developers:
Estimate costs for long-running tasks
Set timeouts to prevent runaway agents
Optimize workflows by identifying high-turn or high-token tasks
Debug completion logic by seeing where Claude gets stuck
/goal in Claude Code is not the first attempt at long-running agent workflows, but it is notable for its integration depth and tracking capabilities.
System
Long-running capability
Tracking
Access
Claude Code /goal
✅ Set completion condition, works across turns until met
Elapsed time, turns, tokens
Public (v2.1.139+)
Codex (OpenAI)
✅ Agentic workflows with goal tracking (integrated from Claude Code)
Not publicly documented
Limited (Daybreak partners)
Hermes agent
✅ Remote VPS agents, long-running tasks
Custom logging
Public (self-hosted)
AutoGPT / BabyAGI
⚠️ Task lists, but requires manual orchestration
Minimal
Public
LangGraph / Agent harnesses
✅ Custom loops with state management
Custom (developer-defined)
Public (requires coding)
Key differentiator:/goal is zero-configuration for Claude Code users—no custom orchestration, no state management code, just set a goal and let Claude work.
Practical use cases for /goal
1. Test-driven refactoring
bash
> /goal Refactor auth.ts to use dependency injection, all tests passing, coverage > 90%
Claude will:
Refactor the code
Run tests after each change
Fix failures
Add tests if coverage drops
Iterate until goal is met
2. Security remediation
bash
> /goal All npm audit vulnerabilities patched, no breaking changes, CI green
Claude will:
Run npm audit
Update dependencies
Test for breaking changes
Fix any issues
Verify CI passes
3. Performance optimization
bash
> /goal Lighthouse score > 95, Core Web Vitals all green, no accessibility regressions
Claude will:
Profile the site
Optimize images, lazy-load assets
Run Lighthouse after changes
Iterate until targets met
4. Documentation completeness
bash
> /goal All public APIs documented, examples for each function, no broken links
Claude will:
Scan for undocumented functions
Write docs and examples
Check for broken links
Iterate until complete
How to use /goal effectively
Based on early reports and best practices from agent development:
Good: "All TypeScript errors resolved, tests passing, no ESLint warnings"
Bad: "Make the code better"
✅ Do: Set reasonable scope
Good: "Refactor auth.ts to use dependency injection"
Bad: "Refactor the entire codebase to use functional programming"
✅ Do: Monitor progress for the first few goals
Check elapsed time and token usage to estimate costs
Identify patterns in turn counts for similar tasks
⚠️ Don't: Use /goal for open-ended creative tasks
Not ideal: "Design a new UI for the app"
Better: "Implement the approved UI mockup from design-system.md, matching all spacing and color tokens"
⚠️ Don't: Assume /goal will always succeed
Complex goals may hit edge cases
Set timeouts or turn limits if supported
Have a fallback plan if the goal isn't met
Integration with Codex and Claude Code Mobile
The fact that /goal has been integrated into Codex (OpenAI's agentic harness, part of the Daybreak announcement) and Claude Code Mobile suggests this is becoming a platform-wide pattern for autonomous agents.
This is notable because:
Cross-vendor adoption — OpenAI's Codex integrating a Claude Code feature suggests /goal is becoming a de facto standard for agent completion conditions
Mobile-first agents — /goal on Claude Code Mobile enables truly autonomous mobile workflows (e.g., "keep optimizing this component until frame rate is stable at 60fps")
Remote Control interoperability — /goal in Remote Control means multiple developers can share goal-tracking agents in collaborative environments
Claude Code 2.1.139's /goal command is a step-function improvement in autonomous agent workflows—allowing developers to set a completion condition and let Claude work across multiple turns, tracking elapsed time, turns, and tokens, until the goal is met.
Early adopters are calling it "the most underrated AI feature of 2026" because it eliminates the need for manual iteration in multi-step tasks, enabling agents to work for hours or even days autonomously.
The feature works in interactive mode, -p flag, and Remote Control, and has been integrated into Codex and Claude Code Mobile, suggesting it's becoming a platform-wide capability.
If you're building agent workflows, update to Claude Code 2.1.139 and experiment with /goal for tasks like test-driven refactoring, security remediation, performance optimization, and documentation completeness.