Agent skill

API Docs

by shenjingnan in shenjingnan/xiaozhi-client

“文档自动生成”

— description from SKILL.md by shenjingnan
MITAuto-check passedDevelopment

Install API Docs

skills CLI
$ npx skills add shenjingnan/xiaozhi-client --skill api-docs -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install shenjingnan/xiaozhi-client api-docs --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/shenjingnan/xiaozhi-client.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/api-docs .claude/skills/api-docs && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
api-docs
GitHub stars
341
Token cost
~2.4k tokens
SKILL.md length
160 words
Files
1
Skills in repo
16
Repo updated
First seen
Licence
MIT

At a glance

  • Works in 12 steps: 源代码分析 → MDX 文档生成 → 类型信息集成 → …
  • SKILL.md covers 技能能力, 解析规则, 生成流程 and 模板系统, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

About this skill

API Docs is a skill in shenjingnan/xiaozhi-client (341 stars). Its SKILL.md is about 2.4k tokens. Licence: MIT.

Workflow steps

12 steps, taken from the step headings in SKILL.md.

  1. 源代码分析
  2. MDX 文档生成
  3. 类型信息集成
  4. 示例代码生成
  5. 装饰器解析
  6. JSDoc 注释解析
  7. 路径别名解析
  8. 类型定义解析
  9. 源码扫描
  10. 信息提取
  11. 文档生成
  12. 导航更新

What it can do on your machine

Read from SKILL.md and the folder at commit fe3c382. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript, yaml, mdx, handlebars, bash and json).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

API Docs loads about 2.4k tokens when it runs. Until then it costs about 4 tokens; SKILL.md has 160 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~4
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from shenjingnan/xiaozhi-client at commit fe3c382, republished under its MIT licence (© shenjingnan). 160 words, ~2,413 tokens.

Download SKILL.mdSave it as .claude/skills/api-docs/SKILL.md (or your agent's skills folder).
name
api-docs
description
文档自动生成

我是 API 文档自动生成技能,专门从 xiaozhi-client 项目的源代码中提取 API 信息,生成符合 Nextra (Next.js) 标准的 MDX 文档,同时遵循务实开发理念。

技能使用原则
  • 保持文档质量,但避免过度复杂:生成清晰有用的文档,但不追求完美的文档结构
  • 实用功能优先,理论完美次之:解决实际的文档需求比完美的文档设计更重要
  • 简单解决方案优于复杂方案:优先选择直接有效的文档生成方式
  • 务实开发指导:评估文档的必要性,避免为了文档而文档

技能能力

1. 源代码分析

深度解析 TypeScript/JavaScript 源代码,提取 API 相关信息:

支持的代码元素
  • 类和方法:使用 @Tool 装饰器的方法
  • 函数接口:纯函数和工具方法
  • 类型定义:接口、类型别名、枚举
  • 参数信息:使用 @Param 装饰器的参数定义
  • 注释文档:JSDoc 格式的代码注释
解析能力
typescript
// 示例源代码
@Tool("控制灯光设备 - 支持通过名称控制灯光设备的开关、亮度和色温")
public async LightControl(
  @Param(z.string().describe("灯光设备名称"))
  name: string,
  @Param(z.enum(["turn_on", "turn_off"]).describe("控制动作"))
  action: "turn_on" | "turn_off",
  @Param(z.number().min(1).max(100).optional().describe("亮度百分比"))
  brightnessPct?: number
) {
  // 实现逻辑...
}

// 提取的信息
{
  name: "LightControl",
  description: "控制灯光设备 - 支持通过名称控制灯光设备的开关、亮度和色温",
  parameters: [
    {
      name: "name",
      type: "string",
      description: "灯光设备名称",
      required: true
    },
    {
      name: "action",
      type: "turn_on | turn_off",
      description: "控制动作",
      required: true
    },
    {
      name: "brightnessPct",
      type: "number",
      description: "亮度百分比",
      required: false,
      constraints: { min: 1, max: 100 }
    }
  ]
}
2. MDX 文档生成

基于提取的信息生成符合 xiaozhi-client 项目标准的 Nextra MDX 文档。

文档结构模板
mdx
# {ToolName}

## 工具介绍

{工具描述}

## 参数定义

| 参数 | 类型 | 范围 | 说明 |
|------|------|------|------|
{参数表格}

## 使用示例

### 基础用法
{基础示例代码}

### 高级功能
{高级示例代码}

## 错误信息

| 错误类型 | 错误信息 | 处理建议 |
|----------|----------|----------|
{错误表格}

## 返回值格式

### 成功响应
{成功响应示例}

### 错误响应
{错误响应示例}
3. 类型信息集成

从类型定义文件中提取相关类型信息,增强文档的完整性。

类型文档化
typescript
// 源类型定义
export interface LightControlParams {
  entity_id: string;
  action: LightActionType;
  brightness?: number;
  transition?: number;
}

export type LightActionType = "turn_on" | "turn_off" | "toggle";

// 生成的类型文档
### LightControlParams
灯光控制参数接口

| 属性 | 类型 | 必需 | 说明 |
|------|------|------|------|
| entity_id | string | 是 | 灯光设备实体ID |
| action | LightActionType | 是 | 控制动作类型 |
| brightness | number | 否 | 亮度百分比 (1-100) |
| transition | number | 否 | 渐变时间(秒) |

### LightActionType
灯光控制动作类型

**可选值:**
- `"turn_on"` - 开灯
- `"turn_off"` - 关灯
- `"toggle"` - 切换开关状态
4. 示例代码生成

基于 API 定义生成实际可运行的示例代码。

代码示例模板
typescript
// 基础示例
// 开启客厅主灯
LightControl("客厅主灯", "turn_on");

// 高级示例
// 开启灯光并设置亮度和渐变效果
LightControl("客厅主灯", "turn_on", 80, undefined, 2);

// 错误处理示例
try {
  const result = await LightControl("不存在的设备", "turn_on");
  console.log("操作成功:", result);
} catch (error) {
  console.error("操作失败:", error.message);
}

解析规则

1. 装饰器解析
typescript
// @Tool 装饰器解析
@Tool(description: string)
// 提取:工具描述信息

// @Param 装饰器解析
@Param(zSchema, description: string)
// 提取:参数类型、验证规则、描述信息
2. JSDoc 注释解析
typescript
/**
 * 通过名称控制灯光设备
 * @param name 灯光设备名称
 * @param action 控制动作 枚举值:turn_on | turn_off
 * @param brightnessPct 亮度百分比 (1-100),可选参数
 * @returns Promise<LightControlResult> 控制结果
 * @example
 * ```typescript
 * LightControl("书房小灯", "turn_on", 80);
 * ```
 */
// 提取:功能描述、参数说明、返回值、使用示例
3. 路径别名解析
typescript
// 支持 xiaozhi-client 项目的复杂路径别名系统
import { UnifiedMCPServer } from "@core/unified-server";
import { StartCommand } from "@cli/commands/start";
import { WebSocketAdapter } from "@transports/websocket";
import type { XiaozhiConfig } from "@/types";

// 提取:模块路径信息,用于生成导航和链接
// 支持:@cli/*, @core/*, @transports/*, @managers/*, @services/*, @types/*, @utils/*
4. 类型定义解析
typescript
// 接口定义
export interface LightControlResult {
  success: boolean;
  entity_id: string;
  action: string;
  changed_states?: HassState[];
  errors?: string[];
}

// 枚举定义
export enum LightActionType {
  TURN_ON = "turn_on",
  TURN_OFF = "turn_off"
}

// 类型别名
export type DeviceState = "on" | "off" | "unavailable";
// 提取:完整的类型信息和文档

生成流程

1. 源码扫描
typescript
interface ScanOptions {
  include: string[];      // 包含的文件模式
  exclude: string[];      // 排除的文件模式
  tools: boolean;         // 是否扫描工具方法
  types: boolean;         // 是否扫描类型定义
  examples: boolean;      // 是否生成示例
}

const scanResult = scanSourceCode(options);
2. 信息提取
typescript
interface ExtractedInfo {
  tools: ToolInfo[];
  types: TypeInfo[];
  examples: ExampleInfo[];
  relationships: RelationshipInfo[];
}

const extractedInfo = extractApiInfo(scanResult);
3. 文档生成
typescript
interface GenerationOptions {
  template: string;       // 文档模板路径
  output: string;         // 输出目录
  format: 'mdx' | 'md';   // 输出格式
  navigation: boolean;    // 是否更新导航
}

const generatedDocs = generateDocumentation(extractedInfo, options);
4. 导航更新
typescript
// 自动更新 meta.json 文件(Nextra 导航配置)
function updateNavigation(docs: GeneratedDoc[]): void {
  const metaJsonPath = 'docs/meta.json';
  const currentConfig = readFileSync(metaJsonPath, 'utf8');
  const updatedConfig = insertIntoNavigation(currentConfig, docs);
  writeFileSync(metaJsonPath, updatedConfig);
}

function insertIntoNavigation(config: string, docs: GeneratedDoc[]): string {
  const parsed = JSON.parse(config);
  // 根据文档类型插入到合适的导航位置
  // MCP 工具文档 -> 使用指南,API 参考 -> 开发指南
  return JSON.stringify(parsed, null, 2);
}

模板系统

1. 工具文档模板
handlebars
# {{toolName}}

## 工具介绍

{{description}}

## 参数定义

| 参数 | 类型 | 范围 | 说明 |
|------|------|------|------|
{{#each parameters}}
| {{name}} | {{type}} | {{constraints}} | {{description}} |
{{/each}}

## 使用示例

{{#each examples}}
### {{title}}
```typescript
{{code}}

{{/each}}

{{#if errors}}

错误信息

错误类型错误信息处理建议
{{#each errors}}
{{type}}{{message}}{{suggestion}}
{{/each}}
{{/if}}

### 2. 类型文档模板
```handlebars
## {{typeName}}

{{description}}

{{#if properties}}
### 属性

| 属性 | 类型 | 必需 | 说明 |
|------|------|------|------|
{{#each properties}}
| {{name}} | {{type}} | {{required}} | {{description}} |
{{/each}}
{{/if}}

{{#if values}}
### 可选值

{{#each values}}
- `{{value}}` - {{description}}
{{/each}}
{{/if}}
3. 示例代码模板
typescript
// 基础用法示例
function generateBasicExample(tool: ToolInfo): string {
  const requiredParams = tool.parameters.filter(p => p.required);
  const paramValues = requiredParams.map(p => getExampleValue(p));

  return `${tool.name}(${paramValues.join(', ')});`;
}

// 完整功能示例
function generateAdvancedExample(tool: ToolInfo): string {
  const allParams = tool.parameters;
  const paramValues = allParams.map(p => getExampleValue(p));

  return `const result = await ${tool.name}(${paramValues.join(', ')});\n` +
         `console.log('操作结果:', result);`;
}

配置选项

1. 全局配置
typescript
interface ApiDocConfig {
  input: {
    sourceDir: string;        // 源码目录
    patterns: string[];       // 文件匹配模式
  };
  output: {
    docsDir: string;          // 文档输出目录
    format: 'mdx' | 'md';     // 输出格式
    templateDir?: string;     // 自定义模板目录
  };
  generation: {
    includeExamples: boolean; // 是否生成示例
    includeTypes: boolean;    // 是否包含类型文档
    updateNavigation: boolean; // 是否更新导航
  };
  formatting: {
    codeTheme: string;        // 代码主题
    tableStyle: 'github' | 'gitlab'; // 表格样式
    useEmojis: boolean;       // 是否使用表情符号
  };
}
2. 工具特定配置
typescript
interface ToolConfig {
  name: string;
  category: string;
  tags: string[];
  examples: ExampleConfig[];
  relatedTools: string[];
  deprecated?: boolean;
  experimental?: boolean;
}

质量保证

1. 文档验证
typescript
interface ValidationResult {
  valid: boolean;
  errors: ValidationError[];
  warnings: ValidationWarning[];
  score: number; // 0-100 文档质量评分
}

function validateDocumentation(docs: GeneratedDoc[]): ValidationResult {
  // 检查文档完整性
  // 验证链接有效性
  // 检查代码示例正确性
  // 评估文档质量
}
2. 自动化测试
typescript
// 测试生成的示例代码
async function testExamples(examples: CodeExample[]): Promise<TestResult[]> {
  const results = [];

  for (const example of examples) {
    try {
      const result = await executeExample(example);
      results.push({ example, success: true, result });
    } catch (error) {
      results.push({ example, success: false, error });
    }
  }

  return results;
}
3. 持续同步
typescript
// 监听源码变化,自动更新文档
function setupDocumentationSync(): void {
  watch(sourceFiles, (filePath) => {
    const changes = detectChanges(filePath);
    if (changes.affectsApi) {
      regenerateDocumentation(changes);
    }
  });
}

集成方式

1. CLI 命令
bash
# 生成所有API文档
api-docs generate

# 生成特定工具的文档
api-docs generate --tool LightControl

# 监听模式,自动更新
api-docs generate --watch

# 验证文档质量
api-docs validate

# 生成覆盖率报告
api-docs coverage
2. 构建集成
json
{
  "scripts": {
    "docs:generate": "api-docs generate",
    "docs:validate": "api-docs validate",
    "docs:watch": "api-docs generate --watch"
  }
}
3. CI/CD 集成
yaml
# GitHub Actions 示例
- name: Generate API Documentation
  run: |
    api-docs generate
    api-docs validate

- name: Deploy Documentation
  run: |
    # 部署生成的文档到文档站点

最佳实践

1. 文档编写规范
  • 使用清晰简洁的描述
  • 提供完整的使用示例
  • 包含错误处理说明
  • 保持文档与代码同步
2. 示例代码要求
  • 代码必须可运行
  • 包含常见使用场景
  • 展示最佳实践
  • 有适当的错误处理
3. 版本管理
  • 记录API变更历史
  • 标记废弃功能
  • 提供迁移指南
  • 维护向后兼容性

通过这个技能,可以确保 xiaozhi-client 项目的 API 文档始终保持最新、准确和高质量,提升开发者体验和项目可维护性。特别适配 Nextra (Next.js) 文档系统和项目的复杂路径别名结构。

Nextra 特定说明

导航配置
  • 使用 docs/meta.json 管理文档导航结构
  • 支持多层级嵌套和分组
  • 自动根据文件路径生成导航树
文档放置
  • MCP 工具文档:docs/content/guides/mcp-tools/*.mdx
  • API 参考文档:docs/content/api/reference/*.mdx
  • 开发指南:docs/content/development/*.mdx
Front Matter 支持
yaml
---
title: 工具名称
description: 工具描述
---

© shenjingnan, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/api-docs of shenjingnan/xiaozhi-client.

Open the folder on GitHubat commit fe3c382

Compare with similar skills

API Docs next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

API Docs compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
API Docs this skillshenjingnan/xiaozhi-client341—~2.4kAutomated safety check: PassMIT
Diagram Designcathrynlavery/diagram-design45k1 repos~7.5kAutomated safety check: PassMIT
Simple Englishmoeru-ai/airi50k2 repos~4.6kAutomated safety check: PassMIT
Get API Docs with chubandrewyng/context-hub14k2 repos~775Automated safety check: PassMIT
Doc SyncJetBrains/ideavim10k2 repos~2.6kAutomated safety check: PassMIT
Mailspring App ScreenshotsFoundry376/Mailspring18k—~1.5kAutomated safety check: PassGPL-3.0

Similar skills

  • Diagram Design

    cathrynlavery/diagram-design

    Creates branded diagrams, from architecture, flowchart and sequence to charts and maps, as self-contained HTML with inline SVG, with import from draw.io, Mermaid and Excalidraw.

    45k GitHub starsUsed in 1 repo~7.5k tokens
    DevelopmentAuto-check passed
  • Simple English

    moeru-ai/airi

    Write or rewrite technical text with the rules of ASD-STE100 Simplified Technical English so it is clear, unambiguous, and free of AI slop.

    50k GitHub starsUsed in 2 repos~4.6k tokens
    DevelopmentAuto-check passed
  • Get API Docs with chub

    andrewyng/context-hub

    Fetches current documentation for third-party APIs and SDKs with the chub CLI before the agent writes code against them, instead of relying on remembered API shapes.

    14k GitHub starsUsed in 2 repos~775 tokens
    DevelopmentAuto-check passed
  • Doc Sync

    JetBrains/ideavim

    Official

    Keeps IdeaVim documentation in sync with code changes. An agent skill from JetBrains/ideavim.

    10k GitHub starsUsed in 2 repos~2.6k tokens
    DevelopmentAuto-check passed
  • Mailspring App Screenshots

    Foundry376/Mailspring

    Captures screenshots of the running Mailspring dev app for docs, PRs or visual checks by launching it with a debugging port, driving the UI and clipping to an element.

    18k GitHub stars~1.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Draw.io Diagram Studio

    Agents365-ai/drawio-skill

    Creates and edits editable draw.io diagrams from descriptions, code, infrastructure files, SQL and API schemas, with sync, review, test and export tools.

    10k GitHub stars~2.4k tokensUpdated 6 days ago
    DevelopmentAuto-check: notes

More from shenjingnan/xiaozhi-client

All 16 skills in this repo
  • E2E Coverage Analyzer

    shenjingnan/xiaozhi-client

    分析当前分支 git 改动,检查 e2e 测试用例覆盖情况,并可补充缺失的测试用例. An agent skill from shenjingnan/xiaozhi-client.

    341 GitHub stars~954 tokensUpdated 1 mo ago
    Auto-check passed
  • Fix Comment

    shenjingnan/xiaozhi-client

    GitHub 评论修复技能,用于获取 PR 的 Copilot 评论并分析修复问题. An agent skill from shenjingnan/xiaozhi-client.

    341 GitHub stars~873 tokensUpdated 1 mo ago
    Auto-check passed
  • CI Validator

    shenjingnan/xiaozhi-client

    CI检查验证和质量保障

    341 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed
  • Commit

    shenjingnan/xiaozhi-client

    生成代码评审友好的 commit 信息

    341 GitHub stars~1.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Dev Workflow Checker

    shenjingnan/xiaozhi-client

    开发流程检查技能,确保代码修改后执行必要的质量检查

    341 GitHub stars~464 tokensUpdated 1 mo ago
    Auto-check passed
  • Docs Creator

    shenjingnan/xiaozhi-client

    文档创建技能,用于创建标准化的项目文档

    341 GitHub stars~614 tokensUpdated 1 mo ago
    Auto-check passed

Categories

Questions about API Docs

How do I install API Docs in Claude Code?

Run `npx skills add shenjingnan/xiaozhi-client --skill api-docs -a claude-code`. Or copy the skill folder (.agents/skills/api-docs in shenjingnan/xiaozhi-client) into .claude/skills/api-docs in your project. Claude Code loads it when a task matches its description.

How do I install API Docs in Codex?

Run `npx skills add shenjingnan/xiaozhi-client --skill api-docs -a codex`. Or copy the skill folder (.agents/skills/api-docs in shenjingnan/xiaozhi-client) into .agents/skills/api-docs in your project. Codex loads it when a task matches its description.

Can I use API Docs in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add shenjingnan/xiaozhi-client --skill api-docs -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/api-docs, .gemini/skills/api-docs, .github/skills/api-docs and .opencode/skills/api-docs in your project.

What does API Docs need to run?

SKILL.md names no scripts, command-line tools or credentials: API Docs is instructions for the agent only.

Does API Docs access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is API Docs safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does API Docs use?

API Docs is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does API Docs use?

About 2.4k tokens (SKILL.md is roughly 9.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to API Docs?

Skills that share tags, products or a category with API Docs: Diagram Design (cathrynlavery/diagram-design, 45k stars), Simple English (moeru-ai/airi, 50k stars), Get API Docs with chub (andrewyng/context-hub, 14k stars) and Doc Sync (JetBrains/ideavim, 10k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains API Docs?

shenjingnan (a GitHub user) maintains it in shenjingnan/xiaozhi-client, which has 341 GitHub stars. The repository holds 16 skills in this directory. The repository was last updated on September 3, 2026.

Source: shenjingnan/xiaozhi-client on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.