Claude Code’s new /goal command lets you set a completion condition and walk away — Claude keeps working across turns until it’s done. This tutorial walks through a real test-repair workflow step by step.

Prerequisites

Claude Code installed and authenticated. A codebase with at least one failing test to practice on.

Step 1: Identify Failing Tests

Start by listing your failing tests so you know what to target:

cd my-project
npm test 2>&1 | grep FAIL

Make a note of the failing test files. For this tutorial we’ll assume tests/auth.test.js has two failures.

Step 2: Set a Goal

Run Claude Code and use /goal with your condition:

claude
/goal Fix all failing tests in tests/auth.test.js
How it works

After every turn, Claude runs a fast model check against your condition. If tests still fail, it starts another turn — without you typing anything. If they pass, it stops and reports done.

Step 3: Review the Changes

Once the goal completes, review what changed:

git diff
Pro tip

Always run the goal on a clean git branch. If the changes aren’t what you wanted, you can discard them without affecting your working tree.

Step 4: Running Multiple Goals

You can dispatch several goals at once using the new Agent View:

claude agents

This opens a dashboard where each goal runs in its own session row — repair auth tests in one, format docs in another, and audit dependencies in a third.

When to Use /goal

  • Test repair — fix regressions after a dependency bump
  • Refactoring — rename a module and update all imports
  • Documentation — generate JSDoc across a package
  • Lint fixes — auto-fix all style warnings
Watch out

/goal is powerful but not magic. Complex goals with ambiguous conditions may loop or produce unexpected changes. Always review the diff before committing.

Summary

The /goal command turns Claude Code from a pair-programmer into an autonomous task worker. When combined with Agent View, it enables a multi-agent workflow where you set objectives and only intervene when the agent needs human judgment.