Designing Context Packages for Coding Agents
A well-worded prompt isnât enough
Section titled âA well-worded prompt isnât enoughââAsk clearly,â âassign a role,â ârequest things step by stepâ: most advice on working with coding agents focuses on polishing the prompt sentence. That advice isnât wrong, but it doesnât solve the actual problem this series has been building toward: how do you hand a coding agent the artifacts already produced (architecture decision, user story, acceptance criteria) without losing information along the way?
Look again at the artifacts produced so far in this series.
- Architecture Decision: a design decision like "double-guarded by a DB unique constraint"- User Story: "As a registrant, I want to know immediately whether a team name is already taken when I type it"- Acceptance Criteria: verification conditions in Given-When-Then formHand these three over as a natural-language paragraph and a coding agent will drop or reinterpret some of it. Unstructured text gives the agent no way to tell whatâs a hard constraint versus whatâs merely background information.
Context Package: structured input, not a prompt
Section titled âContext Package: structured input, not a promptâThis article proposes building a structured input (a Context Package) instead of a natural-language prompt. A Context Package has four fields.
task: # exactly what this piece of work does (keep the scope narrow) title: "Implement the team name duplicate check API" scope: "Implement only the POST /api/registrations/check-team-name endpoint" out_of_scope: "Registration form submission and file upload are not part of this task"
context: # background the agent should reference (quote prior artifacts verbatim) architecture_decision: | - Team name duplicate check is double-guarded by a frontend real-time check plus a DB unique constraint - File storage is kept separate with direct URL access blocked (unrelated to this task) related_story: | Story: Team name duplicate check "As a registrant, I want to know immediately whether a team name is already taken when I type it, so that I don't get rejected at submission time and can complete my registration."
constraints: # non-negotiable rules - "Follow the existing code style (the project's ESLint config)" - "DB access must go through the repository layer (no direct queries in the controller)" - "This endpoint must be reachable without authentication (it runs before registration)"
acceptance: # bring acceptance criteria over verbatim, don't re-summarize them - "Given a team name input, When the name already exists, Then return a 409 response with an error message" - "Given a team name input, When the name does not exist, Then return a 200 response" - "When two requests submit the same team name concurrently, only one may ultimately succeed due to the DB unique constraint"The reason this structure beats a natural-language prompt is simple. task makes the boundary of what the agent may touch explicit; context gives the reasoning behind the design; constraints highlights the non-negotiable rules; acceptance gives the agent a standard to verify its own output against. The fact that these four fields stay separate, instead of blending together, is the whole point.
Donât ask for chain-of-thought
Section titled âDonât ask for chain-of-thoughtâOlder prompt engineering advice frequently recommends asking a model to âthink step by stepâ (chain-of-thought). That pattern isnât applied as-is to coding agents in this series.
The reason is straightforward. Chain-of-thought output shows how the agent thought, but what a human actually needs to verify is what changed and whether it satisfies the acceptance criteria. A narrated thought process is not a verifiable deliverable.
Instead, this series fixes the coding agentâs output structure itself as follows.
## Output structure (coding agent response contract)
1. Decision summary - The key design/implementation decisions made in this task and why (1-3 sentences)
2. Changed file list - File path and change type (added/modified/deleted)
3. Verification command - An actually runnable command to verify this change (e.g. npm test -- --grep "team-name", a curl command, etc.)
4. Execution result - The actual result of running the verification command (pass/fail, relevant logs)
5. Unresolved items - Anything the agent is unsure about or that needs human confirmationThis structure connects directly to the Human Gate principle covered in Agile Delivery and AI Role Boundaries. A response with an empty âunresolved itemsâ section should actually raise suspicion: it likely means the agent overlooked something it wasnât sure about, rather than confirming there was nothing left to resolve.
Comparing actual outcomes with a Context Package example
Section titled âComparing actual outcomes with a Context Package exampleâThe difference becomes visible when you compare requesting the same task as a natural-language prompt versus as a Context Package.
Natural-language prompt (not recommended):
Build an API that checks for duplicate team names. It should error if thename already exists, and it needs to handle multiple people registering atthe same time without issues.This prompt forces the agent to guess where the endpoint should live, whether authentication is required, and what layering it should follow. If the guess diverges from the architecture decision made earlier in this series, the code may work but risks getting merged in a state that contradicts the teamâs design principles.
Context Package (recommended): the YAML above, verbatim. The agent stays inside scope, doesnât violate the constraints, and reports a self-verified result measured against the acceptance criteria.
When a Context Package isnât necessary
Section titled âWhen a Context Package isnât necessaryâNot every task needs a Context Package. Typo fixes or simple refactors that have no relation to any architecture decision or acceptance criteria donât need to be wrapped in this structure. Reserve the Context Package for work that spans multiple screens or layers, must follow the teamâs design principles, or produces a result a human will need to verify later.
Next article
Section titled âNext articleâOnce implementation is done via a Context Package, the next step is proving through testing that the implementation actually satisfies the acceptance criteria. The next article covers a two-pass test design: document-first test scenarios written before code exists, and code-grounded refinement once it does.
â From User Stories to Test Scenarios and Test Code