Let your coding agent test the API it just wrote
Coding agents are now fast at writing endpoints. What they are not good at, out of the box, is proving those endpoints still work after the fifth round of edits. So the loop usually ends with a human: you open curl or a
Coding agents are now fast at writing endpoints. What they are not good at, out of the box, is proving those endpoints still work after the fifth round of edits.
So the loop usually ends with a human: you open curl or an HTTP client, hit every route by hand, find the one that broke, and paste the error back into the chat.
We got tired of being that human. This post shows how we closed the loop so the agent tests its own work, using Ajiro API, a small MIT-licensed CLI we just open-sourced.

A moved route makes GET /todos/stats return 404. The fix makes all 34 tests pass again.
Why "just ask it to write tests" falls short
You can tell an agent to write tests. In practice you get:
- Tests in whatever framework the agent picked that day, scattered across the repo
- Failures printed for humans, so the agent has to guess which line to fix
- Nothing that runs the same way in CI and on your laptop
What the agent needs is a fixed format to write, and failure output it can act on directly.
The idea: one YAML file per endpoint, next to your code
-
scanreads your routes statically and writes one YAML file per endpoint - You or the agent add expectations (status, body fields, values captured for later requests)
-
testruns everything against your running server and returns failures with the response and handler location - The agent fixes the code (or the test) and runs it again
We chose plain YAML over a custom format on purpose. Models write it reliably, diffs are readable in review, and it converts to and from OpenAPI.
Try it on a Hono app
The repo ships a small Hono TODO API in examples/hono-todo.
npx -y ajiro-api init # detects Hono and the port
npx -y ajiro-api scan
+ POST /auth/login api/auth/post-auth-login.yaml
+ GET /health api/health/get-health.yaml
+ GET /todos api/todos/get-todos.yaml
+ POST /todos api/todos/post-todos.yaml
+ GET /todos/stats api/todos/get-todos-stats.yaml
+ DELETE /todos/{id} api/todos/delete-todos-id.yaml
+ GET /todos/{id} api/todos/get-todos-id.yaml
+ PATCH /todos/{id} api/todos/patch-todos-id.yaml
hono: 8 created, 0 updated, 0 unchanged (8 endpoints, 3 ms)
It's a single Rust binary, so there is no Node or Python runtime to manage. It is also on Homebrew (brew install niti-lab/tap/ajiro-api) and cargo.
Each file has a source block that scan owns and a tests list that is yours. Here is the stats endpoint with tests filled in:
# api/todos/get-todos-stats.yaml
id: todos.stats.list
depends_on: [todos.create, todos.update]
request:
headers:
Authorization: "Bearer {{ token }}" # captured from the login test
method: GET
path: /todos/stats
source:
framework: hono
file: src/routes/todos.ts
line: 26
tests:
- name: returns counts
expect:
status: 200
body:
match:
$.total: { $gte: 1 }
$.done: { $gte: 1 }
$.open: { $gte: 1 }
- name: rejects a missing token
request: { headers: { Authorization: "" } }
expect:
status: 401
Re-running scan after code changes updates source and leaves your tests alone. The login password stays in .env ({{ env.DEMO_PASSWORD }}), and tokens are masked as *** in output.
34 passed, 0 failed, 0 errors, 0 skipped (34 total) in 25ms
The part that matters: output an agent can act on
Here is a classic agent mistake. Asked to tidy up the routes, it moves GET /todos/stats below GET /todos/:id. Hono now matches stats as an id. Types still check, and handler-level unit tests still pass.
β todos.stats.list / returns counts (1ms)
status: expected status 200, got 404
body.match: $.total: path not found (expected >= 1)
β api/todos/get-todos-stats.yaml
β handler: src/routes/todos.ts:83
33 passed, 1 failed, 0 errors, 0 skipped (34 total) in 19ms
With --json, the agent gets the same failure with the request and the actual response:
{
"endpoint_id": "todos.stats.list",
"status": "failed",
"request": { "method": "GET", "url": "http://localhost:3000/todos/stats",
"headers": { "Authorization": "Bearer ***" } },
"response": { "status": 404,
"body": { "error": "not_found", "message": "Todo not found" } },
"failures": [ { "check": "status", "expected": 200, "actual": 404 } ],
"source": { "file": "src/routes/todos.ts", "line": 83 }
}
"Todo not found" on a stats route tells you right away that another handler swallowed the request. The agent opens line 83, restores the route order, re-runs, and it's back to 34/34.
Hand it to Claude Code
Install the plugin (skill + MCP server) from inside Claude Code:
/plugin marketplace add niti-lab/ajiro-api
/plugin install ajiro-api@ajiro-api
The skill kicks in whenever the agent adds or changes an endpoint: scan, write tests, run, read failures, fix, re-run. Two of its rules matter most:
- Decide which side is wrong first. If the code contradicts the intent, fix the code. If the behaviour change is intended, fix the test. If unsure, ask the user.
- Don't weaken assertions to get green. No deleting failing tests or loosening status checks.
The second one is the real fear with agent-written tests. Since the YAML lands in the same diff as the code, you can review what was checked, not just what changed.
Using Codex? Paste AGENTS.snippet.md into your AGENTS.md.
Using another MCP client? The server is listed in the official MCP Registry as io.github.NITI-Lab/ajiro-api (and on Glama). Point your client at npx -y ajiro-api mcp; it exposes scan, test, list, validate, get_endpoint and schema as tools.
Same tests in CI
ajiro-api scan --check --ignore-lines # fail if the YAML drifted from the routes
ajiro-api test --env ci --junit report.xml
A full GitHub Actions example is in examples/github-actions.
What else the same YAML gives you
-
ajiro-api mock: a mock server with switchable scenarios, so frontend work doesn't wait on the backend -
ajiro-api docs: a single-file HTML API reference you can email to a client -
ajiro-api openapi import/export,ajiro-api import postman/bruno: move in and out
Supported frameworks: Next.js Route Handlers, Hono, FastAPI, Express, and Go (net/http, chi, Echo). Nothing leaves your machine: no account, no cloud sync.
Where this fits
If you want to poke at an API by hand, keep using Postman, Bruno, or whatever you like. Ajiro API is for the other case: the agent writes the code, and the agent should prove it works.
Repo: https://github.com/NITI-Lab/ajiro-api
Issues about where the route scanner breaks on your codebase are the most useful feedback right now. Stars are welcome too.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.