documentation-audit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDocumentation Audit
文档审计
Overview
概述
Comprehensive documentation sync when drift is detected. Analyzes codebase and creates or updates all documentation artifacts to achieve full synchronization.
Core principle: Documentation must reflect reality. This skill brings them into alignment.
Announce at start: "I'm using documentation-audit to synchronize all documentation with the current codebase."
当检测到文档漂移时,进行全面的文档同步。分析代码库并创建或更新所有文档工件,以实现完全同步。
核心原则: 文档必须反映实际情况。本技能可使二者保持一致。
开始时需告知: "我正在使用documentation-audit技能,将所有文档与当前代码库同步。"
When This Skill Triggers
技能触发场景
This skill is invoked when:
| Trigger | Source |
|---|---|
| API documentation drift | |
| Features documentation drift | |
| Missing documentation files | Any documentation check |
| Manual request | User or orchestrator |
本技能在以下场景被调用:
| 触发条件 | 来源 |
|---|---|
| API文档漂移 | |
| 功能文档漂移 | |
| 缺失文档文件 | 任何文档检查 |
| 手动请求 | 用户或编排器 |
The Audit Process
审计流程
Phase 1: Discovery
阶段1:发现
bash
echo "=== Documentation Audit: Discovery Phase ==="bash
echo "=== Documentation Audit: Discovery Phase ==="Find all documentation files
Find all documentation files
DOC_FILES=$(find . -name ".md" -o -name ".yaml" -o -name "*.json" |
grep -E "(doc|api|swagger|openapi|feature|guide|readme)" |
grep -v node_modules | grep -v .git)
grep -E "(doc|api|swagger|openapi|feature|guide|readme)" |
grep -v node_modules | grep -v .git)
echo "Found documentation files:"
echo "$DOC_FILES"
DOC_FILES=$(find . -name ".md" -o -name ".yaml" -o -name "*.json" |
grep -E "(doc|api|swagger|openapi|feature|guide|readme)" |
grep -v node_modules | grep -v .git)
grep -E "(doc|api|swagger|openapi|feature|guide|readme)" |
grep -v node_modules | grep -v .git)
echo "Found documentation files:"
echo "$DOC_FILES"
Find API documentation
Find API documentation
API_DOC=$(find . -name "openapi.yaml" -o -name "swagger.yaml" -o -name "openapi.json" | head -1)
echo "API Documentation: ${API_DOC:-MISSING}"
API_DOC=$(find . -name "openapi.yaml" -o -name "swagger.yaml" -o -name "openapi.json" | head -1)
echo "API Documentation: ${API_DOC:-MISSING}"
Find features documentation
Find features documentation
FEATURE_DOC=$(find . -name "features.md" -o -name "FEATURES.md" | head -1)
echo "Features Documentation: ${FEATURE_DOC:-MISSING}"
undefinedFEATURE_DOC=$(find . -name "features.md" -o -name "FEATURES.md" | head -1)
echo "Features Documentation: ${FEATURE_DOC:-MISSING}"
undefinedPhase 2: API Audit
阶段2:API审计
If API endpoints exist:
bash
echo "=== Documentation Audit: API Phase ==="若存在API端点:
bash
echo "=== Documentation Audit: API Phase ==="Detect API framework
Detect API framework
detect_api_framework() {
if grep -r "express" package.json 2>/dev/null; then echo "express"; return; fi
if grep -r "fastify" package.json 2>/dev/null; then echo "fastify"; return; fi
if grep -r "@nestjs" package.json 2>/dev/null; then echo "nestjs"; return; fi
if grep -r "fastapi" requirements.txt 2>/dev/null; then echo "fastapi"; return; fi
if grep -r "flask" requirements.txt 2>/dev/null; then echo "flask"; return; fi
if [ -f "go.mod" ]; then echo "go"; return; fi
echo "unknown"
}
FRAMEWORK=$(detect_api_framework)
echo "Detected framework: $FRAMEWORK"
detect_api_framework() {
if grep -r "express" package.json 2>/dev/null; then echo "express"; return; fi
if grep -r "fastify" package.json 2>/dev/null; then echo "fastify"; return; fi
if grep -r "@nestjs" package.json 2>/dev/null; then echo "nestjs"; return; fi
if grep -r "fastapi" requirements.txt 2>/dev/null; then echo "fastapi"; return; fi
if grep -r "flask" requirements.txt 2>/dev/null; then echo "flask"; return; fi
if [ -f "go.mod" ]; then echo "go"; return; fi
echo "unknown"
}
FRAMEWORK=$(detect_api_framework)
echo "Detected framework: $FRAMEWORK"
Extract all endpoints from code
Extract all endpoints from code
extract_endpoints() {
case "$FRAMEWORK" in
express|fastify)
grep -rh "app.(get|post|put|delete|patch)" --include=".ts" --include=".js" |
sed "s/.app.([a-z])('([^'])'./\1 \2/" ;; nestjs) grep -rh "@(Get|Post|Put|Delete|Patch)" --include=".ts" |
sed "s/.@([A-Za-z])('([^'])'./\1 \2/" ;; fastapi) grep -rh "@app.(get|post|put|delete|patch)" --include=".py" |
sed "s/.@app.([a-z])("([^"])"./\1 \2/" ;; *) echo "Unknown framework - manual inspection required" ;; esac }
sed "s/.app.([a-z])('([^'])'./\1 \2/" ;; nestjs) grep -rh "@(Get|Post|Put|Delete|Patch)" --include=".ts" |
sed "s/.@([A-Za-z])('([^'])'./\1 \2/" ;; fastapi) grep -rh "@app.(get|post|put|delete|patch)" --include=".py" |
sed "s/.@app.([a-z])("([^"])"./\1 \2/" ;; *) echo "Unknown framework - manual inspection required" ;; esac }
ENDPOINTS=$(extract_endpoints)
echo "Found endpoints:"
echo "$ENDPOINTS"
undefinedextract_endpoints() {
case "$FRAMEWORK" in
express|fastify)
grep -rh "app.(get|post|put|delete|patch)" --include=".ts" --include=".js" |
sed "s/.app.([a-z])('([^'])'./\1 \2/" ;; nestjs) grep -rh "@(Get|Post|Put|Delete|Patch)" --include=".ts" |
sed "s/.@([A-Za-z])('([^'])'./\1 \2/" ;; fastapi) grep -rh "@app.(get|post|put|delete|patch)" --include=".py" |
sed "s/.@app.([a-z])("([^"])"./\1 \2/" ;; *) echo "Unknown framework - manual inspection required" ;; esac }
sed "s/.app.([a-z])('([^'])'./\1 \2/" ;; nestjs) grep -rh "@(Get|Post|Put|Delete|Patch)" --include=".ts" |
sed "s/.@([A-Za-z])('([^'])'./\1 \2/" ;; fastapi) grep -rh "@app.(get|post|put|delete|patch)" --include=".py" |
sed "s/.@app.([a-z])("([^"])"./\1 \2/" ;; *) echo "Unknown framework - manual inspection required" ;; esac }
ENDPOINTS=$(extract_endpoints)
echo "Found endpoints:"
echo "$ENDPOINTS"
undefinedPhase 3: Features Audit
阶段3:功能审计
bash
echo "=== Documentation Audit: Features Phase ==="bash
echo "=== Documentation Audit: Features Phase ==="Find user-facing components
Find user-facing components
find_features() {
React components in pages/views
find . -path "/pages/" -name ".tsx" -o -path "/views/" -name ".tsx" |
xargs -I {} basename {} .tsx 2>/dev/null
xargs -I {} basename {} .tsx 2>/dev/null
Feature flags
grep -rh "featureFlag|feature:" --include=".ts" --include=".tsx" |
sed "s/.['"]feature[':]\s['"]?([^'"])['"]?./\1/" 2>/dev/null
sed "s/.['"]feature[':]\s['"]?([^'"])['"]?./\1/" 2>/dev/null
Config options exposed to users
grep -rh "config.|settings." --include=".ts" |
grep -v "import|require" |
sed "s/.(config|settings).([a-zA-Z])./\2/" 2>/dev/null | sort -u }
grep -v "import|require" |
sed "s/.(config|settings).([a-zA-Z])./\2/" 2>/dev/null | sort -u }
FEATURES=$(find_features)
echo "Discovered features:"
echo "$FEATURES"
undefinedfind_features() {
React components in pages/views
find . -path "/pages/" -name ".tsx" -o -path "/views/" -name ".tsx" |
xargs -I {} basename {} .tsx 2>/dev/null
xargs -I {} basename {} .tsx 2>/dev/null
Feature flags
grep -rh "featureFlag|feature:" --include=".ts" --include=".tsx" |
sed "s/.['"]feature[':]\s['"]?([^'"])['"]?./\1/" 2>/dev/null
sed "s/.['"]feature[':]\s['"]?([^'"])['"]?./\1/" 2>/dev/null
Config options exposed to users
grep -rh "config.|settings." --include=".ts" |
grep -v "import|require" |
sed "s/.(config|settings).([a-zA-Z])./\2/" 2>/dev/null | sort -u }
grep -v "import|require" |
sed "s/.(config|settings).([a-zA-Z])./\2/" 2>/dev/null | sort -u }
FEATURES=$(find_features)
echo "Discovered features:"
echo "$FEATURES"
undefinedPhase 4: Generate Missing Documentation
阶段4:生成缺失的文档
Create OpenAPI if Missing
若缺失则创建OpenAPI文件
yaml
undefinedyaml
undefinedTemplate for new OpenAPI file
Template for new OpenAPI file
openapi: 3.0.3
info:
title: [PROJECT_NAME] API
description: |
API documentation for [PROJECT_NAME].
Generated by documentation-audit skill.
version: 1.0.0
contact:
name: API Support
servers:
- url: http://localhost:3000 description: Development server
- url: https://api.example.com description: Production server paths:
Endpoints will be added here
components:
schemas:
Error:
type: object
properties:
code:
type: string
message:
type: string
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
undefinedopenapi: 3.0.3
info:
title: [PROJECT_NAME] API
description: |
API documentation for [PROJECT_NAME].
Generated by documentation-audit skill.
version: 1.0.0
contact:
name: API Support
servers:
- url: http://localhost:3000 description: Development server
- url: https://api.example.com description: Production server paths:
Endpoints will be added here
components:
schemas:
Error:
type: object
properties:
code:
type: string
message:
type: string
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
undefinedCreate Features Doc if Missing
若缺失则创建功能文档
markdown
undefinedmarkdown
undefinedFeatures
Features
Generated by documentation-audit skill. Update with accurate descriptions.
Generated by documentation-audit skill. Update with accurate descriptions.
Overview
Overview
[Brief description of the product]
[Brief description of the product]
Core Features
Core Features
[Feature 1]
[Feature 1]
Description: [What it does]
How to Use:
- [Step 1]
- [Step 2]
Description: [What it does]
How to Use:
- [Step 1]
- [Step 2]
Additional Features
Additional Features
[List additional features discovered]
Last updated: [DATE]
Note: This file was auto-generated. Review and enhance descriptions.
undefined[List additional features discovered]
Last updated: [DATE]
Note: This file was auto-generated. Review and enhance descriptions.
undefinedPhase 5: Update Existing Documentation
阶段5:更新现有文档
For each discovered but undocumented item:
-
API Endpoints - Add to OpenAPI spec with:
- Path and method
- Parameters (from function signature)
- Request body schema (from DTO/type)
- Response schema (from return type)
- Basic description
-
Features - Add to features doc with:
- Feature name
- Basic description
- Placeholder for how-to-use
- Note to review and enhance
对于每个已发现但未记录的项:
-
API端点 - 添加到OpenAPI规范中,包含:
- 路径和方法
- 参数(来自函数签名)
- 请求体 schema(来自DTO/类型)
- 响应 schema(来自返回类型)
- 基本描述
-
功能 - 添加到功能文档中,包含:
- 功能名称
- 基本描述
- 使用方法占位符
- 需人工审核的说明
Phase 6: Validation
阶段6:验证
bash
echo "=== Documentation Audit: Validation Phase ==="bash
echo "=== Documentation Audit: Validation Phase ==="Validate OpenAPI
Validate OpenAPI
if [ -f "openapi.yaml" ]; then
yq '.' openapi.yaml > /dev/null 2>&1 && echo "OpenAPI: Valid YAML" || echo "OpenAPI: Invalid YAML"
fi
if [ -f "openapi.yaml" ]; then
yq '.' openapi.yaml > /dev/null 2>&1 && echo "OpenAPI: Valid YAML" || echo "OpenAPI: Invalid YAML"
fi
Validate Markdown
Validate Markdown
for file in docs/*.md; do
if [ -f "$file" ]; then
# Check for required sections
if ! grep -q "^## " "$file"; then
echo "WARNING: $file missing section headers"
fi
fi
done
for file in docs/*.md; do
if [ -f "$file" ]; then
# Check for required sections
if ! grep -q "^## " "$file"; then
echo "WARNING: $file missing section headers"
fi
fi
done
Check completeness
Check completeness
ENDPOINTS_DOCUMENTED=$(yq '.paths | keys | length' openapi.yaml 2>/dev/null || echo 0)
ENDPOINTS_IN_CODE=$(extract_endpoints | wc -l)
echo "Endpoints in code: $ENDPOINTS_IN_CODE"
echo "Endpoints documented: $ENDPOINTS_DOCUMENTED"
if [ "$ENDPOINTS_DOCUMENTED" -lt "$ENDPOINTS_IN_CODE" ]; then
echo "WARNING: Some endpoints still undocumented"
fi
undefinedENDPOINTS_DOCUMENTED=$(yq '.paths | keys | length' openapi.yaml 2>/dev/null || echo 0)
ENDPOINTS_IN_CODE=$(extract_endpoints | wc -l)
echo "Endpoints in code: $ENDPOINTS_IN_CODE"
echo "Endpoints documented: $ENDPOINTS_DOCUMENTED"
if [ "$ENDPOINTS_DOCUMENTED" -lt "$ENDPOINTS_IN_CODE" ]; then
echo "WARNING: Some endpoints still undocumented"
fi
undefinedAudit Report
审计报告
Post audit results to GitHub issue:
markdown
undefined将审计结果发布到GitHub Issue:
markdown
undefinedDocumentation Audit Complete
Documentation Audit Complete
Audit Date: [ISO_TIMESTAMP]
Triggered By: [api-documentation|features-documentation|manual]
Audit Date: [ISO_TIMESTAMP]
Triggered By: [api-documentation|features-documentation|manual]
Summary
Summary
| Category | Before | After | Status |
|---|---|---|---|
| API Endpoints | [N] undocumented | [N] documented | [COMPLETE/PARTIAL] |
| Features | [N] undocumented | [N] documented | [COMPLETE/PARTIAL] |
| General Docs | [N] missing | [N] created | [COMPLETE/PARTIAL] |
| Category | Before | After | Status |
|---|---|---|---|
| API Endpoints | [N] undocumented | [N] documented | [COMPLETE/PARTIAL] |
| Features | [N] undocumented | [N] documented | [COMPLETE/PARTIAL] |
| General Docs | [N] missing | [N] created | [COMPLETE/PARTIAL] |
Files Created
Files Created
- - API documentation
openapi.yaml - - Features documentation
docs/features.md
- - API documentation
openapi.yaml - - Features documentation
docs/features.md
Files Updated
Files Updated
- - Added [N] endpoints
openapi.yaml - - Added [N] features
docs/features.md
- - Added [N] endpoints
openapi.yaml - - Added [N] features
docs/features.md
Requires Manual Review
Requires Manual Review
- Verify API response schemas
- Enhance feature descriptions
- Add usage examples
- Review security documentation
- Verify API response schemas
- Enhance feature descriptions
- Add usage examples
- Review security documentation
Next Steps
Next Steps
- Review generated documentation
- Add detailed descriptions
- Include examples
- Validate with stakeholders
documentation-audit skill completed
undefined- Review generated documentation
- Add detailed descriptions
- Include examples
- Validate with stakeholders
documentation-audit skill completed
undefinedChecklist
检查清单
During audit:
- All documentation files discovered
- API framework detected
- All endpoints extracted from code
- All features extracted from code
- Missing documentation files created
- Existing documentation updated
- All files validated
- Audit report posted to issue
- Changes committed
审计期间需完成:
- 发现所有文档文件
- 检测到API框架
- 从代码中提取所有端点
- 从代码中提取所有功能
- 创建缺失的文档文件
- 更新现有文档
- 验证所有文件
- 将审计报告发布到Issue
- 提交更改
Quality Standards
质量标准
Generated documentation must meet:
| Standard | Requirement |
|---|---|
| Completeness | Every endpoint/feature listed |
| Validity | YAML/JSON validates |
| Structure | Required sections present |
| Placeholders | Clear markers for manual review |
| Attribution | Generated by skill noted |
生成的文档必须满足:
| 标准 | 要求 |
|---|---|
| 完整性 | 列出每个端点/功能 |
| 有效性 | YAML/JSON可通过验证 |
| 结构性 | 包含必要的章节 |
| 占位符 | 清晰标记需人工审核的内容 |
| 归属 | 标注由技能生成 |
Integration
集成
This skill is invoked by:
| Skill | When |
|---|---|
| API drift detected |
| Features drift detected |
| Documentation step |
This skill uses:
| Tool | Purpose |
|---|---|
| Discover code artifacts |
| Analyze existing docs |
| Create new docs |
| Update existing docs |
| Validate YAML |
| Validate JSON |
本技能由以下技能调用:
| 技能 | 调用时机 |
|---|---|
| 检测到API漂移时 |
| 检测到功能漂移时 |
| 文档步骤中 |
本技能使用以下工具:
| 工具 | 用途 |
|---|---|
| 发现代码工件 |
| 分析现有文档 |
| 创建新文档 |
| 更新现有文档 |
| 验证YAML |
| 验证JSON |