acquire-codebase-knowledge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAcquire Codebase Knowledge
获取代码库知识
Produces seven populated documents in covering everything needed to work effectively on the project. Only document what is verifiable from files or terminal output — never infer or assume.
docs/codebase/会在目录下生成七个已填充内容的文档,涵盖在项目中高效工作所需的全部信息。仅记录可从文件或终端输出中验证的内容——绝不进行推断或假设。
docs/codebase/Output Contract (Required)
输出契约(必填)
Before finishing, all of the following must be true:
- Exactly these files exist in :
docs/codebase/,STACK.md,STRUCTURE.md,ARCHITECTURE.md,CONVENTIONS.md,INTEGRATIONS.md,TESTING.md.CONCERNS.md - Every claim is traceable to source files, config, or terminal output.
- Unknowns are marked as ; intent-dependent decisions are marked
[TODO].[ASK USER] - Every document includes a short "evidence" list with concrete file paths.
- Final response includes numbered questions and intent-vs-reality divergences.
[ASK USER]
完成前,必须满足以下所有条件:
- 目录下必须恰好存在这些文件:
docs/codebase/、STACK.md、STRUCTURE.md、ARCHITECTURE.md、CONVENTIONS.md、INTEGRATIONS.md、TESTING.md。CONCERNS.md - 所有声明均可追溯至源文件、配置或终端输出。
- 未知内容标记为;依赖意图的决策标记为
[TODO]。[ASK USER] - 每个文档都包含一个简短的“证据”列表,附带具体的文件路径。
- 最终回复需包含编号的问题,以及意图与实际情况的差异点。
[ASK USER]
Workflow
工作流
Copy and track this checklist:
- [ ] Phase 1: Run scan, read intent documents
- [ ] Phase 2: Investigate each documentation area
- [ ] Phase 3: Populate all seven docs in docs/codebase/
- [ ] Phase 4: Validate docs, present findings, resolve all [ASK USER] items复制并跟踪以下检查清单:
- [ ] 阶段1:运行扫描,读取意图文档
- [ ] 阶段2:调研每个文档领域
- [ ] 阶段3:填充`docs/codebase/`下的所有七个文档
- [ ] 阶段4:验证文档,呈现发现结果,解决所有[ASK USER]项Focus Area Mode
聚焦领域模式
If the user supplies a focus area (for example: "architecture only" or "testing and concerns"):
- Always run Phase 1 in full.
- Fully complete focus-area documents first.
- For non-focus documents not yet analyzed, keep required sections present and mark unknowns as .
[TODO] - Still run the Phase 4 validation loop on all seven documents before final output.
如果用户指定了聚焦领域(例如:“仅架构”或“测试与关注点”):
- 始终完整运行阶段1。
- 优先完成聚焦领域的文档。
- 对于未分析的非聚焦文档,保留必填部分并将未知内容标记为。
[TODO] - 在最终输出前,仍需对所有七个文档运行阶段4的验证循环。
Phase 1: Scan and Read Intent
阶段1:扫描与读取意图
-
Run the scan script from the target project root:bash
python3 "$SKILL_ROOT/scripts/scan.py" --output docs/codebase/.codebase-scan.txtWhereis the absolute path to the skill folder. Works on Windows, macOS, and Linux.$SKILL_ROOTQuick start: If you have the path inline:bashpython3 /absolute/path/to/skills/acquire-codebase-knowledge/scripts/scan.py --output docs/codebase/.codebase-scan.txt -
Search for,
PRD,TRD,README,ROADMAP,SPECfiles and read them.DESIGN -
Summarise the stated project intent before reading any source code.
-
在目标项目根目录运行扫描脚本:bash
python3 "$SKILL_ROOT/scripts/scan.py" --output docs/codebase/.codebase-scan.txt其中是该Skill文件夹的绝对路径。适用于Windows、macOS和Linux系统。$SKILL_ROOT快速启动: 如果已内联路径:bashpython3 /absolute/path/to/skills/acquire-codebase-knowledge/scripts/scan.py --output docs/codebase/.codebase-scan.txt -
搜索、
PRD、TRD、README、ROADMAP、SPEC文件并阅读。DESIGN -
在阅读任何源代码前,总结项目的既定意图。
Phase 2: Investigate
阶段2:调研
Use the scan output to answer questions for each of the seven templates. Load for the full per-template question list.
references/inquiry-checkpoints.mdIf the stack is ambiguous (multiple manifest files, unfamiliar file types, no ), load .
package.jsonreferences/stack-detection.md使用扫描输出来回答七个模板对应的问题。加载获取每个模板的完整问题列表。
references/inquiry-checkpoints.md如果技术栈不明确(存在多个清单文件、不熟悉的文件类型、无),加载。
package.jsonreferences/stack-detection.mdPhase 3: Populate Templates
阶段3:填充模板
Copy each template from into . Fill in this order:
assets/templates/docs/codebase/- STACK.md — language, runtime, frameworks, all dependencies
- STRUCTURE.md — directory layout, entry points, key files
- ARCHITECTURE.md — layers, patterns, data flow
- CONVENTIONS.md — naming, formatting, error handling, imports
- INTEGRATIONS.md — external APIs, databases, auth, monitoring
- TESTING.md — frameworks, file organization, mocking strategy
- CONCERNS.md — tech debt, bugs, security risks, perf bottlenecks
Use for anything that cannot be determined from code. Use where the right answer requires team intent.
[TODO][ASK USER]将中的每个模板复制到目录下。按以下顺序填充:
assets/templates/docs/codebase/- STACK.md — 语言、运行时、框架、所有依赖项
- STRUCTURE.md — 目录结构、入口点、关键文件
- ARCHITECTURE.md — 分层、模式、数据流
- CONVENTIONS.md — 命名规范、格式、错误处理、导入规则
- INTEGRATIONS.md — 外部API、数据库、认证、监控
- TESTING.md — 测试框架、文件组织、Mock策略
- CONCERNS.md — 技术债务、Bug、安全风险、性能瓶颈
对于无法从代码中确定的内容,使用标记。对于需要团队意图才能确定的内容,使用标记。
[TODO][ASK USER]Phase 4: Validate, Repair, Verify
阶段4:验证、修复、确认
Run this mandatory validation loop before finalizing:
- Validate each doc against .
references/inquiry-checkpoints.md - For each non-trivial claim, confirm at least one evidence reference exists.
- If any required section is missing or unsupported:
- Fix the document.
- Re-run validation.
- Repeat until all seven docs pass.
Then present a summary of all seven documents, list every item as a numbered question, and highlight any Intent vs. Reality divergences from Phase 1.
[ASK USER]Validation pass criteria:
- No unsupported claims.
- No empty required sections.
- Unknowns use rather than assumptions.
[TODO] - Team-intent gaps are explicitly marked .
[ASK USER]
在最终确定前,必须运行以下验证循环:
- 根据验证每个文档。
references/inquiry-checkpoints.md - 对于每个非琐碎声明,确认至少存在一个证据引用。
- 如果任何必填部分缺失或无依据:
- 修复文档。
- 重新运行验证。
- 重复此过程直到所有七个文档通过验证。
然后呈现所有七个文档的摘要,将每个项列为编号问题,并突出显示阶段1中发现的“意图与实际情况”差异点。
[ASK USER]验证通过标准:
- 无无依据的声明。
- 无不完整的必填部分。
- 未知内容使用而非假设。
[TODO] - 团队意图缺口明确标记为。
[ASK USER]
Gotchas
注意事项
Monorepos: Root may have no source — check for , , or directories. Each workspace may have independent dependencies and conventions. Map each sub-package separately.
package.jsonworkspacespackages/apps/Outdated README: README often describes intended architecture, not the current one. Cross-reference with actual file structure before treating any README claim as fact.
TypeScript path aliases: config means imports like don't map directly to the filesystem. Map aliases to real paths before documenting structure.
tsconfig.jsonpaths@/fooGenerated/compiled output: Never document patterns from , , , , , or . These are artefacts — document source conventions only.
dist/build/generated/.next/out/__pycache__/.env.example.env.example.env.template.env.sampledevDependenciesdependencies[tool.poetry.dependencies]Test TODOs ≠ production debt: TODOs inside , , , or are coverage gaps, not production technical debt. Separate them in .
test/tests/__tests__/spec/CONCERNS.mdHigh-churn files = fragile areas: Files appearing most in recent git history have the highest modification rate and likely hidden complexity. Always note them in .
CONCERNS.md单体仓库(Monorepos): 根目录的可能无源代码——检查是否存在、或目录。每个工作区可能有独立的依赖项和规范。需分别映射每个子包。
package.jsonworkspacespackages/apps/过时的README: README通常描述的是预期架构,而非当前实际架构。在将README中的任何声明视为事实前,需与实际文件结构交叉验证。
TypeScript路径别名: 中的配置意味着类似的导入不会直接映射到文件系统。在记录结构前,需将别名映射到真实路径。
tsconfig.jsonpaths@/foo生成/编译输出: 绝不记录、、、、或目录中的模式。这些是生成产物——仅记录源代码的规范。
dist/build/generated/.next/out/__pycache__/.env.example.env.example.env.template.env.sampledevDependenciesdependencies[tool.poetry.dependencies]测试中的TODO ≠ 生产债务: 、、或目录中的TODO是测试覆盖率缺口,而非生产环境的技术债务。需在中单独区分。
test/tests/__tests__/spec/CONCERNS.md高变动文件 = 脆弱区域: 在最近Git历史中出现最频繁的文件修改率最高,可能存在隐藏的复杂性。需在中始终标记这些文件。
CONCERNS.mdAnti-Patterns
反模式
| ❌ Don't | ✅ Do instead |
|---|---|
| "Uses Clean Architecture with Domain/Data layers." (when no such directories exist) | State only what directory structure actually shows. |
"This is a Next.js project." (without checking | Check |
Guess the database from a variable name like | Check manifest for |
Document | Source files only. |
| ❌ 请勿 | ✅ 正确做法 |
|---|---|
| “采用了Clean Architecture,包含领域/数据层。”(当不存在此类目录时) | 仅陈述目录结构实际显示的内容。 |
“这是一个Next.js项目。”(未检查 | 先检查 |
从 | 检查清单文件中的 |
将 | 仅记录源代码的规范。 |
Enhanced Scan Output Sections
增强的扫描输出部分
The script now produce the following sections in addition to the original output:
scan.py- CODE METRICS — Total files, lines of code by language, largest files (complexity signals)
- CI/CD PIPELINES — Detected GitHub Actions, GitLab CI, Jenkins, CircleCI, etc.
- CONTAINERS & ORCHESTRATION — Docker, Docker Compose, Kubernetes, Vagrant configs
- SECURITY & COMPLIANCE — Snyk, Dependabot, SECURITY.md, SBOM, security policies
- PERFORMANCE & TESTING — Benchmark configs, profiling markers, load testing tools
Use these sections during Phase 2 to inform investigation questions and identify tool-specific patterns.
scan.py- CODE METRICS — 总文件数、按语言统计的代码行数、最大文件(复杂度信号)
- CI/CD PIPELINES — 检测到的GitHub Actions、GitLab CI、Jenkins、CircleCI等
- CONTAINERS & ORCHESTRATION — Docker、Docker Compose、Kubernetes、Vagrant配置
- SECURITY & COMPLIANCE — Snyk、Dependabot、SECURITY.md、SBOM、安全策略
- PERFORMANCE & TESTING — 基准测试配置、性能分析标记、负载测试工具
在阶段2中使用这些部分来指导调研问题,并识别特定工具的模式。
Bundled Assets
捆绑资源
| Asset | When to load |
|---|---|
| Phase 1 — run first, before reading any code (Python 3.8+ required) |
| | Phase 2 — load for per-template investigation questions |
| | Phase 2 — only if stack is ambiguous |
| | Phase 3 step 1 |
| | Phase 3 step 2 |
| | Phase 3 step 3 |
| | Phase 3 step 4 |
| | Phase 3 step 5 |
| | Phase 3 step 6 |
| | Phase 3 step 7 |
references/inquiry-checkpoints.mdreferences/stack-detection.mdassets/templates/STACK.mdassets/templates/STRUCTURE.mdassets/templates/ARCHITECTURE.mdassets/templates/CONVENTIONS.mdassets/templates/INTEGRATIONS.mdassets/templates/TESTING.mdassets/templates/CONCERNS.mdTemplate usage mode:
- Default mode: complete only the "Core Sections (Required)" in each template.
- Extended mode: add optional sections only when the repo complexity justifies them.
| 资源 | 加载时机 |
|---|---|
| 阶段1 — 先运行此脚本,再阅读任何代码(需要Python 3.8+) |
| | 阶段2 — 加载以获取每个模板的调研问题 |
| | 阶段2 — 仅当技术栈不明确时加载 |
| | 阶段3 步骤1 |
| | 阶段3 步骤2 |
| | 阶段3 步骤3 |
| | 阶段3 步骤4 |
| | 阶段3 步骤5 |
| | 阶段3 步骤6 |
| | 阶段3 步骤7 |
references/inquiry-checkpoints.mdreferences/stack-detection.mdassets/templates/STACK.mdassets/templates/STRUCTURE.mdassets/templates/ARCHITECTURE.mdassets/templates/CONVENTIONS.mdassets/templates/INTEGRATIONS.mdassets/templates/TESTING.mdassets/templates/CONCERNS.md模板使用模式:
- 默认模式:仅完成每个模板中的“核心部分(必填)”。
- 扩展模式:仅当仓库复杂性需要时,才添加可选部分。