<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kanepion</title>
    <description>The latest articles on DEV Community by Kanepion (@kanep_679433b8ec8dc).</description>
    <link>https://dev.to/kanep_679433b8ec8dc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4254769%2Fd4301474-8611-43ab-be24-6a0bac9d6057.png</url>
      <title>DEV Community: Kanepion</title>
      <link>https://dev.to/kanep_679433b8ec8dc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kanep_679433b8ec8dc"/>
    <language>en</language>
    <item>
      <title>Let your coding agent test the API it just wrote</title>
      <dc:creator>Kanepion</dc:creator>
      <pubDate>Fri, 20 Nov 2026 05:48:05 +0000</pubDate>
      <link>https://dev.to/kanep_679433b8ec8dc/let-your-coding-agent-test-the-api-it-just-wrote-11gh</link>
      <guid>https://dev.to/kanep_679433b8ec8dc/let-your-coding-agent-test-the-api-it-just-wrote-11gh</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;We got tired of being that human. This post shows how we closed the loop so the agent tests its own work, using &lt;strong&gt;Ajiro API&lt;/strong&gt;, a small MIT-licensed CLI we just open-sourced.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fraw.githubusercontent.com%2FNITI-Lab%2Fajiro-api%2Fmain%2Fdocs%2Fdemo%2Fdemo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fraw.githubusercontent.com%2FNITI-Lab%2Fajiro-api%2Fmain%2Fdocs%2Fdemo%2Fdemo.gif" alt="demo" width="799" height="465"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;A moved route makes &lt;code&gt;GET /todos/stats&lt;/code&gt; return 404. The fix makes all 34 tests pass again.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Why "just ask it to write tests" falls short
&lt;/h2&gt;

&lt;p&gt;You can tell an agent to write tests. In practice you get:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tests in whatever framework the agent picked that day, scattered across the repo&lt;/li&gt;
&lt;li&gt;Failures printed for humans, so the agent has to guess which line to fix&lt;/li&gt;
&lt;li&gt;Nothing that runs the same way in CI and on your laptop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What the agent needs is a fixed format to write, and failure output it can act on directly.&lt;/p&gt;
&lt;h2&gt;
  
  
  The idea: one YAML file per endpoint, next to your code
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;scan&lt;/code&gt; reads your routes statically and writes one YAML file per endpoint&lt;/li&gt;
&lt;li&gt;You or the agent add expectations (status, body fields, values captured for later requests)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;test&lt;/code&gt; runs everything against your running server and returns failures with the &lt;strong&gt;response and handler location&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The agent fixes the code (or the test) and runs it again&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;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.&lt;/p&gt;
&lt;h2&gt;
  
  
  Try it on a Hono app
&lt;/h2&gt;

&lt;p&gt;The repo ships a small Hono TODO API in &lt;code&gt;examples/hono-todo&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx -y ajiro-api init     &lt;span class="c"&gt;# detects Hono and the port&lt;/span&gt;
npx -y ajiro-api scan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+ 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)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's a single Rust binary, so there is no Node or Python runtime to manage. It is also on Homebrew (&lt;code&gt;brew install niti-lab/tap/ajiro-api&lt;/code&gt;) and cargo.&lt;/p&gt;

&lt;p&gt;Each file has a &lt;code&gt;source&lt;/code&gt; block that &lt;code&gt;scan&lt;/code&gt; owns and a &lt;code&gt;tests&lt;/code&gt; list that is yours. Here is the stats endpoint with tests filled in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# api/todos/get-todos-stats.yaml
&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;todos.stats.list&lt;/span&gt;
&lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;todos.create&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;todos.update&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="na"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer {{ token }}"&lt;/span&gt;   &lt;span class="c1"&gt;# captured from the login test
&lt;/span&gt;  &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;GET&lt;/span&gt;
  &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/todos/stats&lt;/span&gt;
&lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;framework&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hono&lt;/span&gt;
  &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;src/routes/todos.ts&lt;/span&gt;
  &lt;span class="na"&gt;line&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;26&lt;/span&gt;
&lt;span class="na"&gt;tests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;returns counts&lt;/span&gt;
    &lt;span class="na"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;
      &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;match&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;$.total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;$gte:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;$.done&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;$gte:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;$.open&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;$gte:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;rejects a missing token&lt;/span&gt;
    &lt;span class="na"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;headers:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;Authorization:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="na"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;401&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Re-running &lt;code&gt;scan&lt;/code&gt; after code changes updates &lt;code&gt;source&lt;/code&gt; and leaves your tests alone. The login password stays in &lt;code&gt;.env&lt;/code&gt; (&lt;code&gt;{{ env.DEMO_PASSWORD }}&lt;/code&gt;), and tokens are masked as &lt;code&gt;***&lt;/code&gt; in output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;34 passed, 0 failed, 0 errors, 0 skipped (34 total) in 25ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The part that matters: output an agent can act on
&lt;/h2&gt;

&lt;p&gt;Here is a classic agent mistake. Asked to tidy up the routes, it moves &lt;code&gt;GET /todos/stats&lt;/code&gt; below &lt;code&gt;GET /todos/:id&lt;/code&gt;. Hono now matches &lt;code&gt;stats&lt;/code&gt; as an id. Types still check, and handler-level unit tests still pass.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✗ todos.stats.list / returns counts (1ms)
    status: expected status 200, got 404
    body.match: $.total: path not found (expected &amp;gt;= 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
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;--json&lt;/code&gt;, the agent gets the same failure with the request and the actual response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"endpoint_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"todos.stats.list"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"failed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"request"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"method"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost:3000/todos/stats"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
               &lt;span class="nl"&gt;"headers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer ***"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"response"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nl"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"not_found"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Todo not found"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"failures"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"check"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"expected"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"actual"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"file"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"src/routes/todos.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"line"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;83&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hand it to Claude Code
&lt;/h2&gt;

&lt;p&gt;Install the plugin (skill + MCP server) from inside Claude Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/plugin marketplace add niti-lab/ajiro-api
/plugin install ajiro-api@ajiro-api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Decide which side is wrong first.&lt;/strong&gt; If the code contradicts the intent, fix the code. If the behaviour change is intended, fix the test. If unsure, ask the user.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't weaken assertions to get green.&lt;/strong&gt; No deleting failing tests or loosening status checks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Using Codex? Paste &lt;a href="https://github.com/NITI-Lab/ajiro-api/blob/main/docs/agents/AGENTS.snippet.md" rel="noopener noreferrer"&gt;AGENTS.snippet.md&lt;/a&gt; into your &lt;code&gt;AGENTS.md&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Using another MCP client? The server is listed in the official MCP Registry as &lt;code&gt;io.github.NITI-Lab/ajiro-api&lt;/code&gt; (and on Glama). Point your client at &lt;code&gt;npx -y ajiro-api mcp&lt;/code&gt;; it exposes &lt;code&gt;scan&lt;/code&gt;, &lt;code&gt;test&lt;/code&gt;, &lt;code&gt;list&lt;/code&gt;, &lt;code&gt;validate&lt;/code&gt;, &lt;code&gt;get_endpoint&lt;/code&gt; and &lt;code&gt;schema&lt;/code&gt; as tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Same tests in CI
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ajiro-api scan --check --ignore-lines        &lt;span class="c"&gt;# fail if the YAML drifted from the routes&lt;/span&gt;
ajiro-api &lt;span class="nb"&gt;test&lt;/span&gt; --env ci --junit report.xml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A full GitHub Actions example is in &lt;a href="https://github.com/NITI-Lab/ajiro-api/blob/main/examples/github-actions/ajiro-api.yml" rel="noopener noreferrer"&gt;examples/github-actions&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What else the same YAML gives you
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ajiro-api mock&lt;/code&gt;: a mock server with switchable scenarios, so frontend work doesn't wait on the backend&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ajiro-api docs&lt;/code&gt;: a single-file HTML API reference you can email to a client&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ajiro-api openapi import/export&lt;/code&gt;, &lt;code&gt;ajiro-api import postman/bruno&lt;/code&gt;: move in and out&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Supported frameworks: Next.js Route Handlers, Hono, FastAPI, Express, and Go (net/http, chi, Echo). Nothing leaves your machine: no account, no cloud sync.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this fits
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/NITI-Lab/ajiro-api" rel="noopener noreferrer"&gt;https://github.com/NITI-Lab/ajiro-api&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Issues about where the route scanner breaks on your codebase are the most useful feedback right now. Stars are welcome too.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>testing</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
