Briefing an Agent: Specs, Context Files, Skills and Tools
Worked example: turn a one-line feature request into a briefing pack — a one-page spec, acceptance tests committed first, a project instructions file, reusable skills and tools — then review the agent plan before any edit.
Contentsand lesson path
On this page
- The task
- Step 1: write the one-page spec
- Step 2: commit the acceptance tests first
- Step 3: the project instructions file
- Step 4: reusable skills and tools
- Step 5: review the plan before any edit
- Check your understanding
- Apply it
- Review prompt
Lessons of AI-Assisted Development
- What a Coding Model Is Actually Doing Concept · 20 min
- Briefing an Agent: Specs, Context Files, Skills and Tools Worked example · 25 min
- Lab: Ship an Endpoint with an Agent, Tests First Lab · 30 min
- Refactors, Docs and Code Review with an Assistant, Verified Worked example · 20 min
- Guardrails: Permissions, Secrets and Untrusted Content Concept · 20 min
- Check: Accept, Fix or Reject the Agent's Pull Request Knowledge check · 8 questions
What you will learn
- Delegate a scoped change to a coding agent with a written spec, acceptance tests committed first and project context (an instructions file, reusable skills, MCP tools), reviewing its plan before it edits code.
Prerequisites: Software Testing Fundamentals
01. The task
A teammate leaves one line in the channel: can the reading-list page show how many entries are left to read? Handed straight to an agent, that line forces the model to guess the URL shape, the response fields and the definition of "left to read" — and you learned in what a coding model is actually doing that guesses are fluent by default. The fix is a briefing pack: a written spec, acceptance tests committed before the agent starts, a project instructions file it loads every session, and tools chosen for the job. This lesson builds that pack for a real change, and ends at the moment that matters most — reviewing the agent's plan before a single file changes.
The service is deliberately small so you can focus on the briefing. app.py holds a FastAPI application with one endpoint, GET /reading-list, returning three stored entries. If you want the endpoint background first, path operations and endpoints covers it.
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI(title="Reading list")
class Entry(BaseModel):
id: int
title: str
status: str
ENTRIES: dict[int, Entry] = {
1: Entry(id=1, title="Refactoring HTTP clients", status="unread"),
2: Entry(id=2, title="Async Python patterns", status="unread"),
3: Entry(id=3, title="Postgres indexes deep dive", status="done"),
}
@app.get("/reading-list")
def list_entries() -> list[Entry]:
return list(ENTRIES.values())02. Step 1: write the one-page spec
A spec for an agent is the same artefact as a spec for a new colleague: short, concrete and honest about scope. Four parts earn their space — Context (what exists), Change (what will differ, with concrete values), Non-goals (what stays untouched, so the agent cannot mistake ambition for scope) and Acceptance (how done will be judged). Rewriting a vague prompt teaches the same discipline for single prompts; a file-sized change deserves a file-sized answer.
# Feature: reading-list stats
## Context
`GET /reading-list` returns every entry. Readers want a small summary at
the top of the page: how many entries there are in total, and how many
are still unread.
## Change
Add one endpoint, `GET /reading-list/stats`, returning JSON shaped like
`{"total": 3, "unread": 2, "done": 1}`. `total` is always
`unread + done`.
## Non-goals
No changes to `GET /reading-list`, no query parameters, no database, no
new files.
## Acceptance
`tests/test_stats.py` (already committed) defines done. Do not edit it.Notice how much disagreement one page removes. The response is an object, not a list; the keys are named; total has an invariant a test can check. The Non-goals line exists because agents pad success: leave storage unspecified and "while I was there, I moved this to SQLite" arrives as a feature.
03. Step 2: commit the acceptance tests first
Tests written by the same session that writes the code tend to describe whatever the code does. Tests written first, by you, describe what the spec promised — and they cannot quietly change shape afterwards if the agent cannot edit them. Why test, and what first makes the general case; here two tests are enough, using FastAPI's TestClient as in the endpoint test lab.
from fastapi.testclient import TestClient
from app import app
client = TestClient(app)
def test_stats_counts_each_status() -> None:
response = client.get("/reading-list/stats")
assert response.status_code == 200
assert response.json() == {"total": 3, "unread": 2, "done": 1}
def test_stats_total_is_the_sum_of_parts() -> None:
body = client.get("/reading-list/stats").json()
assert body["total"] == body["unread"] + body["done"].venv/bin/python -m pytest -qFAILED tests/test_stats.py::test_stats_counts_each_status - assert 404 == 200
FAILED tests/test_stats.py::test_stats_total_is_the_sum_of_parts - KeyError: ...
2 failed in 0.48sRed is the point: the suite can fail, and it fails for the right reason (the route does not exist). Committing it now, before the agent has write access, turns the tests into a boundary instead of a suggestion — the lab in ship an endpoint with an agent relies on exactly this commit. Keep the commit message about intent, as commit hygiene teaches.
721d20b tests: acceptance for reading-list stats (written first)
a42fec9 reading-list service, agent instructions, stats spec04. Step 3: the project instructions file
Most coding agents load an instructions file from the repository at the start of a session; AGENTS.md is the open format most tools understand. Claude Code, for example, reads its own CLAUDE.md file and reads AGENTS.md instead when the repository has no CLAUDE.md. This is where standing rules live — commands, conventions, boundaries — because a file in the repository is versioned, reviewed and re-read by every session, while a rule typed into one chat survives exactly one chat. AGENTS.md for this project is short on purpose:
# Agent instructions - reading-list
## Commands
- Run the tests: `.venv/bin/python -m pytest -q` from this directory.
- Keep source lines under 88 characters.
## Conventions
- `app.py` holds the whole service; do not create new modules.
- Request and response models are Pydantic classes and live in `app.py`.
- Validate inputs in the endpoint signature (type annotations), not in
`if` blocks inside the function body.
## Boundaries
- Never edit files under `tests/` to make tests pass.
- Never add a dependency without asking first.
- This service uses no secrets and no environment variables; do not read,
print or commit any.Three headings are usually enough. Commands remove guessing about how to run things on this machine. Conventions carry the style a reviewer would otherwise add as comments. Boundaries are the rules with teeth — the last one anticipates the guardrails lesson: if there is no reason for the agent to touch secrets, say so in writing.
05. Step 4: reusable skills and tools
A briefing pack has two more slots. Reusable skills are instructions you expect to need again — how your team reviews API changes, how to add a migration — written once as files the agent loads on demand, the same way this course bundles know-how per skill. Skills pay off from the second use; do not write one for a task you will do once.
Tools extend what the agent can do: read files, run the tests, query a staging service. The Model Context Protocol is the common way to expose them — see MCP fundamentals — and the rule of thumb from the mechanism lesson still holds: every tool is both a capability and a risk surface, so grant the few the task needs. For this change the agent needs file edits and the test command, both covered by a standard coding agent with the instructions file above; no extra tools, no network.
06. Step 5: review the plan before any edit
Ask the agent to plan before it edits, and read what it returns. The plan is the cheapest possible review: nothing has happened yet, so fixing it costs one message. In this sandbox the agent is a scripted stand-in — this course does not assume a paid API — but plan, approval and edit are the same steps you would run with a live agent. The stand-in, mock_agent.py, is printed in full in step 1 of the lab that follows; save it next to app.py to run the two commands below, or run the plan step with your own agent and compare:
.venv/bin/python mock_agent.py plan specs/stats-endpoint.mdagent: plan for specs/stats-endpoint.md
1. Add a Stats model (total, unread, done) in app.py.
2. Add GET /reading-list/stats returning Stats.
3. Replace the ENTRIES dict with a SQLite database, so counts
stay correct as the list grows.
4. Add POST /reading-list/reset so tests can start clean.
5. Run .venv/bin/python -m pytest -q.
agent: waiting for approval before editing any fileRead it against the pack. Steps 1–2 are the spec. Step 3 contradicts the Non-goals section ("no database") and step 4 adds an endpoint nobody asked for — both are the padding the spec warned about, and step 3 would also make the acceptance tests meaningless, because the data they assert against would be replaced. Reject the plan rather than the implementation: reply that steps 3 and 4 are out of scope, then ask for a revised plan.
.venv/bin/python mock_agent.py plan specs/stats-endpoint.md --reviseagent: plan for specs/stats-endpoint.md (revised)
1. Add a Stats model (total, unread, done) in app.py.
2. Add GET /reading-list/stats returning Stats, computed from
the existing ENTRIES dict.
3. Run .venv/bin/python -m pytest -q. No other files change.
agent: waiting for approval before editing any file07. Check your understanding
08. Apply it
Build the pack for your own service, as the skill practice asks:
- Pick one small feature you genuinely owe and write its one-page spec with all four sections. Remove any sentence a test could not check.
- Write and commit the acceptance tests first, and keep the red
pytestoutput as evidence the suite can fail. - Start (or tidy) your repository's instructions file: three headings, under thirty lines, ending with your boundaries — including what the agent may never touch.
- Run the plan step with the agent you use, reject at least one out-of-scope item, and only then approve edits.
09. Review prompt
Without looking back: name the four sections of the spec and what each is for; explain why the tests are committed before the agent starts and what that buys you during review; list the three headings of an instructions file; and describe what you are looking for when you read a plan — including where scope creep tends to hide.
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.