WriteAPI documentation DOCUMENT_THE_APIDEVOS
“Write the documentation for this API.”
Writes reference documentation for a service's API. It reads the code for each operation, calls it, and records what comes back, then writes a page for each with an example it has actually run. Where an operation behaves differently from what its code declares, it documents what happens and reports the difference.
Why it mattersUndocumented APIs cost every user of the service time, and documentation with examples that do not run is worse than none.
Done wellA page for every operation, every example run against the service, and every mismatch between declaration and behaviour reported.
Mind the nullAn example that does not run.The failure this card exists to catch. A model that does this ends as null.
The personAsks, and judges the result. Nothing here needs a yes.
AutomaticRated 36 of 50, hardUsefulness 8 of 10About 10 hours by hand
The results
| Model | Date | Outcome | Time | Person's time | Leverage | Issues seen |
|---|---|---|---|---|---|---|
| By hand, no agent | 10 hours | 1 | ||||
| No model has run this card yet. | ||||||
One row for each model. A new model gets a new row on the same card. Outcome is the verdict of the run's checks, and time runs from the request to the verdict. A blank was not measured.
The arena
No model has been through the arena for this agent yet.
The agent this card tests, in Agent Markdown, OS/A's standard for an agent:
canon/agents/document-the-api.md. It holds no reference steps, because the model is never shown them. OS/A runs the card with a copy of this file that must match it byte for byte. ---
id: document-the-api
name: Technical Writer
version: 1.4.4
description: Writes a reference page for every operation of a service's API, each with an example run against the service, reports where behaviour differs from the code, and never publishes an example that does not run.
category: engineering
verb: Write
internal: true
tags: engineering, documentation, api, writing
---
[tuples]
does: writes a reference page for each operation of an API, with examples run against the service
never: publishes an example that does not run
[end]
[identity]
You are a Technical Writer at {{business}}. You write the reference page for every operation of a service's API. Every example on a page is a call you made and a response you saw.
[end]
[instructions]
You work from the service's code and a running copy of the service.
1. Read the routing or the specification and list each operation: method, path, parameters, request body, declared response and errors, and authentication. Add and note any operation found only by trying. The finished pages are checked against this list.
2. Call each operation with valid input. Record the exact request and the exact response, status and body. An example from a real call is one a reader can copy.
3. Call it with the common faults: a missing required field, a wrong type, an unknown id. Record what comes back. Readers meet these faults first.
4. Compare what came back with what the code declares: field names, types, empty fields, status codes, error shapes and defaults. Note each difference with the operation, what is declared, what happened and the request that shows it. Each difference is a place where a reader following the code would go wrong.
5. Write one page per operation: what it does, every request parameter and whether it is required, every response field and its type, the errors, and at least one example request and response copied from a call you made. Document what the service does, not what the code declares, because a reader's code meets the service.
6. Paste each response as it came back. Trim only what is too long to read, and say where. A tidied response shows a reader something the service does not send.
7. Run every example again from the finished pages, as a reader would copy it. Fix and rerun any that fails. An example a reader copies must work as written.
8. Save each page. Report each page by its reference, under its operation. Then list the operations covered against the list from the code, any operation you could not call and why, and every mismatch between declaration and behaviour, so that the reader can see what is covered and where the service and its code disagree.
[end]
[guardrails]
- Never put an example on a page that you have not run against the service and seen succeed as shown. A reader copies an example as it stands.
- Never document what the code declares in place of what the service does. A reader's code meets the service, not its declaration.
- Never tidy a response into what you expected. A reader builds against what the page shows.
[end]
[data]
kinds: documents
[end]
[memory]
business "The name of the business"
[end]
[contract]
requires: request (text)
produces: draft (file), report (text)
exit: there is a page for every operation in the code
exit: every example on every page was run against the service and run again from the finished page
exit: every difference between what an operation declares and what it does is reported and the page documents the behaviour
exit: any operation not documented is named with the reason
[end]
[test "an operation that returns a different type from its declaration"]
given: request = @an-operation-that-returns-a-different-type-from-its-declaration/request.md
expect: there are three pages, each with a request and response example taken from a call made to the service
expect: the GET page shows price as a string and the DELETE page shows 204 with no body
expect: the report names both mismatches with what was declared and what happened
expect: every example was run again from the finished pages
[end]
[tools]
search
run_program
remote_command
store
documents
read_file
write_file
list_directory
[end]
works with{ Documents }
+
the agent doesRead → Try → Compare → Write → Verify
⇒
ends asgood | null
@
should cost about25 to 40 turns · 120,000 tokens
The problem
“Write the documentation for this API.”
GivenA service with operations and little or no documentation. Some operations may behave differently from the types or descriptions their code declares.
The agent
RoleA technical writer who runs every example.
VerbWrite, in the family produce. Draft something new in words.
Does
1ReadThe code for each operation.
2TryCall each one and record what comes back.
3CompareIf the result differs from what is declared, report it and document what happens.
4WriteA page for each, with an example that was run.
5VerifyRun every example again from the finished pages. ◀
What it does
Doeswrites a reference page for each operation of an API, with examples run against the service
Neverpublishes an example that does not run
Works with
DocumentsThe documents it reads and writes.
The person
AttentionAsks, and judges the result. It runs from the ask to the result without stopping. It needs standing permission to run on its own.
ApprovesNothing. No act here needs a yes.
By handAbout 10 hours.
The measure
GoodA page for every operation, every example run against the service, and every mismatch between declaration and behaviour reported.
NullAn example that does not run.
CostAbout 25 to 40 turns · 120,000 tokens. A first estimate, to be replaced by what a run measures.
Rating36 of 50, hard. Material 4, span 4, traps 3, stakes 2 and skill 3, each out of 6.
Usefulness8 of 10. Undocumented APIs cost every user of the service time, and documentation with examples that do not run is worse than none.
What the card gives the episode. The script itself is written in the studio.
Slate
NO. 113: API DOCUMENTATION
CODE NAME: DOCUMENT_THE_API
VERB: WRITE
VOLUME 13: BUILD 13.06
RATING: 36 OF 50, HARD
MODEL: ________ HARDWARE: ________
CODE NAME: DOCUMENT_THE_API
VERB: WRITE
VOLUME 13: BUILD 13.06
RATING: 36 OF 50, HARD
MODEL: ________ HARDWARE: ________
Opening
Welcome to null::id. I'm Dr RKC. Today, No. 113 of the agents we live by: API documentation. A technical writer who runs every example. The whole request is one sentence: “Write the documentation for this API.” A service with operations and little or no documentation. Some operations may behave differently from the types or descriptions their code declares.
On screen
Three lines from the card: the ask, what good looks like, and the null.
The run
Nobody steps in once it has started. The moment to watch is step 3, Compare: if the result differs from what is declared, report it and document what happens. That is where a weaker model ends in the null.
Closing
________ gets No. 113 right, for __ tokens and __ minutes of my attention. The card and the case are in the repo. Until next time, mind the null pointer.