The AI Coding Agent Guide: Context, Workflows, and Verification
Quick answer: An AI coding agent is only as good as the context it is given and the verification it is held to. The two failures that dominate real work are under-context (the agent guesses the API and invents fields) and over-trust (it reports "done" after a green local run, without exercising the real flow). The fix is structural: give the agent the contract and tools through an MCP server instead of pasted docs, keep it on the OpenAPI, and define "done" as a runnable command that passes in CI — not a confident summary.
This guide covers how to give agents context, how to design APIs so agents can use them, how to verify their work, and the recurring anti-patterns. Follow the links for the concrete cases.
All articles in this guide
Each article below is a focused, pain-point-driven read that belongs to this hub. New ones are added on a regular schedule; the ones still in progress are marked.
The Agent Said "Done" but Didn't Verify
The agent's green local run never exercised the real path. How to make "done" a runnable command, not a confident summary.
Read the article →Green CI After an AI Refactor Means Nothing
A green build after an AI refactor can still miss the changed path. What it proves and what it silently skips.
Read the article →The Agent Passes Unit Tests but Never Runs the App
Unit tests pass but the app never boots. The gap between isolated units and the running system.
Read the article →Local Green, CI Red: Why the Agent's Machine Lied
It works on the agent's machine and fails in CI. The environment and ordering assumptions that cause it.
Read the article →The Agent Fixed a TypeScript Error with "as any"
The fastest way to silence tsc is also the one that throws away the type. Better fixes, in order.
Read the article →A Broad try-catch the Agent Added Hides Real Failures
A catch-all that makes errors disappear instead of surfacing them. Why it ships and how to catch it.
Read the article →The Agent's Handoff Kept the Decision but Dropped the Why
The summary records what changed but not why. The context that vanishes and how to keep it.
Read the article →Dev Servers Left Orphaned After the Agent Said "Done"
The agent finishes and leaves background servers and ports running. A cleanup check for the handoff.
Read the article →The Agent Reintroduces a Bug You Already Fixed in an Earlier Session
A fixed bug can return in a new session because the agent lacks memory; encode the invariant as a regression test.
Read the article →The Agent Edits a Generated File That Gets Overwritten on the Next Build
Fix the generator input rather than the emitted artifact, with a CI drift check to catch direct edits.
Read the article →The Agent Rewrote a Shared Helper and Changed Its Return Shape for Every Caller
Why an agent can break every caller when it edits a shared helper, and how to verify the whole contract.
Read the article →The Agent Fixed One Call Site but Left the Same Bug in the Others
Why a pattern-level bug needs a structural search and a shared helper instead of a single-site patch.
Read the article →The Agent Added a Second Copy of a Utility the Repo Already Had
How a freshly written helper can silently fork an existing utility and drift into a domain bug.
Read the article →The Agent Resolved a Merge Conflict by Keeping Both Sides
Why an agent's clean merge can keep both sides of a conflict and silently shadow one.
Read the article →The Agent Removed a 'Dead' Export That Was Still Imported Through a Path Alias
Why a dead-code report can miss aliased and dynamic imports and turn a safe-looking deletion into a runtime break.
Read the article →The Agent Added a 'Safe' Fallback That Quietly Returned Empty Data
Why a nullish fallback can hide a failing upstream call and how to keep the error honest.
Read the article →The Agent Added an Inline Linter Disable Instead of Fixing What It Flagged
Why an inline linter disable hides real problems and how to make suppressions intentional.
Read the article →Give the agent the right context
An agent that does not know the real API will politely invent one. Pasting a curl command or a doc dump is a weak, lossy way to supply context; the better architecture is to connect the agent to the contract through tools. Start with AI coding agents, API context, and MCP, then stop pasting API docs and give the AI an MCP server. When an agent is asked to work from an unknown contract, the honest alternative is in unknown is better than an AI-invented contract.
Design APIs so agents can use them
An API that is easy for a human is not always easy for an agent: agents need discoverable operations, typed errors, and stable identifiers. The design principles are in designing APIs for AI agents. When the agent needs structured data back, enforce the shape with a schema rather than parsing free text; structured outputs, JSON Schema, and tool calling.
Define "done" as a verified command
The word "done" from an agent is a claim, not evidence. The most common failure is a green local run that never exercised the real path. The rule is in the agent said done but didn't verify, and for APIs the bar is a 200 is not done: run the business scenario. A green build after a refactor is also not proof; green CI after an AI refactor means nothing explains what it can still miss.
The recurring agent anti-patterns
Autonomous agents repeat a recognizable set of mistakes. Scan for these in review; each is a real case:
- Passes unit tests but never runs the app
- Local green, CI red
- Fixes a type error with
as any - Adds types that are mostly
any - A broad try-catch that hides failures
- A handoff that keeps the decision but drops the why
- A rename that misses a string reference
- Dev servers left orphaned after "done"
Switching tools without reintroducing the API
Teams move between coding agents and IDEs as the landscape changes. The way to keep your API contract stable across those switches — rather than re-integrating it into each tool — is in switching AI tools without reintroducing your API. The client landscape is compared in MCP clients compared.
Where to go next
Powerduck is the local-first, OpenAPI-first workspace that carries this whole flow — from the contract through debug, test, mock, and the tools an agent can call. See it on the Powerduck homepage.
The mechanism that makes all of this work is the contract and the tools built from it. Read the MCP server guide to expose the API, and the API testing guide to verify the agent's work. For the underlying contract, return to the OpenAPI guide.
Frequently asked questions
How much should I let an AI agent do autonomously?
Let it draft, explore, and implement, but keep a human on the decisions that change the contract or touch money and auth. Autonomy should scale with how fast you can verify its output.
Why does the agent keep using fields that don't exist?
Because it is working from memory or a doc dump rather than the live schema. Give it the contract through MCP and it will call the documented tools instead of guessing.
What is the minimum verification for an agent change?
Run the relevant test suite and the real business flow in CI, and confirm the change fails without the fix. A test that cannot fail, or a run that never touches the changed path, is not verification.