Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问clear审计异常

api-documentationAPI 文档

Agent Skill

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

总安装

3,873

周安装

163

GitHub Stars

40

下载量

1,356
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:api-documentation(API 文档)
来源仓库:https://github.com/bobmatnyc/claude-mpm-skills
仓库路径:skills/api-documentation
安装命令:
npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill api-documentation
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill api-documentation

简介

api-documentation 辅助梳理接口契约、错误码和集成规范。

  • 支持 OpenAPI 草稿生成、字段命名检查和响应结构验证。
  • 强调文档与代码一致性,避免凭空补充未定义字段。
  • 需结合现有 schema 或样例数据确保接口描述准确。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

API Documentation

Best practices for documenting APIs and code interfaces. Eliminates ~100-150 lines of redundant documentation guidance per agent.

Core Documentation Principles

  1. Document the why, not just the what - Explain intent and rationale
  2. Keep docs close to code - Inline documentation stays synchronized
  3. Document contracts, not implementation - Focus on behavior
  4. Examples are essential - Show real usage
  5. Update docs with code - Outdated docs are worse than no docs

Function/Method Documentation

Python (Docstrings)

def calculate_discount(price: float, discount_percent: float) -> float:
    """
    Calculate discounted price with percentage off.

    Args:
        price: Original price in dollars (must be positive)
        discount_percent: Discount percentage (0-100)

    Returns:
        Final price after discount, rounded to 2 decimals

    Raises:
        ValueError: If price is negative or discount > 100

    Examples:
        >>> calculate_discount(100.0, 20.0)
        80.0
        >>> calculate_discount(50.0, 50.0)
        25.0

    Note:
        Discount percent is capped at 100% (minimum price of 0)
    """
    if price < 0:
        raise ValueError("Price cannot be negative")
    if discount_percent > 100:
        raise ValueError("Discount cannot exceed 100%")

    discount_amount = price * (discount_percent / 100)
    return round(price - discount_amount, 2)

JavaScript (JSDoc)

/**
 * Calculate discounted price with percentage off
 *
 * @param {number} price - Original price in dollars (must be positive)
 * @param {number} discountPercent - Discount percentage (0-100)
 * @returns {number} Final price after discount, rounded to 2 decimals
 * @throws {Error} If price is negative or discount > 100
 *
 * @example
 * calculateDiscount(100.0, 20.0)
 * // returns 80.0
 *
 * @example
 * calculateDiscount(50.0, 50.0)
 * // returns 25.0
 */
function calculateDiscount(price, discountPercent) {
  if (price < 0) {
    throw new Error('Price cannot be negative');
  }
  if (discountPercent > 100) {
    throw new Error('Discount cannot exceed 100%');
  }

  const discountAmount = price * (discountPercent / 100);
  return Math.round((price - discountAmount) * 100) / 100;
}

Go (Godoc)

// CalculateDiscount calculates discounted price with percentage off.
//
// The function applies the given discount percentage to the original price
// and returns the final price rounded to 2 decimal places.
//
// Parameters:
//   - price: Original price in dollars (must be positive)
//   - discountPercent: Discount percentage (0-100)
//
// Returns the final price after discount.
//
// Returns an error if price is negative or discount exceeds 100%.
//
// Example:
//
//	finalPrice, err := CalculateDiscount(100.0, 20.0)
//	// finalPrice = 80.0
func CalculateDiscount(price, discountPercent float64) (float64, error) {
    if price < 0 {
        return 0, errors.New("price cannot be negative")
    }
    if discountPercent > 100 {
        return 0, errors.New("discount cannot exceed 100%")
    }

    discountAmount := price * (discountPercent / 100)
    return math.Round((price-discountAmount)*100) / 100, nil
}

API Endpoint Documentation

REST API (OpenAPI/Swagger)

openapi: 3.0.0
info:
  title: User Management API
  version: 1.0.0

paths:
  /users/{userId}:
    get:
      summary: Get user by ID
      description: Retrieves detailed information for a specific user
      parameters:
        - name: userId
          in: path
          required: true
          schema:
            type: integer
            minimum: 1
          description: Unique user identifier
      responses:
        '200':
          description: User found successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
              example:
                id: 123
                name: "John Doe"
                email: "john@example.com"
        '404':
          description: User not found
        '401':
          description: Unauthorized - authentication required

GraphQL

"""
Represents a user in the system
"""
type User {
  """Unique identifier for the user"""
  id: ID!

  """User's full name"""
  name: String!

  """User's email address (validated)"""
  email: String!

  """User's posts (paginated)"""
  posts(limit: Int = 10, offset: Int = 0): [Post!]!
}

"""
Query a specific user by ID
"""
type Query {
  """
  Get user by unique identifier

  Returns null if user not found
  """
  user(id: ID!): User
}

Class/Module Documentation

class UserManager:
    """
    Manages user accounts and authentication.

    This class provides a high-level interface for user management
    operations including creation, authentication, and profile updates.

    Attributes:
        db: Database connection instance
        cache: Redis cache for session management

    Example:
        >>> manager = UserManager(db=get_db(), cache=get_cache())
        >>> user = manager.create_user("john@example.com", "password")
        >>> authenticated = manager.authenticate("john@example.com", "password")
        >>> authenticated is not None
        True

    Thread Safety:
        This class is thread-safe. Multiple threads can safely call
        methods concurrently.

    Note:
        All passwords are automatically hashed using bcrypt before
        storage. Never pass pre-hashed passwords to methods.
    """

    def __init__(self, db: Database, cache: Cache):
        """
        Initialize UserManager with database and cache.

        Args:
            db: Database connection for persistent storage
            cache: Redis cache for session management

        Raises:
            ConnectionError: If unable to connect to database or cache
        """
        self.db = db
        self.cache = cache

README Documentation Structure

# Project Name

Brief description of what the project does (1-2 sentences).

## Features

- Key feature 1
- Key feature 2
- Key feature 3

## Installation

pip install project-name


## Quick Start

from project import MainClass

Simple usage example

client = MainClass(api_key="your-key") result = client.do_something() print(result)


## Configuration

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `api_key` | str | None | API authentication key |
| `timeout` | int | 30 | Request timeout in seconds |

## API Reference

See full [API Documentation](https://github.com/bobmatnyc/claude-mpm-skills/blob/HEAD/universal/web/api-documentation/docs/api.md)

### Main Methods

#### `do_something(param1, param2)`

Description of what this does.

**Parameters:**

- `param1` (str): Description of param1
- `param2` (int): Description of param2

**Returns:** Description of return value

**Example:**

result = client.do_something("value", 42)


## Contributing

See [CONTRIBUTING.md](https://github.com/bobmatnyc/claude-mpm-skills/blob/HEAD/universal/web/api-documentation/CONTRIBUTING.md)

## License

MIT License - see [LICENSE](https://github.com/bobmatnyc/claude-mpm-skills/blob/HEAD/universal/web/api-documentation/LICENSE)

Documentation Anti-Patterns

❌ Redundant Comments

# Bad: Obvious comment adds no value
i = i + 1  # Increment i

# Good: Comment explains WHY
i = i + 1  # Skip header row

❌ Outdated Documentation

# Bad: Comment doesn't match code
def get_users(limit=10):  # Comment says: Returns all users
    """Returns all users in the system."""  # But limit is 10!
    return User.query.limit(limit).all()

# Good: Keep docs synchronized
def get_users(limit=10):
    """
    Returns up to 'limit' users from the system.

    Args:
        limit: Maximum number of users to return (default: 10)
    """
    return User.query.limit(limit).all()

❌ Implementation Documentation

# Bad: Documents HOW (implementation)
def sort_users(users):
    """Uses bubble sort algorithm to sort users."""  # Don't care!
    ...

# Good: Documents WHAT (contract)
def sort_users(users):
    """Returns users sorted alphabetically by name."""
    ...

Documentation Tools

Python

  • Sphinx: Generate HTML docs from docstrings
  • pdoc: Simpler alternative to Sphinx
  • MkDocs: Markdown-based documentation

JavaScript

  • JSDoc: Generate HTML from JSDoc comments
  • TypeDoc: For TypeScript projects
  • Docusaurus: Full documentation websites

Go

  • godoc: Built-in documentation tool
  • pkgsite: Go package documentation

Rust

  • rustdoc: Built-in documentation with cargo doc

Quick Documentation Checklist

□ Public APIs have docstrings/comments
□ Parameters and return values documented
□ Exceptions/errors documented
□ Usage examples provided
□ Edge cases and limitations noted
□ README includes quick start
□ API reference available
□ Configuration options documented
□ Docs are up to date with code
□ Breaking changes documented

Remember

  • Code is read more than written - Good docs save time
  • Examples speak louder than descriptions - Show, don't just tell
  • The best docs are no docs - Write self-documenting code
  • Keep it DRY - Don't repeat what the code already says
  • Update docs with code - Outdated docs mislead developers

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

29.36%
按下载量换算398

Gemini CLI

21.53%
按下载量换算292

OpenCode

18.29%
按下载量换算248

Antigravity

12.18%
按下载量换算165

github-copilot

8.14%
按下载量换算110

windsurf

3.36%
按下载量换算46

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills