All courses

Prompting . Beginner . 60 min

Prompting and Context for Coding Agents

A tool-agnostic course on getting reliable work out of coding agents: write clear task specs, give the right context, make tests the target, and keep sessions focused.

What your team will learn

Outline

  1. Writing task specs agents can act on (12 min, 4-question quiz)
  2. Giving the right context and constraints (12 min, 4-question quiz)
  3. Verification loops: make tests the target (12 min, 4-question quiz)
  4. Breaking down work into agent-sized steps (12 min, 4-question quiz)
  5. Context window hygiene (12 min, 4-question quiz)
Assign this course to your team

Free lesson

Writing task specs agents can act on

A coding agent is a fast, literal collaborator that has never been to your standup. It does not know which ticket you mean, why the code looks the way it does, or what your team considers finished. Most disappointing agent output traces back to a vague request, not a weak model. The fix is cheap: spend two minutes writing a task spec before you hit enter.

The four parts of a good spec

  1. Goal: one or two sentences describing the outcome, phrased as behavior. "Users can reset their password from the login page" beats "add password reset".
  2. Context: where the relevant code lives, what already exists, and anything surprising about it.
  3. Constraints: what the agent must not do. No new dependencies, keep the public API stable, do not touch the migrations folder.
  4. Definition of done: the checks that prove the work is complete, ideally commands the agent can run.

You do not need all four for a one-line fix, but the definition of done is the part people skip most and the part that matters most. Without it, the agent decides when it is finished, and it is usually optimistic.

Goal: Add a "copy link" button to each row in the invoices table.

Context:
- Table is in src/features/invoices/InvoiceTable.tsx
- We already have a useClipboard hook in src/hooks/useClipboard.ts
- Toasts use the existing toast() helper, see src/ui/toast.ts

Constraints:
- No new dependencies
- Keep the table's column order unchanged
- Match the existing icon button style (see the "download" button)

Done when:
- pnpm test src/features/invoices passes, including a new test for the button
- pnpm typecheck passes
- Clicking the button copies the invoice URL and shows a toast
A compact spec for a small feature

Say what you know, not just what you want

Engineers often hold back information they assume is obvious. The agent cannot see your assumptions. If you already know the bug is in the date parsing, say so. If a previous fix attempt failed, say what it was and why it failed, so the agent does not repeat it. If there is a pattern in the codebase you want copied, name the file. Pointing at an example is one of the most effective things you can do, because the agent will mirror naming, error handling, and structure without you spelling them out.

Phrasing that helps

  • Be specific about scope: "only change files under src/billing" is clearer than "keep it small".
  • State the preferred approach when you have one, and say when you do not: "I am open to a different approach if this one is awkward".
  • Ask the agent to stop and ask when a decision is ambiguous rather than guess.
  • Avoid stacking unrelated requests in one message. Two tasks in one prompt tend to produce one half-finished task.

Over time you will notice the same context appearing in many specs: how to run tests, which folders are generated, code style rules. Most agent tools support a project instructions file that is loaded automatically. Moving repeated context there keeps each individual spec short and keeps the whole team consistent.

Exercise

Rewrite a vague request

  1. Pick a real ticket from your backlog that you would describe in one sentence.
  2. Write it as a spec with goal, context, constraints, and done-when sections.
  3. Make sure every done-when item is either a command or an observable behavior.
  4. Give both versions to an agent in separate sessions and compare the first diffs you get back.

Keep going with your team

The other 4 lessons, quizzes, progress tracking, due dates and certificates come with the Training add-on at $12 per learner per month.

Get started

Independent course. Not affiliated with or endorsed by Anthropic, OpenAI or Anysphere.