A good agent prompt is not a longer monologue. It is a compact contract: what to achieve, what must not happen, which tools are in bounds, and how both of you will know the work is done. If the agent can succeed while violating your intent, the prompt—not the model—is incomplete.
01
What “good” means
Judge a prompt by outcomes you can inspect:
- Goal clarity: a stranger could restate the done state in one sentence.
- Bounded authority: files, commands, networks, and data the agent may touch are explicit.
- Observable checks: tests, screenshots, or commands that prove completion.
- Recovery path: what to do on ambiguity or failure instead of inventing requirements.
02
A durable prompt shape
Use the same skeleton every time so both you and the agent learn the pattern:
- Role & scope — who the agent is for this task, and what is out of scope.
- Objective — the user-visible result, not a stack of implementation guesses.
- Constraints — style rules, forbidden changes, latency/cost limits.
- Context pointers — paths, tickets, APIs; prefer links over pasted walls of text.
- Tool policy — when to read, edit, run, or ask.
- Acceptance — commands or criteria that must pass before claiming done.
You are a coding agent working in this repository only.
Objective:
- Add a /healthz endpoint that returns {"ok": true} with HTTP 200.
Constraints:
- Do not change authentication or public URL routes other than /healthz.
- Match existing 4-space indent and test style.
- Ask if the framework choice is ambiguous; do not invent a second router.
Context:
- Entry: src/index.tsx
- Existing tests: src/**/*.test.ts
Tool policy:
- Read before edit. Run the focused test after the change.
- No network installs unless I approve.
Acceptance:
- pnpm test -- healthz passes
- Manual curl to /healthz returns {"ok": true}03
Worked example: weak vs strong
| Weak prompt | Stronger rewrite |
|---|---|
| “Improve the homepage SEO.” | “Update title and meta description on / only; keep copy; add links to three new guides listed in the issue; do not change DNS or deploy config.” |
| “Fix the bug.” | “Reproduce failing test X; fix root cause in module Y; add a regression test; do not silence the assertion.” |
| “Use best practices.” | “Follow repo README conventions; 4-space indent; register new routes in pages[]; run pnpm run build.” |
Strong prompts name artifacts and non-goals. Weak prompts invite creative reinterpretation.
04
Prompts that work with tools
When the agent can call MCP tools or shell commands, state the policy in the same prompt—not only in a separate config file the model never sees:
- Prefer read-only discovery before mutating tools.
- Require confirmation for destructive or expensive calls.
- Tell the agent which tool output fields matter; ignore the rest.
- For custom servers, see the MCP server tutorial.
05
Failure modes to design against
- Goal substitution: agent ships a different feature that “also helps.” Name non-goals.
- Silent scope creep: refactors adjacent files “while here.” Forbid unless asked.
- Fake completion: claims done without running acceptance checks.
- Hidden assumptions: invents product rules when the ticket is ambiguous.
- Prompt bloat: pasting entire codebases instead of paths and queries.
06
Practice loop
- Write the acceptance checks first—even if they are manual.
- Run the agent once; note every place it guessed.
- Turn each guess into a constraint or a clarifying question rule.
- Keep a short library of prompts that repeatedly work in your repo.
Related reading: Cursor agent tips · Cursor rules examples · AGENTS.md vs CLAUDE.md vs Cursor rules · Cursor skills examples · How to write CLAUDE.md · MCP server tutorial · MCP server best practices · Git worktree for coding agents · Agent engineering notes
07
FAQ
What makes a good agent prompt?
A good agent prompt is a short contract: a clear done state, hard boundaries, tool policy, and acceptance checks. If the agent can “succeed” while violating your intent, the prompt is incomplete.
How long should an agent prompt be?
Prefer the shortest text that removes ambiguity. Paste paths and failing signals, not entire codebases. Long monologues usually hide missing constraints rather than add clarity.
Should tool rules live in the prompt?
Yes—when the agent can call MCP tools or shell commands, state read vs write, confirmation rules, and which output fields matter in the same brief. Config the model never sees will not steer the session. See the MCP server tutorial for server-side schemas and host wiring.
How does this relate to a coding agent workflow?
Prompts steer one session; durable repo contracts belong in cursor rules examples or CLAUDE.md; a coding agent workflow covers review, eval, and rollback across tickets. Use both—do not stuff an entire delivery process into a single system message.