DocSync:自动化文档与偏差检测 - Openclaw Skills
作者:互联网
2026-04-06
什么是 DocSync?
DocSync 弥合了源代码与文档之间的鸿沟。通过 tree-sitter 提供的先进 AST 解析,它能够理解代码结构,从而自动生成准确的 README 和 API 参考。与静态生成器不同,它通过 git 钩子与开发工作流深度集成,确保文档永不过时。这使其成为维护代码库健康和提升开发效率最强大的 Openclaw Skills 之一。
该工具采用本地优先的设计理念,确保所有代码分析均在您的机器上完成。无论您是使用免费版生成 README 的个人开发者,还是需要架构图和入职指南的大型团队,DocSync 都能为动态文档提供可扩展的解决方案。
下载入口:https://github.com/openclaw/skills/tree/main/skills/suhteevah/docsync
安装与下载
1. ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install docsync
2. 手动安装
将技能文件夹复制到以下位置之一
全局模式~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置
3. 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 docsync。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
DocSync 应用场景
- 自动为新文件或目录生成 README 或 API 文档。
- 检测文档偏差,识别因代码更改而导致现有的文档过时的情况。
- 使用集成的 git 钩子在提交过程中强制执行文档标准。
- 为新团队成员生成高层架构图和入职指南。
- 在复杂的多语言代码库中映射模块关系和数据流。
- 该技能使用 tree-sitter 语法解析目标源文件,以提取类、函数和接口等特定符号。
- 它应用专门的模板将提取的代码符号转换为易于阅读的 Markdown 文档。
- 对于偏差检测,它通过 difftastic 的语义差异比对,将当前代码符号与现有文档进行比较。
- 集成 lefthook 后,它会拦截 git 提交,以验证文档是否与暂存的代码更改匹配。
- 它提供自动化修复路径,无需手动编写即可重新生成过时的文档块。
DocSync 配置指南
要在您的 Openclaw Skills 中开始使用 DocSync,请确保已安装必要的依赖项:
# 通过 Homebrew 安装所需的工具
brew install lefthook tree-sitter difftastic
要为特定文件或目录生成文档:
bash "/scripts/docsync.sh" generate
对于专业版功能,请将您的许可证密钥添加到位于 ~/.openclaw/openclaw.json 的 Openclaw 配置文件中。
DocSync 数据架构与分类体系
DocSync 使用以下结构组织其输出和配置:
| 功能 | 数据组织 |
|---|---|
| 输出目录 | 可通过 outputDir 配置(默认为 docs/)。 |
| 符号提取 | 使用 tree-sitter AST 映射来识别函数、类和类型。 |
| 偏差报告 | 生成具有严重级别的报告:严重、警告和信息。 |
| 配置 | 存储在全局 Openclaw 配置的 docsync 键下。 |
| 排除项 | 支持 excludePatterns 中的 glob 模式,以忽略 node_modules 或构建产物。 |
name: docsync
description: Auto-generate docs from code and detect documentation drift via git hooks. Free README gen + paid living docs.
homepage: https://docsync.pages.dev
metadata:
{
"openclaw": {
"emoji": "??",
"primaryEnv": "DOCSYNC_LICENSE_KEY",
"requires": {
"bins": ["git", "bash"]
},
"install": [
{
"id": "lefthook",
"kind": "brew",
"formula": "lefthook",
"bins": ["lefthook"],
"label": "Install lefthook (git hooks manager)"
},
{
"id": "tree-sitter",
"kind": "brew",
"formula": "tree-sitter",
"bins": ["tree-sitter"],
"label": "Install tree-sitter (code parser)"
},
{
"id": "difftastic",
"kind": "brew",
"formula": "difftastic",
"bins": ["difft"],
"label": "Install difftastic (semantic diff)"
}
],
"os": ["darwin", "linux", "win32"]
}
}
user-invocable: true
disable-model-invocation: false
DocSync — Living Documentation for Your Codebase
DocSync generates documentation from your code and keeps it in sync automatically. It uses tree-sitter for multi-language AST parsing, lefthook for git hook integration, and difftastic for semantic change detection.
Commands
Free Tier (No license required)
docsync generate
Generate a one-shot README or API doc for a single file or directory.
How to execute:
bash "/scripts/docsync.sh" generate
What it does:
- Parses the target file(s) with tree-sitter to extract symbols (functions, classes, exports, types, interfaces)
- Applies the appropriate template from
/templates/ - Generates a markdown documentation file alongside the source
Example usage scenarios:
- "Generate docs for src/utils/auth.ts" → runs
docsync generate src/utils/auth.ts - "Document this whole directory" → runs
docsync generate src/api/ - "Create a README for this project" → runs
docsync generate .
Pro Tier ($29/user/month — requires DOCSYNC_LICENSE_KEY)
docsync drift [directory]
Scan for documentation drift — find where code has changed but docs haven't been updated.
How to execute:
bash "/scripts/docsync.sh" drift [directory]
What it does:
- Validates license key from config
- Parses all source files with tree-sitter
- Compares extracted symbols against existing documentation
- Reports: new undocumented symbols, changed signatures with stale docs, deleted symbols still in docs
- Outputs a drift report with severity levels (critical/warning/info)
docsync hooks install
Install git hooks that automatically check for doc drift on every commit.
How to execute:
bash "/scripts/docsync.sh" hooks install
What it does:
- Validates Pro+ license
- Copies lefthook config to project root
- Installs lefthook pre-commit hook
- On every commit: analyzes staged files, blocks commit if critical drift detected, offers auto-regen
docsync hooks uninstall
Remove DocSync git hooks.
bash "/scripts/docsync.sh" hooks uninstall
docsync auto-fix [directory]
Auto-regenerate stale documentation for files with detected drift.
bash "/scripts/docsync.sh" auto-fix [directory]
Team Tier ($49/user/month — requires DOCSYNC_LICENSE_KEY with team tier)
docsync onboarding [directory]
Generate a comprehensive onboarding guide for new developers.
bash "/scripts/docsync.sh" onboarding [directory]
docsync architecture [directory]
Generate architecture documentation showing module relationships and data flow.
bash "/scripts/docsync.sh" architecture [directory]
Supported Languages
DocSync uses tree-sitter grammars and supports:
- JavaScript / TypeScript (including JSX/TSX)
- Python
- Rust
- Go
- Java
- C / C++
- Ruby
- PHP
- C#
- Swift
- Kotlin
Configuration
Users can configure DocSync in ~/.openclaw/openclaw.json:
{
"skills": {
"entries": {
"docsync": {
"enabled": true,
"apiKey": "YOUR_LICENSE_KEY_HERE",
"config": {
"outputDir": "docs",
"templateOverrides": {},
"excludePatterns": ["**/node_modules/**", "**/dist/**", "**/.git/**"],
"languages": ["typescript", "python", "go"],
"driftThreshold": "warning",
"autoFix": false
}
}
}
}
}
Important Notes
- Free tier works immediately with no configuration
- Pro/Team tiers require a license key from https://docsync.pages.dev
- All processing happens locally — no code is sent to external servers
- License validation is offline — no network calls needed
- Git hooks use lefthook which must be installed (see install metadata above)
- tree-sitter and difftastic are optional but recommended for best results; the skill falls back to regex-based parsing if unavailable
Error Handling
- If tree-sitter is not installed, fall back to regex-based symbol extraction (less accurate but functional)
- If lefthook is not installed and user tries
hooks install, prompt to install it - If license key is invalid or expired, show clear message with link to https://docsync.pages.dev/renew
- If a language grammar is not available, skip that file with a warning
When to Use DocSync
The user might say things like:
- "Generate docs for this file/project"
- "Are my docs up to date?"
- "Check for documentation drift"
- "Set up auto-docs on my commits"
- "Create an onboarding guide"
- "Document the architecture"
- "What's undocumented in this codebase?"
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
天气:实时预报与气象数据 - Openclaw Skills
上传处理程序生成器:安全文件上传逻辑 - Openclaw Skills
Docker 镜像构建器:自动化容器构建 - Openclaw Skills
Crypto.com 交易机器人:自动化加密货币交易所工具 - Openclaw Skills
Claude 安全检查器:HHH 对齐与审核 - Openclaw Skills
币安三角套利:加密货币交易与执行 - Openclaw Skills
币安超短线交易机器人:高频加密货币交易工具 - Openclaw Skills
币安网格交易:自动化加密货币套利 - Openclaw Skills
AI 测试生成器:自动化单元测试创建 - Openclaw Skills
AI 性能优化器:自动化代码瓶颈分析 - Openclaw Skills
AI精选
