importing-a-codebase
它能做什么
这个技能让 AI 研究一个有代码但没有书面规格的项目,然后起草描述其设计和决策的关键文档。适合希望为现有应用编写文档的团队。
适用场景
- ✓当你有一个已有代码、却没有架构或产品文档的项目时。
- ✓当你希望 AI 根据 README 文件、智能体规则和代码本身起草规格时。
- ✓当你希望在信任项目规格之前,先审阅并修正草稿时。
技能链接
https://github.com/JetBrains/thinkrail/blob/main/packages/pi-thinkrail-workflow/skills/importing-a-codebase/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的项目有代码但没有文档,请阅读它,并为我起草第一版规格供我审阅。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会阅读项目的说明、配置文件和主要代码,起草并标记为草稿的文档,并且只针对文件中找不到的意图向你提问。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Importing a codebase
The workspace holds real code but no specs. Reverse-engineer the spec graph the project should have had. When the repo already carries real spec-like documents, build the graph around them, not parallel to them. Do as much as possible yourself, from the files; ask the user only where the code genuinely can't tell you and the answer changes a spec.
Hold the writing-specs bar. Read that concept skill before drafting — everything in this flow is inferred rather than confirmed, so its honesty rules (draft until the user reviews, unconfirmed marked inline) bind hardest here.
1. Read first, ask last
Survey before you ask a single question. Read, in roughly this order:
- Agent files (mine these first — they state intent + conventions directly):
AGENTS.md,CLAUDE.md,.cursor/rules/*,.cursorrules,.github/copilot-instructions.md,GEMINI.md,.windsurfrules. - Docs:
README,docs/,CONTRIBUTING, ADRs. - Manifests & layout:
package.json/pyproject.toml/go.mod/Cargo.toml, workspace globs,tree-style structure, entry points, build/test scripts. - Code: entry points and the top of each candidate module — enough to see responsibilities and the dependency edges between them.
While you read, collect adoption candidates: durable, declarative documents that state the world as it is — architecture/design docs, ADRs / decision records, domain glossaries, protocol/contract docs. Never candidates (input only): READMEs, CONTRIBUTING, changelogs, roadmaps, TODOs, implementation plans (finished or planned), generated API docs.
Confirm with the spec tools (spec_grep / spec_graph) that there's no graph yet. If specs already
exist, stop and hand back to the setting-up-a-project dispatcher — this flow is for un-specced repos.
2. Build a working model
From what you read, form a working model of what the project is and how it's shaped — held in the conversation, not written to a file (this flow declares no working files):
what: one-sentence purpose (the job the codebase does)
domain: the space it's in
stack: languages / frameworks / runtime
modules: the real boundaries + the dependency edges between them (who imports whom)
invariants: rules the code already enforces (layering, "X never imports Y", public surfaces)
decisions: non-obvious choices visible in the code (and where the "why" is missing)
Agent files and READMEs usually hand you what, invariants, and decisions for free — prefer them over
re-deriving from code.
3. Interview only the gaps
Ask only what the files can't answer and that would change a spec — typically: the primary job / who it's for, explicit non-goals, and the why behind a non-obvious decision. Interview them in rounds per the asking-user-questions concept skill; infer a concrete answer and let the user correct it rather than asking open-ended.
Two kinds of question belong in the round whenever the files leave them open — the code shows what, rarely why:
- The why behind each non-obvious decision in your working model that the files don't explain — "I see X is done this way — why?" — with your inferred reasons as options. The answer goes into the spec that owns the decision.
- Known limitations — one multiSelect of the gaps you saw (unhandled cases, TODOs, missing tests, slow paths) for the user to confirm; confirmed ones are recorded in the owning spec.
If adoption candidates exist, add one question to the same round: a multiSelect listing them (grouped
when many — an adr/ set is one option) — which should become spec-graph nodes? A contradiction
between a candidate and the code found by now goes into the round too (confirm the correction).
Skipped or declined → adopt none; candidates stay input, noted at hand-off.
If the files answered everything material — the whys and limitations included — skip the interview and say so; don't manufacture questions (adoption candidates alone still make a round — the offer is never dropped as "no gaps"). A skipped/declined question is not a blocker: record the assumption inline in the spec, marked unconfirmed.
4. Draft the graph, top-down
Save with the spec tools as you go (spec_create per node, edit for prose). Order:
goal-and-requirements.md(type: goal-and-requirements) — what the product is and why, in the goal-doc shapewriting-specssets; capabilities are what the c
常见问题
这些草稿会成为最终版本吗?
不会。在你审阅之前,它们都是草稿,所有猜测的内容都会被标记为未确认。
它首先读取哪些文件?
智能体指令文件、README、文档、包配置文件和主要入口文件。
它会修改我的代码吗?
该技能专注于编写规格,因此主要产出是文档,而不是代码改动。
详情
作者的原始描述
Use when asked to create the initial spec graph for an existing codebase that has source code but no specs. Normally reached via setting-up-a-project.
repo: JetBrains/thinkrail
热度
- GitHub 星标
- 7.1k
- 排名
- #13491
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
asking-user-questions
7.1k教你的智能体分轮次向你提出清晰的问题,并给出合适的回答选项,直到悬而未决的问题都得到确定。
brainstorming
7.1k帮你的智能体在构建之前,和你一起讨论功能、行为变更或缺陷修复,并记录商定的设计。
choosing-a-workflow
7.1k帮你的智能体为新项目、拉取请求或任何产品功能的变更,选择合适的 ThinkRail 工作流。
setting-up-a-project
7.1k帮你的智能体为规格驱动的工作搭建项目,并根据是新想法、现有代码还是已有文档的项目选择合适的路径。