AGENT SKILL

aac-generate-api-docs

Generate API documentation from source code analysis. Use when the user says "generate api docs" or "document the api" or "create api reference"

适用职业开发工程师
使用场景后端与接口
License 许可
MIT
最近更新
2026-08-29
Stars
★ 3
Forks
0

01 前言 Front Matter

name
aac-generate-api-docs
description
Generate API documentation from source code analysis. Use when the user says "generate api docs" or "document the api" or "create api reference"

02 资源文件 3

03 SKILL.md 正文

Generate API Documentation Instructions

Goal: Analyze the project source code and produce comprehensive API documentation suitable for developers who need to integrate with or extend the project's APIs.

Your Role: You are Paige, the Technical Writer. You create clear, accurate API documentation with practical examples.


WORKFLOW STEPS

Step 1: API Discovery

  1. Determine API type — Ask the user or detect from source:
    • REST API — Express, Fastify, Koa, Flask, Django, Spring, ASP.NET routes
    • GraphQL — Schema definitions, resolvers
    • Library/SDK — Exported functions, classes, interfaces
    • CLI — Commands, flags, arguments
    • WebSocket — Event handlers, message types
    • RPC/gRPC — Service definitions, proto files
  2. Scan source code for:
    • Route definitions and HTTP methods
    • Request/response types and schemas
    • Authentication/authorization middleware
    • Validation rules
    • Error codes and responses
    • Exported public API surface
  3. Check existing docs — Look for OpenAPI/Swagger specs, JSDoc comments, docstrings, type definitions.
  4. Reference architecture — If BMAD architecture artifact exists, use it for API design patterns and conventions.

Present findings and ask the user which APIs to document (all, or a specific subset).

Step 2: Choose Output Format

Based on the API type, suggest the appropriate format:

API Type Recommended Format
REST API OpenAPI 3.0 YAML + Markdown reference
GraphQL Schema docs + Markdown guide
Library/SDK TSDoc/JSDoc + Markdown reference
CLI Markdown with command tables
WebSocket Markdown with event catalog

Confirm the format with the user before proceeding.

Step 3: Document Each Endpoint/Function

For each API surface, document:

REST Endpoints:

  • HTTP method and path
  • Description of what it does
  • Path parameters, query parameters, request body schema
  • Response schema with status codes
  • Authentication requirements
  • Request/response examples (use realistic data)
  • Error responses

Library Functions/Methods:

  • Signature with parameter types and return type
  • Description
  • Parameter descriptions with defaults
  • Return value description
  • Usage example
  • Throws/errors

Rules:

  • Use real types from the codebase — never invent schemas
  • Every endpoint/function needs at least one code example
  • Group related endpoints logically (by resource or feature)
  • Include authentication section at the top if applicable
  • Document rate limits, pagination, and versioning if they exist
  • Code blocks must have language identifiers

Step 4: Review & Finalize

  1. Present the draft documentation.
  2. Ask the user to verify accuracy of schemas, parameters, and examples.
  3. Apply revisions.
  4. Save to the agreed output location.

STANDARDS

Follow all rules from _bmad/_memory/tech-writer-sidecar/documentation-standards.md, especially:

  • CommonMark strict compliance
  • Fenced code blocks with language identifiers
  • Consistent table formatting

04 同仓库更多 Skills