api-gen

api-gen is a command for coding agents from halflength-ampleness75/claude-code-recipes. It costs 14 tokens per session (1,182 once invoked), scanned A, original, MIT.

A command for generating REST API endpoints from a written description. REST APIs let software exchange data through web addresses, while endpoints are the individual operations exposed by that API.

In plain words
What is it for?
Use it to create API endpoints for resources such as users, products, or orders. It can inspect the project’s framework, programming language, database tools, validation library, and file organization before generating the implementation.
Why use it?
It turns a feature description into routes, input checks, error handling, and tests that fit the project’s existing technology and conventions. For vague requests, it uses a standard create, read, update, and delete structure and asks for confirmation before writing code.

Command

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.

agentmods
npx agentmods add commands/halflength-ampleness75/claude-code-recipes/api-gen
Clone the repo
git clone --depth 1 https://github.com/halflength-ampleness75/claude-code-recipes

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-gen

README.md
[![agentmods](https://agentmods.dev/badge/commands/halflength-ampleness75/claude-code-recipes/api-gen.svg)](https://agentmods.dev/commands/halflength-ampleness75/claude-code-recipes/api-gen)
Your own site
<a href="https://agentmods.dev/commands/halflength-ampleness75/claude-code-recipes/api-gen"><img src="https://agentmods.dev/badge/commands/halflength-ampleness75/claude-code-recipes/api-gen.svg" alt="Measured on agentmods" height="20"></a>
Per session 14 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,182 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00014 $0.01182
Opus 5 $0.00007 $0.00591
Sonnet 5 $0.00003 $0.00236
Haiku 4.5 $0.00001 $0.00118

Measured 4d ago against content hash 270827cedfc6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

api-gen 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 4d 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-gen.md · 142 lines

How it starts

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

Generate production-quality REST API endpoints from a description provided in $ARGUMENTS.

Step 1 — Understand the Requirements

Parse $ARGUMENTS to determine:

  • Resource name (e.g., "users", "products", "orders")
  • Operations needed (CRUD by default, or specific operations if stated)
  • Fields and types (if specified, otherwise infer reasonable defaults)
  • Relationships to other resources (if mentioned)
  • Authentication requirements (if mentioned)

If $ARGUMENTS is vague (e.g., just "users"), generate a standard CRUD API with sensible defaults and ask the user to confirm the field list before writing code.

Step 2 — Detect the Project's Stack

Search the project to determine:

  1. Framework: Express, Fastify, Koa, NestJS, Django REST Framework, Flask, FastAPI, Gin, Echo, etc.
  2. Language: TypeScript, JavaScript, Python, Go, etc.
  3. Database/ORM: Prisma, TypeORM, Sequelize, SQLAlchemy, Django ORM, GORM, etc.
  4. Validation library: Zod, Joi, class-validator, Pydantic, marshmallow, etc.
  5. Project structure: Where do routes, controllers, models, and tests live?
  6. Existing patterns: Read 1-2 existing route files to match the project's conventions exactly.

If no existing backend framework is found, ask the user which stack to use. Do not assume.

Step 3 — Design the API

Create a specification before writing any code:

## API Design: [Resource]

Base path: /api/[resource]

| Method | Path            | Description          | Auth | Status Codes       |
|--------|-----------------|----------------------|------|--------------------|
| GET    | /               | List all (paginated) | Yes  | 200, 401           |
| GET    | /:id            | Get one by ID        | Yes  | 200, 401, 404      |
| POST   | /               | Create new           | Yes  | 201, 400, 401, 409 |
| PUT    | /:id            | Update by ID         | Yes  | 200, 400, 401, 404 |
| DELETE | /:id            | Delete by ID         | Yes  | 204, 401, 404      |

### Request/Response Shapes
(show the JSON schema for request body and response body)

Read the full file on GitHub · 142 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. 4d ago First seen · 142 lines · 14 tokens per session scan A 270827cedfc6

Subscribe to this mod's changes

api-gen is a command published in the GitHub repository halflength-ampleness75/claude-code-recipes (2 stars, last pushed 5d ago), licensed MIT. It adds 14 tokens to every session and 1,182 once invoked, about $0.0001 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.