How to Make Your API Work Better With Claude Code, Codex and Cursor
Direct answer
To make your API work better with Claude Code, Codex and Cursor, remove every step that needs a human. Publish full quickstart code in Markdown, read keys from environment variables, name one correct package, return errors that say what to fix, and ship a CLI and MCP server. Then run the same task on each agent, since results differ.
Agent usability is whether an agent can complete a real task with your product: sign up, authenticate, integrate and get a working result. Our numbers come from the October 2026 boards of Devtool Arena, Lightsage's public leaderboard of how well coding agents use 150+ developer tools.
How do I make my API work better with Claude Code?
You make your API work better with Claude Code by shortening the loop it runs on every integration. The agent recalls or fetches your docs, picks a package, finds a key, writes code, runs it and reads the output. Each unclear step adds tool calls.
The same API can run that loop very differently on each agent. In one of Devtool Arena's payments runs, the same API got the same task on every board. Claude Code (Sonnet 5) finished with 7 tool calls and no errors, for a score of 85. Codex (GPT-6 Sol) scored 66 and needed 59 tool calls, and Cursor (Composer 2.5) scored 71 with 37. The API's checklist score was identical on all three boards, so the gap came from the task run (Devtool Arena, Claude Code API board, October 2026).
1. Publish complete docs that agents can read
Give every quickstart full, runnable code, serve each docs page as Markdown, and list your pages in an llms.txt file.
A complete quickstart has the install command, the import line, the key's environment variable, the call and the expected output. Stripe's quickstart in Markdown opens with instructions written for coding agents, including which API to prefer and which import path to use (checked October 24, 2026).
Treat llms.txt as a convenience for agents that look for it. We think it doesn't change whether an agent picks you, and assets don't make the task work on their own. On Devtool Arena's Claude Code API board (October 2026), one agent memory API had every checklist asset (100) and a task score of 61, while an inference API had a checklist score of 57 and a task score of 86.
Fetch your quickstart the way an agent does:
curl -s https://docs.example.com/quickstart.md | grep -c 'ACME_API_KEY'
Zero means an agent reading that page never learns where the key goes.
2. Let an agent get and use a key without a browser
Read the key from a documented environment variable, offer test keys that need no card or phone number, and let keys be created from an API or CLI.
Access is where unattended runs stop. On Devtool Arena's Claude Code API board (October 2026), dozens of tools were skipped before the task could run, most because no key could be obtained or the key required a paid plan, and a few because of company verification or a credit card requirement. The Codex API board shows the same pattern. These rows measure access only and say nothing about the API behind them, but we think an agent working alone stalls at the same point.
Stripe's docs tell coding agents to run stripe sandbox create for an anonymous sandbox with working keys and no registration (Stripe, checked October 24, 2026). Resend lets an existing key create others with resend api-keys create (Resend API reference).
It worked if a fresh shell with only the variable set gets a successful call:
export ACME_API_KEY=test_key_here
claude -p "Use the Acme API to fetch one record and print it."
3. Name one correct package and ship a typed SDK
Use one official package name everywhere, publish a typed SDK generated from your OpenAPI spec, and show the install line next to the import line in every snippet.
Models guess package names. In 576,000 code samples from 16 models, hallucinated packages averaged at least 5.2% for commercial models and 21.7% for open-source ones (Spracklen et al., arXiv, 2024). An unscoped package with your brand name may belong to someone else, so an agent that guesses can install the wrong client. And when a client installs under one name but imports under another, every snippet needs both lines.
A typed SDK lets a type checker catch a wrong field before the code runs. An OpenAPI spec gives agents and SDK generators every endpoint in one file.
To check, ask each agent to "install the Acme SDK" in an empty project and compare its pick with your official package.
4. Return errors that say what to do next
Every error should carry a stable code, the parameter at fault, a sentence on how to fix it and a link to the right docs page.
Agents decide their next call from your error body. Stripe's error object includes type, code, param, message and doc_url (Stripe API reference). An agent that gets "param": "currency" can fix the request, while a bare 400 Bad Request sends it back to the docs. Errors cost tool calls. On Devtool Arena's Cursor API board (October 2026), runs with at least one error used a median of 32 tool calls, against 14 for the 45 error-free runs (our count from the board).
A useful error looks like this:
{
"error": {
"code": "missing_parameter",
"param": "currency",
"message": "currency is required. Use a three-letter ISO code such as usd.",
"doc_url": "https://docs.example.com/errors#missing_parameter"
}
}
Send one request with a missing field and one with a bad key. If the responses alone tell you the fix, an agent can use them.
5. Ship a CLI with JSON output and exit codes
Give agents a CLI that reads the key from an environment variable, prints JSON on request and exits non-zero on failure.
Agents already work in a terminal, so a CLI is often their shortest path. Resend's CLI switches to JSON when piped or given --json, reads RESEND_API_KEY from the environment, and exits with code 1 and a JSON error on failure (Resend CLI docs). It scored 91 on both the Claude Code and Codex CLI boards with no errors. LiveKit's lk CLI scored 87 on Claude Code and 90 on Codex (Devtool Arena, Codex CLI board, October 2026).
Drop interactive prompts and browser-only logins, then check it in a script:
acme projects list --json | jq '.[0].id'
acme projects get does-not-exist --json; echo "exit=$?"
The second command should print a JSON error and a non-zero exit code.
6. Offer an MCP server for agents that prefer tools
Publish an MCP server whose tools map to developers' jobs, with environment variable or header auth and install commands for each agent.
The Model Context Protocol lets an agent call your product as named tools instead of writing HTTP code. Each agent installs servers its own way: claude mcp add in Claude Code, codex mcp add or ~/.codex/config.toml in Codex, and .cursor/mcp.json in Cursor. Put all three on one docs page.
A well-built server can outscore your API. Qdrant's MCP server scored 90 on Devtool Arena's Claude Code MCP board and 93 on its Codex MCP board, above its API scores of 79 and 80 (October 2026). Confirm that MCP Inspector lists your tools with clear descriptions, then run one real task in each agent. How to test your MCP server with coding agents covers the full method.
7. Write context for CLAUDE.md, AGENTS.md and Cursor rules
Publish a short block developers can paste into their agent's context file: the package name, the key's environment variable, the base URL and mistakes to avoid.
Each agent reads a different file, as of October 24, 2026:
| Agent | Reads | Detail |
|---|---|---|
| Codex | AGENTS.md | ~/.codex/AGENTS.md, then each directory from the repo root down; 32 KiB cap by default (docs) |
| Cursor | .cursor/rules/*.mdc or AGENTS.md | Project rules need the .mdc extension and frontmatter (docs) |
| Claude Code | CLAUDE.md | Reads AGENTS.md only when no CLAUDE.md exists (v2.1.277 or later); otherwise import it with @AGENTS.md (docs) |
| OpenCode | AGENTS.md | Falls back to CLAUDE.md when no AGENTS.md exists (docs) |
So write one AGENTS.md block, a one-line @AGENTS.md import for Claude Code users and an .mdc copy for Cursor. LiveKit goes further: lk agent init offers to install its agent skills and docs MCP server into Claude Code, Codex and Cursor (LiveKit docs). To check, open a fresh session and ask which environment variable holds your key. The agent should answer without searching.
Common mistakes
- Shipping llms.txt and an MCP server without running a task. Run one real task per interface first.
- Snippets with
...or missing imports. Publish whole files and run them in CI. - A key flow that ends in a dashboard click. Offer test keys and key creation by API.
- Testing only in Claude Code. Run the same task in Codex and Cursor too.
For a longer list, use the API agent-readiness playbook.
How to measure it across Claude Code, Codex and Cursor
Run the same task several times in each agent, in the same starter project, and record pass or fail, tool calls, errors and time. A change counts as better when the pass rate rises or tool calls fall on the same task and model for two runs in a row.
Results don't carry over between agents. Clerk's API scored 83 on Devtool Arena's Claude Code board, 76 on Codex and 95 on Cursor (October 2026). Devtool Arena publishes API boards for nine agents, including Muse Code, Grok and OpenCode, to compare your category against.
For one agent and one task, a shell loop with claude -p, codex exec and Cursor's agent -p is enough. Lightsage's Agent Usability is one option for more. It runs your own API, MCP or CLI task on real coding agents in sandboxes and returns pass or fail, full traces, errors and per-agent scores. Startup ($100/month) covers Claude Code and Codex, and Growth ($1,000/month) adds Cursor, OpenCode, Grok, Muse Code and others. How to run agent evals walks through the setup either way.
Frequently asked questions
How do I make my docs and llms.txt work better with Codex?
Serve every docs page as Markdown with complete, runnable code, and use llms.txt as an index of those pages. Put the key's environment variable and the package name on the quickstart itself, because Codex works from what it fetches. We think llms.txt helps agents find pages but doesn't decide whether Codex picks you.
How do I make my integration work better with Cursor?
Give Cursor users a project rule in .cursor/rules with the .mdc extension, or an AGENTS.md block, naming your package, key variable and common mistakes. Then run your integration task in Cursor itself, because Devtool Arena's October 2026 boards show the same API scoring differently on Cursor than on Claude Code or Codex.
How do I make my developer tool work better with OpenCode?
Apply the same fixes and put your agent instructions in AGENTS.md, which OpenCode reads before falling back to CLAUDE.md. OpenCode runs many models, so test with the ones your customers use. Devtool Arena publishes an OpenCode API board to compare against as of October 2026.
How do I make my MCP server work better with AI coding agents?
Name tools after the jobs developers do, keep descriptions short, and authenticate with an environment variable or header. Publish install commands for Claude Code, Codex and Cursor, and run one real task in each. Qdrant's MCP server scored 90 on Devtool Arena's Claude Code MCP board and 93 on its Codex MCP board in October 2026.
Is there a platform that runs API evals across OpenCode and Claude Code?
Yes. Lightsage's Agent Usability runs your API, MCP or CLI task on real coding agents, including OpenCode and Claude Code, and returns pass or fail with full traces. OpenCode comes with the Growth plan and the 7-day trial, and Devtool Arena publishes public API boards for both agents.
Next step
This week, run your quickstart in Claude Code, Codex and Cursor with only the key set, and fix the first step where one stops, using how to run agent evals.