Work with AI agents
Guardrails for AI agents that write APIs
An agent renames a response field as readily as a variable, without asking which clients read it. Catch the incompatible change in its local checks, and again in the required CI check.
- A linter that says no
apigenie lintexits with status 1 and names each issue's line and rule, as JSON on request, so an agent fixes what it broke instead of guessing. - A diff that rates the change
apigenie diffrates each change by what it does to a client, as a status, a changelog or JSON. Run as a required check against the base branch, it stops a breaking change even when the agent skipped its local checks. - Edits that review cleanThe formatter gives the same file every time, and
--fixkeeps your comments, so an agent's change is a small diff a person can read.
A rename rejected, then done safely
The agent renames customerName to customer_name in a response. apigenie diff against the base branch's file rates the response change breaking and exits with 1. The agent keeps the old field, marks it deprecated, adds the new one, and the recheck passes, as JSON it can read. A required CI check runs the same command on the pull request, so merging depends on it, not on the agent's local run.
$ apigenie diff main.yaml api.yaml
api.yaml
10 7 breaking Modified operation GET /orders/{orderId}
10 7 breaking Modified response code 200
$ echo $?
1
$ # keep customerName, deprecated; add customer_name
$ apigenie diff main.yaml api.yaml \
--report status --formatter json
{
"formatVersion": 1,
"status": "non-breaking"
}
$ echo $?
0What it covers
- One table of exit statusesShared by the four binaries, and frozen by the 1.0 compatibility promise for
apigenie, the generator and the server. - JSON on requestlint, diff, format, test, the catalog and the server's contract report, each with a
formatVersionthat changes only when a field is removed or changes meaning. - A configuration with a schema
apigenie.yamlis checked against its JSON Schema before any command reads it. - Docs an agent can readGuides, reference pages and linter rules as Markdown, listed in
llms.txtand collected inllms-full.txt. - MCP servers from the contract
apigenie-generator server mcpwrites a tool per operation (experimental). - Generated code, checkedA validating proxy checks what an agent's server returns against the contract.
Step by step
Work with AI agents: Put the linter, the diff and the formatter in a coding agent's loop, so that what it changes in a contract is checked the way a person's change is.
The same answer for the agent, the reviewer and CI
lint, diff and format give the agent JSON, the reviewer text and CI an exit status, with the same rules behind each.