Packs

How to give an AI coding agent a clear task: scope, context and done-checks

Guide · checked against the docs on

An agent can only build what you describe. Anthropic's Claude Code docs say: "The more precise your instructions, the fewer corrections you'll need." (checked Oct 2026)

This guide shows how to write one clear task: what to change, which files matter, what rules to follow, and how you'll know it's done. It's quoted from Anthropic, OpenAI, Cursor, GitHub and VS Code docs, checked Oct 2026.

Not affiliated with or endorsed by Anthropic, OpenAI, Anysphere, GitHub or Microsoft. Check their current docs before relying on these details.

For plan-mode keys, committing first and undo, see prompts that stop AI breaking your code. This guide doesn't repeat them.

Step 1: Use four parts

OpenAI's Codex docs split a task into four parts:

OpenAI says this "helps Codex stay scoped, make fewer assumptions, and produce work that's easier to review." (checked Oct 2026) Our advice, not a vendor quote: the same four parts work in any agent.

GitHub suggests a similar order for Copilot: "first give Copilot a broad description of the goal or scenario. Then list any specific requirements." (checked Oct 2026)

Step 2: Keep the scope small

VS Code's docs say: "Choose a small task and define an observable result." (checked Oct 2026) For bigger work, "decompose it into smaller, well-scoped steps." (checked Oct 2026)

GitHub's Copilot docs agree: "If you want Copilot to complete a complex or large task, break the task into multiple simple, small tasks." (checked Oct 2026)

Step 3: Point at the files

Our advice, not a vendor quote: don't make the agent guess where code lives. Anthropic says to "Reference files with @ instead of describing where code lives." (checked Oct 2026) Each tool has its own way:

VS Code also says to "Provide the relevant files, errors, constraints, and existing test commands." (checked Oct 2026)

Our advice, not a vendor quote: rules you give on every task, like your test command or code style, belong in a project file instead. See AGENTS.md and CLAUDE.md.

Step 4: Be specific, and show examples

Our advice, not a vendor quote: vague words make the agent guess. GitHub's example: "don't ask 'what does this do' if 'this' could be the current file, the last Copilot response, or a specific code block." (checked Oct 2026) Ask "What does the createUser function do?" (checked Oct 2026) instead.

Anthropic's docs give a before and after. Before: "add tests for foo.py" (checked Oct 2026). After: "write a test for foo.py covering the edge case where the user is logged out." (checked Oct 2026)

Examples help too. GitHub says "You can provide example input data, example outputs, and example implementations" (checked Oct 2026), and "Unit tests can also serve as examples." (checked Oct 2026) VS Code suggests you "Describe expected behavior or include example input and output" (checked Oct 2026), such as validateEmail("user@example.com") returns true.

Step 5: Say how it will prove it's done

Our advice, not a vendor quote: this is the "done when" part, and it matters most. Anthropic says to "Give Claude a check it can run: tests, a build, a screenshot to compare." (checked Oct 2026) Without one, "'looks done' is the only signal available, and you become the verification loop" (checked Oct 2026).

Our advice, not a vendor quote: ask for proof, not just "done". Anthropic suggests you "Have Claude show evidence rather than asserting success: the test output, the command it ran and what it returned, or a screenshot of the result." (checked Oct 2026)

OpenAI says Codex can test and check its work, "but only if it knows what 'good' looks like." (checked Oct 2026) VS Code says to "Provide test cases, expected results, or acceptance criteria so the AI can verify its own work." (checked Oct 2026) Cursor's agent can also "Control a browser to take screenshots, test applications, and verify visual changes." (checked Oct 2026)

Our advice, not a vendor quote: for anything that touches users or data, add error handling and logging to your "done when" list, without secrets in the logs. OWASP's Logging cheat sheet lists things not to log, including "Access tokens" (checked Oct 2026), "Authentication passwords" (checked Oct 2026) and "Database connection strings" (checked Oct 2026).

Step 6: Plan first, or skip it

Our advice, not a vendor quote: for big or unclear work, plan first. OpenAI says: "If the task is complex, ambiguous, or hard to describe well, ask Codex to plan before it starts coding." (checked Oct 2026) Cursor says "For larger changes, spend extra time creating a precise, well-scoped plan." (checked Oct 2026) Anthropic suggests that "for larger features have Claude interview you and write a spec before you start implementing." (checked Oct 2026)

Our advice, not a vendor quote: for small work, skip it. Anthropic's rule: "If you could describe the diff in one sentence, skip the plan." (checked Oct 2026)

Step 7: Fix it early

Anthropic says to "Correct Claude as soon as you notice it going off track." (checked Oct 2026) VS Code says to "Refine responses by adding constraints or corrections in follow-up messages rather than rewriting the entire prompt." (checked Oct 2026)

If a planned task goes wrong, Cursor suggests a reset instead: "Revert the changes, refine the plan to be more specific about what you need, and run it again." (checked Oct 2026)

An example task

Here's a task written with the four parts (we haven't tried it ourselves):

Goal: add empty-state text to the results view.
Context: @src/ResultsView.tsx and its tests.
Constraints: change only that view and its tests; follow existing patterns.
Done when: the existing tests pass and you show me the test output.

After the agent finishes

Our advice, not a vendor quote: a clear task doesn't replace checking the work. VS Code says: "When the agent finishes, inspect every changed file and run the relevant tests yourself." (checked Oct 2026) See how to review AI-written code.

Next steps

Not affiliated with or endorsed by Anthropic, OpenAI, Anysphere, GitHub or Microsoft. Check their current docs before relying on these details.