Skip to content

Instantly share code, notes, and snippets.

@devded
Created March 5, 2026 22:47
Show Gist options
  • Select an option

  • Save devded/a7992a9c4f24567d77f03b1d6940337e to your computer and use it in GitHub Desktop.

Select an option

Save devded/a7992a9c4f24567d77f03b1d6940337e to your computer and use it in GitHub Desktop.

API Documentation Generator — Claude Code Instructions

Your Job

Whenever I add, update, or delete an API in this collection, your job is to automatically sync API_DOC.md (or a specified markdown file) to reflect the latest state of all APIs.


How to Detect Changes

Watch for any of these:

  • New .yml / .bru file added to any folder
  • Existing .yml / .bru file modified (endpoint, method, request body, response changed)
  • .yml / .bru file deleted
  • New group/folder created (= new API group)

When any of the above happens — re-read all collection files and regenerate the affected sections in the markdown doc.


Output File

Always write the final result to:

API_DOC.md

(Unless I tell you a different filename.)


Markdown Structure to Follow

Use this EXACT structure every time:

# [Project Name] — API Documentation

> 🌐 **Base URL:** `http://localhost:3000`

> 📅 **Last Updated:** [date]

---

### Table of Contents

- [Group Name](#group-name)
  - [API 01: Action Name](#api-01-action-name)
  - [API 02: Action Name](#api-02-action-name)

---

### Group Name

<a id="api-01-action-name"></a>
<details>
<summary style="padding: 8px; font-size: 16px; background-color: #f0f6ff; margin-bottom: 8px;">
  API 01: Action Name
</summary>

#### Endpoint:

```text
METHOD http://localhost:3000/api/path
```

#### Request:

```json
{
  "field": "value"
}
```

#### Response:

```json
{
  "field": "value"
}
```

</details>

---

Rules You Must Always Follow

API Numbering

  • Number APIs sequentially across the entire document: API 01, API 02, API 03, etc.
  • When a new API is added, assign the next available number
  • When an API is deleted, do NOT renumber existing ones — keep gaps to avoid breaking links
  • The number is part of the anchor ID (e.g. api-01-action-name)

TOC Anchors

  • Each <details> block must be preceded by <a id="api-XX-action-name"></a>
  • TOC links must match these anchor IDs exactly (lowercase, hyphens only)
  • Always regenerate the full TOC after any change
  • Group endpoints under their collection file/folder name

Toggleable Endpoints

  • Always wrap each endpoint inside <details> + <summary> HTML tags
  • Use this exact <summary> style: style="padding: 8px; font-size: 16px; background-color: #f0f6ff; margin-bottom: 8px;"
  • Summary text shows only the API number and action name: API 01: Action Name
  • Everything (endpoint, request, response) goes between <details> and </details>

Standard Response Structure

Every API response must follow this base structure — no exceptions:

{
  "error": false,
  "message": "...",
  "data": {}
}
  • error — always false for success responses
  • message — a short human-readable status string (e.g. "Profile updated successfully")
  • data — the actual response payload as an object/dict, or null if there is no payload to return

Sections Inside Each Endpoint

  • Endpoint: — always a ```text block showing METHOD full-url
  • Request: — a ```jsonc block with inline // comments on every field. For multipart/form-data, use ```text and list the fields with inline comments. Omit this section entirely for GET requests with no body.
  • Response: — a ```json block with the expected response body (no comments needed)

Inline Request Comments

Every field in the Request block must have a trailing // comment in this format:

"field": "value"   // required|optional | type | special notes (if any)
  • required/optionalrequired if the field must always be present, optional if it can be omitted
  • typestring, number, boolean, array, object, file
  • special notes — only add if there is a format rule, value constraint, or enum (e.g. YYYY-MM-DD format, min 6 characters, "host" or "driver", image (PNG, JPG))
  • Use jsonc (JSON with Comments) as the code block language for all Request blocks

Separators

  • Always use --- between each endpoint block
  • Always use --- after the TOC

Group Headers

  • Use ### (h3) for group section headers — no emojis
  • Example: ### Auth, ### Profile, ### User Documents

Last Updated

  • Always update the 📅 Last Updated date at the top when the file is modified

Collection File Format Reference

Bruno .bru format:

meta {
  name: Create User
  type: http
}

post {
  url: {{baseUrl}}/api/add
}

headers {
  Content-Type: application/json
}

body:json {
  {
    "name": "Dedar",
    "age": 25
  }
}

OpenCollection .yml format:

info:
  name: Create User
  type: http
  seq: 1

http:
  method: POST
  url: http://localhost:3000/api/add
  headers:
    - name: Authorization
      value: Bearer <token>
  body:
    type: json
    data: |
      {
        "name": "Dedar",
        "age": 25
      }

Parsing rules:

  • info.name / meta.name → endpoint action name
  • http.method / get|post|put|delete block → HTTP method
  • http.url / url field → full endpoint URL
  • http.body.data / body:json block → request body (parse as JSON)
  • http.body.type: multipart-form → use text block listing field names
  • File/folder name → API group name

Example Commands You Can Give Me

I added a new API in the Profile group called Delete Profile. Update the docs.
I updated the request body of Update Profile. Sync the markdown.
I deleted the Get Profile endpoint. Remove it from the docs.
Regenerate the full API doc from scratch based on all collection files.

Initial Setup Command

If running for the first time, say:

Read all .yml (or .bru) files in this project and generate the full API documentation in API_DOC.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment