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
# Traditional approach (manual iteration)
$ claude "fix the bug in server.ts"
[Claude fixes one issue]
$ claude "now add tests"
[Claude adds tests]
$ claude "now verify it passes CI"
[Claude checks CI]
# Manual intervention at each step
# With /goal (autonomous completion)
$ claude
> /goal All tests passing in CI, no TypeScript errors, server.ts bug fixed
[Claude works across multiple turns autonomously until goal is met]
[Tracks: 45 minutes elapsed, 12 turns, 89,000 tokens]
Where /goal is available
According to the release notes and early reports, /goal works in three modes:
| Mode | Description | Use case |
|---|---|---|
| Interactive mode | Use /goal in the Claude Code CLI | Development and debugging sessions where you want Claude to work autonomously while you monitor progress |
-p flag (programmatic) | Set goal with -p flag in command-line invocations | Scripted workflows, CI/CD pipelines, scheduled tasks |
| Remote Control | Use /goal in remote sessions | Collaborative work, cloud-based agents, distributed workflows |
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"
Alex Finn (@AlexFinn) posted:
"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."
Daniel San (@dani_avila7) noted:
"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
Example tracking output (hypothetical)
> /goal All TypeScript errors resolved, tests passing, PR ready
[Turn 1] Reading codebase, identifying TypeScript errors... (3,200 tokens)
[Turn 2] Fixing type errors in auth.ts... (4,100 tokens)
[Turn 3] Running tests, 2 failures detected... (2,800 tokens)
[Turn 4] Fixing failing tests... (3,900 tokens)
[Turn 5] All tests passing, preparing PR... (2,100 tokens)
Goal met! Elapsed: 18 minutes | Turns: 5 | Tokens: 16,100
Comparison with other long-running agent systems
/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
> /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
> /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
> /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
> /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:
✅ Do: Define clear, measurable completion conditions
- 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
/goalis becoming a de facto standard for agent completion conditions - Mobile-first agents —
/goalon Claude Code Mobile enables truly autonomous mobile workflows (e.g., "keep optimizing this component until frame rate is stable at 60fps") - Remote Control interoperability —
/goalin Remote Control means multiple developers can share goal-tracking agents in collaborative environments
Related on ExplainX
- Hermes agent: remote VPS, Telegram, CLI guide — another long-running agent system
- Claude Code vs Codex rate limit boost — comparing Anthropic and OpenAI agent platforms
- Agent harness engineering: Terminal Bench, LangChain — how to build custom agent orchestration
- Skills lock JSON: reproducible agent skills — ensuring agent workflows are deterministic
Bottom line
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.
Claude Code release notes: https://github.com/anthropics/claude-code/releases. Early reports via X: @AlexFinn, @dani_avila7, @milesdeutscher. ExplainX is not affiliated with Anthropic.