api-doc

api-doc is a command for Claude Code from mertjane/awesome-claude-commands. It costs 41 tokens per session (1,076 once invoked), scanned A, original, MIT.

A command that reads backend source code and creates an OpenAPI 3.0 YAML file. OpenAPI is a standard format for describing an HTTP API's routes, inputs, outputs, and authentication.

In plain words
What is it for?
Use it to document Express, Fastify, Koa, or Hapi applications, including route paths, HTTP methods, route groups, server details, and detected authentication middleware.
Why use it?
It removes the need to document every backend route by hand and helps keep API documentation based on the code that actually exists.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it to document Express, Fastify, Koa, or Hapi applications, including route paths, HTTP methods, route groups, server details, and detected authentication middleware.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/mertjane/awesome-claude-commands/api-doc
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/mertjane/awesome-claude-commands

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for api-doc

README.md
[![agentmods](https://agentmods.dev/badge/commands/mertjane/awesome-claude-commands/api-doc.svg)](https://agentmods.dev/commands/mertjane/awesome-claude-commands/api-doc)
Your own site
<a href="https://agentmods.dev/commands/mertjane/awesome-claude-commands/api-doc"><img src="https://agentmods.dev/badge/commands/mertjane/awesome-claude-commands/api-doc.svg" alt="Measured on agentmods" height="20"></a>
Per session 41 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,076 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00041 $0.01076
Opus 5 $0.00020 $0.00538
Sonnet 5 $0.00008 $0.00215
Haiku 4.5 $0.00004 $0.00108

Measured 7d ago against content hash 93b117d2f121, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

api-doc scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/api-doc.md · 128 lines

How it starts

The opening of the file, as written. The whole thing — 128 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Generate API Documentation

Analyze the project's backend source code to produce a complete OpenAPI 3.0.0 specification and save it to docs/openapi.yaml (or the path provided in $ARGUMENTS if specified).

Step 1 — Detect Framework and Project Info

Read package.json:

  • Extract name, version, description fields
  • Detect the framework from dependencies:
    • express → Express.js
    • fastify → Fastify
    • koa → Koa.js
    • @hapi/hapi → Hapi.js
    • None found → treat as Generic HTTP API

Step 2 — Read the Main Entry File

Search for and read the first match from (in order): src/index.js, src/app.js, src/server.js, index.js, app.js, server.js

Detect:

  • PORT value (e.g. process.env.PORT || 3000)
  • Route prefixes (e.g. app.use("/api/v1", ...) → base path /api/v1)
  • Auth middleware usage (e.g. verifyToken, authenticate, authMiddleware, passport)
  • All registered router prefixes

Step 3 — Discover Route Files

Use Glob to find route files:

  • **/routes/**/*.{js,ts}
  • **/router/**/*.{js,ts}
  • **/controllers/**/*.{js,ts}
  • **/api/**/*.{js,ts} (exclude node_modules)

Read each route file and extract:

HTTP Methods and Paths:

  • router.get("/path", ...) → GET /path
  • router.post("/path", ...) → POST /path
  • router.put("/:id", ...) → PUT /{id}
  • router.patch("/:id", ...) → PATCH /{id}
  • router.delete("/:id", ...) → DELETE /{id}

Path Parameters:

  • :id{id} (integer, required)
  • :slug{slug} (string, required)
  • :userId{userId} (string, required)

Request Body:

  • Look at req.body destructuring: const { email, password } = req.body
  • If validation exists (joi, zod, yup), read the schema
  • Extract field names and types

Response Structure:

  • Look at res.json({...}) output shapes
  • Status codes: res.status(201), res.status(404), etc.
  • Extract response object fields

Auth Protection:

  • Does the route handler have middleware? router.get("/", authMiddleware, handler)
  • If the middleware name relates to auth → this endpoint is protected

Read the full file on GitHub · 128 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 128 lines · 41 tokens per session scan A 93b117d2f121

Subscribe to this mod's changes

api-doc is a command published in the GitHub repository mertjane/awesome-claude-commands (2 stars, last pushed 6mo ago), licensed MIT. It adds 41 tokens to every session and 1,076 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.