Agent Skillscodeaholicguy/ai-devkit › document-code

document-code

GitHub

用于对代码入口点(文件、函数、API等)进行结构化分析,梳理依赖关系并生成文档。遵循先分析后文档原则,输出Markdown知识文档及可选HTML可视化卡片,支持Mermaid图表展示。

skills/document-code/SKILL.md codeaholicguy/ai-devkit

触发场景

用户要求记录或理解代码模块/文件/函数/API 用户请求映射代码结构或生成技术文档

安装

npx skills add codeaholicguy/ai-devkit --skill document-code -g -y
更多选项

不安装直接使用

npx skills use codeaholicguy/ai-devkit@document-code

指定 Agent (Claude Code)

npx skills add codeaholicguy/ai-devkit --skill document-code -a claude-code -g -y

安装 repo 全部 skill

npx skills add codeaholicguy/ai-devkit --all -g -y

预览 repo 内 skill

npx skills add codeaholicguy/ai-devkit --list

SKILL.md

Frontmatter
{
    "name": "document-code",
    "description": "AI DevKit · Document a code entry point with structured analysis, dependency mapping, and saved knowledge docs. Use when users ask to document, understand, or map code for a module, file, folder, function, or API."
}

Code Documentation Assistant

Build structured understanding of code entry points with an analysis-first workflow.

Hard Rule

  • Do not create documentation until the entry point is validated and analysis is complete.

Workflow

  1. Gather & Validate
  • Confirm entry point (file, folder, function, API), purpose, and desired depth.
  • Verify it exists; resolve ambiguity or suggest alternatives if not found.
  • Search for existing knowledge before analyzing: npx ai-devkit@latest memory search --query "<entry point name or purpose>"
  1. Collect Source Context
  • Summarize purpose, exports, key patterns.
  • Folders: list structure, highlight key modules.
  • Functions/APIs: capture signature, parameters, return values, error handling.
  1. Analyze Dependencies
  • Build dependency view up to depth 3, track visited nodes to avoid loops.
  • Categorize: imports, function calls, services, external packages.
  • Exclude external systems or generated code.
  1. Synthesize
  • Overview (purpose, language, high-level behavior).
  • Core logic, execution flow, patterns.
  • Error handling, performance, security considerations.
  • Improvements or risks discovered during analysis.
  1. Create Documentation
  • Normalize name to kebab-case (calculateTotalPricecalculate-total-price).
  • Create docs/ai/implementation/knowledge-{name}.md using the Output Template — this is the source of truth.
  • Include mermaid diagrams when they clarify flows or relationships.
  1. Offer HTML Artifact
  • After the markdown is written, ask the user once: "Also generate an HTML artifact for easier scanning? (y/N)".
  • If yes, generate sibling docs/ai/implementation/knowledge-{name}.html per the HTML Artifact spec. Regenerate from the markdown on subsequent runs; never hand-edit.
  • If no or no response, stop here — markdown alone is a complete result.

HTML Artifact

Generated only when the user opts in at step 6. A self-contained HTML file optimized for scanning, not reference reading. Complements the markdown — does not replace it.

Constraints:

  • Single file. Inline CSS. No build step. Only external asset allowed is mermaid via CDN (https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js).
  • Card-based grid layout, not a long scroll. The reader should capture structure at a glance.
  • Responsive down to laptop width. Print-friendly.
  • No interactivity beyond collapsible deep-dives and mermaid pan/zoom.

Section mapping (from the Output Template):

  • Overview → hero card: title, one-line purpose, language/type badges.
  • Implementation Details → grid of sectioned cards with short bullets, not prose.
  • Dependencies → graph card (mermaid) plus a categorized list (imports, calls, services, external).
  • Visual Diagrams → full-width rendered mermaid blocks.
  • Additional Insights → callout boxes, color-coded by kind (info, warning, risk).
  • Next Steps → checklist card.
  • Metadata → compact footer (date, depth, files touched).

Red Flags and Rationalizations

Rationalization Why It's Wrong Do Instead
"I already understand this code" Understanding ≠ documented understanding Write it down, then verify
"The code is self-documenting" Future readers lack your current context Capture the why, not just the what
"Dependencies are obvious" Implicit dependencies cause surprises Map them explicitly to depth 3

Validation

  • Documentation covers all Output Template sections.
  • If an HTML artifact was generated, it opens standalone in a browser, renders mermaid, and reflects the markdown content (no drift).
  • Summarize key insights, open questions, and related areas for deeper dives.
  • Confirm file path(s) and remind to commit.

Output Template

  • Overview
  • Implementation Details
  • Dependencies
  • Visual Diagrams (mermaid)
  • Additional Insights
  • Metadata (date, depth, files touched)
  • Next Steps

版本历史

  • d4caf56 当前 2026-07-05 15:22

同 Skill 集合

skills/agent-communication/SKILL.md
skills/agent-management/SKILL.md
skills/changelog/SKILL.md
skills/dev-commit/SKILL.md
skills/dev-design/SKILL.md
skills/dev-implementation/SKILL.md
skills/dev-lifecycle/SKILL.md
skills/dev-planning/SKILL.md
skills/dev-pr/SKILL.md
skills/dev-requirements/SKILL.md
skills/dev-review/SKILL.md
skills/dev-testing/SKILL.md
skills/dev-worktree/SKILL.md
skills/memory/SKILL.md
skills/security-review/SKILL.md
skills/simplify-implementation/SKILL.md
skills/structured-debug/SKILL.md
skills/task/SKILL.md
skills/tdd/SKILL.md
skills/technical-writer/SKILL.md
skills/verify/SKILL.md

元信息

文件数
0
版本
d4caf56
Hash
9e0e4108
收录时间
2026-07-05 15:22

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-15 06:44
浙ICP备14020137号-1 $访客地图$