Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.markapidown.net/llms.txt

Use this file to discover all available pages before exploring further.

Slash commands are markdown files that Claude Code and Codex CLI load as reusable agent workflows. MarkApiDown ships two: /mad for creating and enriching specs, and /mad-debug for diagnosing failures. You type the command in the agent chat, optionally pass an argument, and the agent follows a structured decision tree to completion — no manual prompting required.
Slash commands are only available in Claude Code and Codex CLI. If you use Cursor, GitHub Copilot, Antigravity, or OpenCode, use skills and MCP tools instead — they cover the same workflows through those agents’ native interfaces.

Install slash commands

Run the following command from your project root to install both /mad and /mad-debug:
mad install slashcmd
To install for a specific agent:
mad install slashcmd --agent=claude-code
mad install slashcmd --agent=codex-cli
Where files are written:
AgentInstall path
Claude Code.claude/commands/mad.md and .claude/commands/mad-debug.md
Codex CLI~/.codex/commands/mad.md and ~/.codex/commands/mad-debug.md
After installation, reload your agent session. The commands appear in the slash command picker immediately.

/mad — scan, enrich, and build flows

The /mad command routes to one of three modes depending on the argument you pass. You can invoke it by name, pass a target path, or describe a flow in plain language.
Trigger: /mad, /mad scan, or /mad <directory>Scan mode imports or creates missing endpoint specs for your project. The agent runs mad import project first — if it finds an OpenAPI spec, it converts that. Otherwise, it reads your source routes directly and authors specs using mad_author.What the agent does:
1

Auto-import

Runs mad import project <directory>. If MarkApiDown finds an OpenAPI spec, it converts it and skips to validation. If it generates stubs from a CLI export command (FastAPI, Spring Boot, etc.), it runs that first.
2

Read source routes

For any routes not covered by the import, the agent searches your source code for route definitions using patterns like @GetMapping, @app.get, router.get, and r.GET — adapting to your framework automatically.
3

Author specs

For each discovered route, the agent reads the handler and its type definitions, then calls mad_author with a complete spec: realistic request body, real field names, an expected response that matches the handler’s return type, and assertions covering the happy path and at least one error case.
4

Validate and index

Runs mad validate api-docs/ and then mad index to regenerate the index.
Example conversation:
You: /mad scan src/routes/
Agent: Running mad import project src/routes/…
       Found 3 unspecced routes: POST /orders, GET /orders/:id, DELETE /orders/:id
       Authoring specs…
       ✓ api-docs/apis/orders/post-create-order.md
       ✓ api-docs/apis/orders/get-order-by-id.md
       ✓ api-docs/apis/orders/delete-order.md
       Running mad validate api-docs/… all valid.
       Running mad index… done.

/mad-debug — diagnose failing specs

The /mad-debug command diagnoses a failing endpoint or pipeline. Pass it a spec file path, a pipeline file path, or a description of the endpoint that’s failing. The agent follows a structured diagnostic workflow and tells you exactly what to fix.
Trigger: /mad-debug <spec file> or /mad-debug <method> <path>The agent works through a fixed sequence of checks before drawing any conclusions.
1

Locate the spec

Searches for the spec file using mad_search (via MCP) or rg on the api-docs/apis/ directory. If no spec exists for the failing endpoint, it tells you to run /mad first.
2

Validate

Runs mad validate <file>. If validation fails, the error output identifies the exact field or section to fix.
3

Dry run

Runs mad exec <file> --env=dev --dry-run and checks the resolved request: correct baseUrl, auth header present, path params substituted, body shape correct.
4

Execute

Calls mad_exec via MCP with the spec and any required variables. Captures the full response.
5

Interpret

Applies the following decision table to the result and tells you what to do:
Exit / resultFix
Exit 2 — invalid specFix frontmatter field or ## Request http block
Exit 4 — network errorCheck baseUrl in _shared/env.md, confirm server is running
Exit 5 — secret detectedMove the value to .env.local or a MAD_* environment variable
Response mismatchUpdate ## Expected response if the API changed; otherwise fix the API
401 / 403Check authToken in env, verify auth: frontmatter matches the header
Unresolved variableCheck _shared/env.md for baseUrl, check .env.local for tokens
Example conversation:
You: /mad-debug api-docs/apis/orders/post-create-order.md
Agent: Validating spec… valid.
       Dry run… baseUrl resolved to http://localhost:3000, auth header present.
       Executing… HTTP 422 {"error": "items must not be empty"}
       Exit 0, but assertion failed: status expected 201, got 422.
       The request body is missing items. Check the ## Request block —
       the example body is {} instead of {"items": [{"sku": "…", "qty": 1}]}.
       Fix: update ## Request with a valid items array, then re-run.
The /mad-debug command never prints raw auth tokens. It masks all secret values as **** in its output. Always run debug commands against --env=dev. The command will ask for explicit confirmation before running anything against --env=prod.