下载技能包
最后更新
2026/4/27
运行时依赖
无特殊依赖
版本
latestv1.0.02026/4/27
初始版本:AI 驱动的代码库分析,输出结构化入门指南
安装命令
点击复制官方npx clawhub@latest install codebase-onboarder
镜像加速npx clawhub@latest install codebase-onboarder --registry https://cn.longxiaskill.com 镜像可用
技能文档
分析任意代码库,输出结构化入门指南。涵盖架构、核心流程、模式、依赖、入口与坑点 —— 那些靠读代码得花几周才能摸清的事。
使用场景:有人说“帮我看懂这个代码库”“带我上手”“给这项目写文档”或“这仓库是干嘛的”。
分析步骤
按顺序执行,上一步结果影响下一步。1. 项目身份
``bash
# 这是什么?
cat README.md 2>/dev/null || cat readme.md 2>/dev/null
cat package.json 2>/dev/null | jq '{name, description, scripts}'
cat pyproject.toml 2>/dev/null | head -30
cat Cargo.toml 2>/dev/null | head -20
cat go.mod 2>/dev/null | head -10
cat Makefile 2>/dev/null | head -40
`
判定:语言、框架、用途、构建系统。 2. 项目结构
`bash
# 目录树(深度 3,忽略噪音)
find . -maxdepth 3 -type d \
-not -path '/node_modules/' \
-not -path '/.git/' \
-not -path '/vendor/' \
-not -path '/__pycache__/' \
-not -path '/dist/' \
-not -path '/build/' \
-not -path '/.next/' \
-not -path '/target/' \
| head -80
# 按扩展名统计文件
find . -type f -not -path '/node_modules/' -not -path '/.git/' \
| sed 's/.\.//' | sort | uniq -c | sort -rn | head -15
`
映射架构:业务逻辑在哪、配置在哪、测试在哪、约定是什么。 3. 入口点
`bash
# Web 应用
grep -rl "listen\|createServer\|app\.run\|uvicorn\|Flask(__name__)" --include=".{js,ts,py,go,rb}" . 2>/dev/null | head -10
# CLI 工具
grep -rl "if __name__\|func main\|fn main\|bin.:" --include=".{py,go,rs,json}" . 2>/dev/null | head -10
# 配置声明的入口
cat package.json 2>/dev/null | jq '.main, .bin, .scripts.start, .scripts.dev'
cat pyproject.toml 2>/dev/null | grep -A5 'scripts\|entry_points'
`
识别:执行从哪开始、主脚本/命令有哪些、本地如何运行。 4. 依赖与栈
`bash
# 关键依赖(只列重要的)
cat package.json 2>/dev/null | jq '.dependencies | keys' | head -20
cat requirements.txt 2>/dev/null | head -20
cat go.mod 2>/dev/null | grep -v '//' | tail -20
cat Cargo.toml 2>/dev/null | grep -A50 '\[dependencies\]' | head -30
`
识别:数据库(postgres、mongo、redis)、框架(express、fastapi、gin)、ORM、认证、队列、云 SDK —— 决定项目性格。 5. 数据层
`bash
# 数据库 schema、迁移、模型
find . -type f \( -name ".sql" -o -name "migration" -o -name "schema" -o -name "model" \) \
-not -path '/node_modules/' 2>/dev/null | head -20
# ORM 模型
grep -rl "class.Model\|@Entity\|schema\.\|CREATE TABLE\|db\.Column" \
--include=".{py,ts,js,go,rb,java}" . 2>/dev/null | head -10
`
映射:核心实体、关系、迁移在哪。 6. API 面
`bash
# REST 路由
grep -rn "app\.\(get\|post\|put\|delete\|patch\)\|@app\.route\|router\.\(get\|post\)\|@Get\|@Post\|@Controller" \
--include=".{ts,js,py,go,rb,java}" . 2>/dev/null | head -30
# GraphQL
find . -name ".graphql" -o -name ".gql" -o -name "schema" -name ".graphql" 2>/dev/null | head -10
grep -rl "type Query\|type Mutation\|@Query\|@Mutation" --include=".{ts,js,py,go}" . 2>/dev/null | head -10
`
列出关键端点/操作,按域分组。 7. 配置与环境
`bash
# 环境变量
cat .env.example 2>/dev/null || cat .env.sample 2>/dev/null || cat .env.template 2>/dev/null
grep -rh "process\.env\.\|os\.environ\|os\.getenv\|env::\|std::env" \
--include=".{ts,js,py,go,rs,rb}" . 2>/dev/null | sort -u | head -30
`
记录:需要哪些 env、哪些是密钥、需跑哪些服务。 8. 测试
`bash
# 测试结构
find . -type f \( -name "test" -o -name "spec" -o -name "_test." \) \
-not -path '/node_modules/' 2>/dev/null | head -20
# 如何跑测试
cat package.json 2>/dev/null | jq '.scripts.test'
grep -r "pytest\|jest\|mocha\|vitest\|go test\|cargo test" Makefile 2>/dev/null
` 9. CI/CD 与部署
`bash
ls -la .github/workflows/ 2>/dev/null
ls -la .gitlab-ci.yml 2>/dev/null
cat Dockerfile 2>/dev/null | head -20
cat docker-compose.yml 2>/dev/null | head -30
ls -la k8s/ kubernetes/ helm/ 2>/dev/null
` 输出模板
分析完成后,生成包含以下章节的文档:
``markdown
# [项目名称] — 入门指南
这是什么
一句话:它做什么、给谁用、解决什么问题。技术栈
- Language: X
- Framework: X
- Database: X
- Key dependencies: X, Y, Z