Stop Prompting Endlessly: Give the Agent a Goal
Anyone working with AI coding agents knows the pattern: you prompt – the agent delivers – you follow up – the agent corrects – you prompt again. After ten rounds you have a passable result, but the cost and time have multiplied. The mistake lies not in the model, but in the approach.
The decisive shift: Give the agent a goal, not a step-by-step instruction.
The Problem: Prompt Loops
Imagine telling a person: “Open the file, find line 42, change the value to true, save, and then do the same in the configuration file.” That’s tedious. Now imagine instead saying: “Make sure the authentication is correct. Here are the acceptance criteria.”
The difference is immense:
| Approach | Description | Result |
|---|---|---|
| Instruction prompting | “Do step A, then B, then C” | Micromanagement, many iterations |
| Goal-oriented | “The goal is X. Here is the test that must pass.” | The agent plans autonomously, iterates independently |
Coding agents like Claude Code or Codex CLI are built for the goal-oriented approach. They can independently plan, read files, make changes, and verify the result – if you let them.
Define Acceptance Criteria (Before You Prompt)
Before you send the agent off, write down how you will recognize that the task is done. This is the most important step.
Good acceptance criteria are:
- Measurable: “The test suite runs without errors” instead of “The code works”
- Unambiguous: “The endpoint returns status 200” instead of “The API runs”
- Verifiable: Automatically checkable (tests, linter, TypeScript compiler)
Example for a task:
Goal: Add a /health endpoint to the API.
Acceptance Criteria:
- GET /health returns { "status": "ok" }
- The server starts without errors
- All existing tests still pass
- TypeScript code shows no compile errors
Provide Context – Not the Solution
A common mistake is to give the agent the solution instead of describing the problem. Instead of “Write a function that first checks if the user is logged in, then queries the database and formats the result” – say instead:
“The endpoint
/api/user/{id}should return the public profile data of a user. Invalid IDs should respond with 404; non-public fields (email, hash) are omitted. The existing auth middleware is already insrc/middleware/auth.ts.”
The agent then has:
- A clear goal (deliver public profile data)
- Clear constraints (404 for invalid IDs, filter fields)
- A context hint (existing auth middleware)
The Elegant Prompt: Goal + Acceptance Criteria + Context
A good prompt for a coding agent consists of at most three parts:
## Goal
[One sentence: What should be achieved?]
## Acceptance Criteria
- [Measurable, verifiable, automatically checkable]
- [Further criteria …]
## Context
[Reference to existing infrastructure, relevant files, architectural decisions]
Concrete example:
## Goal
Enable publishing of blog comments after manual approval.
## Acceptance Criteria
- An admin can approve comments in the admin interface
- Only approved comments are displayed on the blog page
- The author receives an email notification upon approval
- SQL migration present (a field `approved_at` in the comments table)
## Context
- Admin backend: `src/admin/`
- Blog frontend: `src/blog/`
- Mail service: `src/lib/mail.ts` (use it, don't rebuild)
- Existing comments API: `src/api/comments.ts`
That’s it. No step-by-step instructions, no micromanagement. The agent has everything it needs.
Let the Agent Plan
A good agent does more than just write code. If you give it a goal, it will:
- Analyze the task – What is the current state, what is the desired state?
- Create a plan – Which files need to be changed, which ones need to be created?
- Execute the plan – With intermediate steps and test runs
- Verify itself – Does it work? Do the tests pass?
- Finish – Or ask questions if there are problems
This is the key: A goal-oriented agent can independently get itself out of a dead end, while an instruction-driven agent waits in a dead end until you tell it the next step.
When Is the Agent Done?
You define that with your acceptance criteria – not the agent. A good prompt contains the answer to “When am I done?” as part of the task.
Keywords for “done”:
- Tests green – All tests (existing + new) pass
- TypeScript/Compiler clean – No errors
- Linter passed – Code formatting and rules followed
- Self-review – The agent compares its result with the acceptance criteria
If you teach the agent that the task is only complete when these checks pass, you save yourself the second, third, and fourth iteration.
How This Looks in Claude Code
Claude Code is particularly well-suited for this approach because it brings three crucial abilities:
- Plan Mode – Claude Code can create a plan before starting and ask you for approval
- Autonomous Work – It independently reads files, runs tests, and iterates
- Tool Use – It can execute bash, tests, linter, and even git commands
A goal-oriented prompt in Claude Code:
/claude-code:plan
## Goal
Extract the hardcoded API endpoints into a configuration file.
## Acceptance Criteria
- All API URLs are in a central `config/api.ts`
- The `fetch` call uses the configured base URL everywhere
- Tests pass (npm test)
- TypeScript: no compile errors
Claude Code then independently analyzes which files are affected and creates a plan for approval.
Common Mistakes – and How to Avoid Them
| Mistake | Problem | Better |
|---|---|---|
| “Do A, then B, then C” | Takes away the agent’s planning ability | “Achieve X. Here are the criteria.” |
| “It should work similar to Y” | Vague, not verifiable | “The interface is identical to src/api/orders.ts” |
| “Make it quick” | No quality criteria | “Tests passed, linter clean, no dead code” |
| No context | The agent guesses the environment | “The DB session is in ctx.db, tokens are in the Authorization header” |
| Too many goals in one prompt | Overload, abort | One goal per prompt, or explicitly prioritize |
Conclusion: Prompt Less, Set Goals More
The shift from “giving instructions” to “setting goals” is the most effective lever for productive work with AI coding agents. It requires some discipline in formulating the acceptance criteria – but the ROI is enormous: fewer iterations, better results, predictable costs.
Good agents don’t need step-by-step instructions. They need a clear goal and the trust to find the way themselves.
🌐 Machine-translated from the German original, editorially reviewed. 🤖 Written with AI assistance.
Sponsored