bmad-project-context

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Overview

概述

A conversation that produces a repository's agent instructions: a small verified block inside
AGENTS.md
. The user brings rules they want followed — governance, security, standards — and the repository supplies the rest, verified.
Conversational always; the user approves every write.
Args: intent (
setup
|
adopt
|
refresh
|
record
|
audit
); a target repo or path; extra source paths or URLs.
这是一个用于生成仓库Agent指令的对话流程:最终会在
AGENTS.md
中生成一个经过验证的小型代码块。用户提供需要遵循的规则——治理、安全、标准等,仓库提供其余必要信息并完成验证。
全程采用对话式交互;所有写入操作都需用户批准。
参数: intent(
setup
|
adopt
|
refresh
|
record
|
audit
);目标仓库或路径;额外的源路径或URL。

Resolution rules

解析规则

  • Bare paths and
    {skill-root}
    (e.g.
    references/best-practices.md
    ) resolve from this skill's installed directory.
  • {project-root}
    → the project working directory.
  • Target → the repository being described, defaulting to
    {project-root}
    . If it resolves to more than one working tree, or to one the user cannot commit in, ask before writing.
  • 裸路径和
    {skill-root}
    (例如
    references/best-practices.md
    )从本Skill的安装目录解析。
  • {project-root}
    → 项目工作目录。
  • 目标 → 所描述的仓库,默认为
    {project-root}
    。如果解析到多个工作树,或者用户无法提交的工作树,写入前需询问用户。

On Activation

激活流程

  1. Resolve customization:
    uv run {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow
    . On failure, read
    {skill-root}/customize.toml
    directly and use defaults. Execute
    {workflow.activation_steps_prepend}
    ; treat
    {workflow.persistent_facts}
    entries as standing context (
    file:
    = paths/globs to load, others verbatim).
  2. Config: if
    {project-root}/_bmad
    exists,
    uv run {project-root}/_bmad/scripts/resolve_config.py --project-root {project-root}
    and read
    {user_name}
    ,
    {communication_language}
    (use it every turn),
    {output_folder}
    . Standalone: skip.
  3. Load
    references/best-practices.md
    and
    references/template.md
    before anything else.
    Every decision below is made against them.
  4. Detect intent and greet
    {user_name}
    : setup (no instruction file in the target carries meaningful content — scaffolding alone, empty headings, a comment, a lone import line, is not meaningful; when unsure, adopt, since adopting a near-empty file costs one small ledger while setting up a meaningful one loses instructions), adopt (an instruction file has content but no managed block, whatever its state and whoever wrote it — the migration form of refresh; that file is the baseline and every instruction in it enters the ledger of step 1), refresh (a managed block exists), record (the user reports a mistake agents made), audit (re-verify and prune). A supplied intent that contradicts what detection finds — e.g.
    setup
    against a file with content — is surfaced and confirmed, never silently obeyed. Fold
    {workflow.external_sources}
    into the source list. Execute
    {workflow.activation_steps_append}
    .
  1. 解析自定义配置:执行
    uv run {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow
    。若执行失败,直接读取
    {skill-root}/customize.toml
    并使用默认值。执行
    {workflow.activation_steps_prepend}
    ;将
    {workflow.persistent_facts}
    中的条目视为固定上下文(
    file:
    = 要加载的路径/通配符,其他内容直接使用)。
  2. 配置处理:如果
    {project-root}/_bmad
    存在,执行
    uv run {project-root}/_bmad/scripts/resolve_config.py --project-root {project-root}
    并读取
    {user_name}
    {communication_language}
    (每次交互均使用该语言)、
    {output_folder}
    。独立模式下跳过此步骤。
  3. 优先加载
    references/best-practices.md
    references/template.md
    。后续所有决策均以此为依据。
  4. 检测intent并向
    {user_name}
    问候:setup(目标仓库中无包含有效内容的指令文件——仅脚手架、空标题、注释或单独的导入行均视为无效;若不确定,则采用adopt模式,因为采用近乎空的文件仅需少量记录,而设置有效文件可能会丢失现有指令),adopt(指令文件包含内容但无受管理的代码块,无论其状态或编写者——属于refresh的迁移形式;该文件作为基准,其中的每条指令都会进入步骤1的记录),refresh(存在受管理的代码块),record(用户报告Agent犯的错误),audit(重新验证并精简内容)。若用户提供的intent与检测结果矛盾——例如针对已有内容的文件使用
    setup
    ——需明确指出并确认,不得默默执行。将
    {workflow.external_sources}
    合并到源列表中。执行
    {workflow.activation_steps_append}

Setup, Adoption, and Refresh Steps

设置、采用与更新步骤

No writes until step 5!
在步骤5前不得进行任何写入操作!

1. Assess and report

1. 评估与报告

Read
AGENTS.md
, harness or agent specific rule files, docs folders, and any notes carrying lessons. Report what exists and how it measures up, per
best-practices.md
.
Existing instructions are the baseline being improved, never raw material to discard. Open a ledger: one entry per existing section and per independently meaningful instruction, opened at
retain
or
rewrite
, carrying what an agent would get wrong without it. Entries settle as evidence arrives in steps 2–4 —
retain | rewrite | relocate | automate | delete
, each with its reason, its evidence, the risk if it goes, a destination for a relocation, and an approval flag. Deletion needs one of the four grounds in
best-practices.md
, and a relocation destination must itself be loaded or sit behind an observable trigger — a move into a file nothing reads is a deletion and needs its ground. Setup has nothing to map and opens no ledger; refresh opens entries for the lines it proposes to change or remove, the block's own included. A lesson found outside the instruction files — a warning in a README, a notes file — is an ordinary candidate, not a ledger entry.
If the target contains separable units — a workspace manifest listing members, or directories carrying their own build manifest — name them and ask whether this run covers the root only, all of them, or which. Absent that evidence, do not ask. Sibling repositories are not children; each is its own target, offered in turn.
读取
AGENTS.md
、工具或Agent专属规则文件、文档文件夹及任何包含经验总结的笔记。根据
best-practices.md
报告现有内容及其符合程度。
现有指令是待改进的基准,绝不能当作可丢弃的原始素材。建立一个记录台账:每个现有章节和每条独立有效指令对应一个条目,初始状态为
保留
重写
,记录缺少该指令时Agent会犯的错误。随着步骤2-4中证据的收集,条目状态会更新为
保留 | 重写 | 迁移 | 自动化 | 删除
,每个状态需附带原因、证据、删除后的风险、迁移目标以及审批标记。删除操作需符合
best-practices.md
中的四个理由之一,且迁移目标必须已加载或有可观察的触发条件——将内容迁移到无人读取的文件等同于删除,需符合删除理由。setup模式无内容可映射,无需建立记录台账;refresh模式仅为拟修改或删除的行(包括代码块自身的行)创建条目。在指令文件外发现的经验总结——如README中的警告、笔记文件——是普通候选内容,无需创建记录台账条目。
如果目标包含可分离的单元——如列出成员的工作区清单、或包含自身构建清单的目录——需列出这些单元并询问本次操作仅覆盖根目录、全部单元还是特定单元。若无相关证据,无需询问。同级仓库不属于子仓库;每个仓库都是独立目标,需依次处理。

2. Ask what they bring

2. 询问用户提供的规则

Rules to follow regardless of what the repo does: governance, security and compliance, coding standards, style guides, frozen areas. Ask for outside documents too — handbooks, wikis, architecture docs, MCP knowledgebases. Note the paths; do not read them yet.
Greenfield: this is the whole content. Brownfield: it is the half no scan reaches.
无论仓库功能如何都需遵循的规则:治理、安全与合规、编码标准、风格指南、冻结区域。同时询问外部文档——手册、维基、架构文档、MCP知识库。记录路径;暂不读取这些文档。
全新项目:这就是全部内容。已有项目:这是扫描无法覆盖的部分。

3. Discover and verify

3. 发现与验证

Fan out with parallel subagents against what the sections need — executable config and CI for policy and for what they already state, tracked source for conventions and boundaries, targeted history for constraints whose reason must still hold.
package.json
, a
Makefile
,
pyproject.toml
, contribution guides, pull request templates, and CI config are read to know what the block must not repeat. Their caveats come from the human in step 4. Path-check every claim naming a file. For every claim the block will make about what a command does, read the target or script that runs it and verify the claim.
Each child agreed in step 1 is scanned as its own scope, against its own manifests.
使用并行子Agent针对各章节需求展开工作——可执行配置和CI用于策略及已声明内容,跟踪源代码用于约定和边界,针对性历史记录用于仍需保留的约束条件。
读取
package.json
Makefile
pyproject.toml
、贡献指南、拉取请求模板和CI配置,确保代码块不会重复这些内容。这些内容中的注意事项需在步骤4中由用户确认。对所有提及文件的声明进行路径检查。对于代码块中关于命令功能的每条声明,需读取执行该命令的目标文件或脚本并验证声明的准确性。
步骤1中确认的每个子单元需作为独立范围进行扫描,对照其自身的清单。

4. Interview the gaps

4. 访谈填补空白

Only what no scan reaches: what agents keep getting wrong here, what is off limits, what a domain term means, why a constraint exists.
  • Never ask what a scan could answer. Asking the user to confirm a path-checked claim, or one a config file already states, is a defect.
  • Ask recall questions, not review lists. Never hand the user a selection problem a scan created.
  • A mistake this session made and caught is observed evidence — offer it.
  • A repeatable command spotted in anything read this session — a log, a doc, its own runs — whose correct form is not the obvious guess is a candidate line: offer it. E.g.
    uv run pytest
    where plain
    pytest
    looks right but runs outside the project environment.
  • Batches of at most eight; fewer is better. A batch yielding nothing new means write.
  • When the repo contradicts the user, show the evidence and ask. Never write the claim as given, never drop it silently.
仅询问扫描无法获取的内容:Agent在此处常犯的错误、禁止操作的区域、领域术语的含义、约束条件存在的原因。
  • 绝不询问扫描可回答的问题。让用户确认已通过路径检查的声明,或配置文件已明确的内容,属于操作缺陷。
  • 询问回忆类问题,而非清单式问题。绝不将扫描产生的选择问题抛给用户。
  • 本次会话中发现并纠正的错误属于观察证据——需告知用户。
  • 在本次会话读取的任何内容中发现的可重复命令——日志、文档、自身运行记录——其正确形式并非直观猜测的,需作为候选内容提供。例如:
    uv run pytest
    ,虽然普通
    pytest
    看似正确,但会在项目环境外运行。
  • 每次最多询问8个问题;越少越好。若一轮提问未获得新信息,则开始写入操作。
  • 当仓库内容与用户陈述矛盾时,需展示证据并询问用户。绝不能直接按用户陈述写入,也不能默默忽略矛盾内容。

5. Show the block, then write it

5. 展示代码块,然后写入

Compose against
template.md
. For each candidate, ask first whether a hook, lint rule, or CI check enforces it better than prose; if so propose the check, and the line becomes the fallback if they decline. A ledger entry marked
automate
keeps its instruction until its check is in place (a later run deletes the line under ground 2 once the check is live).
Show the complete block before writing it, and every child block alongside it — one approval covers the set. Present the settled ledger with it: replacement text alone is an incomplete proposal, because it shows what the user gains and hides what they lose. Every existing instruction appears with its decision and reason. Retains and rewrites that keep the full rule may be grouped. If a rewrite weakens, narrows, or drops part of a rule, treat the lost part as a deletion and list it separately. Keep the rule itself; examples may explain it but cannot replace it. Every relocation, automation, and deletion is itemized. A deletion resting on none of the first three grounds is held for line-item approval — approving the block never approves it — and a declined deletion, relocation, or automation reverts to retain. On approval, splice between the markers — the splice itself touches nothing outside them. Text outside the markers changes only through a settled ledger entry or a proposed fix the user has seen, never as a side effect of the splice. Fill each provenance line with today's date and the verified SHA.
Where an instruction elsewhere contradicts the block in a way that changes behavior — a stale
CLAUDE.md
line, a retired command — propose the fix to that file. Two live contradictory instructions is a defect.
Never commit.
对照
template.md
编写内容。对于每个候选内容,先询问是否通过钩子、lint规则或CI检查比文字描述更能有效执行;若如此,则建议使用检查机制,若用户拒绝则保留文字描述作为备选。标记为
自动化
的记录台账条目需保留其指令,直到检查机制生效(后续运行会在检查机制生效后根据理由2删除该行)。
写入前需展示完整的代码块,同时展示所有子代码块——一次审批即可覆盖全部内容。需同时展示已确定的记录台账:仅提供替换文本属于不完整的提案,因为只展示了用户获得的内容,隐藏了失去的内容。每条现有指令需附带决策结果及理由。保留和重写且完整保留规则的条目可分组展示。若重写削弱、缩小或删除了规则的部分内容,需将丢失的部分视为删除操作单独列出。需保留规则本身;示例可解释规则但不能替代规则。每个迁移、自动化和删除操作需逐项列出。未符合前三个删除理由的删除操作需单独审批——批准代码块并不代表批准该删除操作——若用户拒绝删除、迁移或自动化操作,则恢复为保留状态。获得批准后,在标记之间插入内容——插入操作不得触及标记外的任何内容。标记外的文本仅可通过已确定的记录台账条目或用户已确认的修复提案进行修改,不得作为插入操作的副作用修改。在每个来源行中填写当前日期和经过验证的SHA。
若其他指令文件中的内容与代码块矛盾且会改变行为——如过时的
CLAUDE.md
行、已废弃的命令——需建议修复该文件。同时存在两个生效的矛盾指令属于缺陷。
绝不执行提交操作。

6. Close

6. 收尾

  • What went in, what was left out and why, and — after adoption or refresh — where each existing instruction landed.
  • Why, in the user's terms, from
    best-practices.md
    — why it is small, why what the repo already states stays out, why a pitfall stays until its cause is gone.
  • How it loads, and that other harness files can point at it.
  • Any branch, ticket, commit, or pull request rules that apply when the user submits these instruction changes.
  • Maintenance: re-run after significant change,
    record
    the moment an agent gets something wrong, prefer a check over a new line.
  • Rules repeating across their projects, or personal rather than the team's, belong in their global agent config.
  • 已写入的内容、未写入的内容及原因,以及——在采用或更新模式下——每条现有指令的最终去向。
  • 用用户易懂的语言解释
    best-practices.md
    中的原则——为何内容要精简、为何仓库已声明的内容无需重复、为何常见问题需保留直到其原因消除。
  • 代码块的加载方式,以及其他工具文件如何指向它。
  • 用户提交这些指令变更时需遵循的分支、工单、提交或拉取请求规则。
  • 维护建议:在重大变更后重新运行,一旦发现Agent出错立即使用
    record
    模式,优先使用检查机制而非新增行。
  • 在多个项目中重复出现的规则,或属于个人而非团队的规则,应放入全局Agent配置中。

Refresh

更新(Refresh)

Same steps, step 1 as a diff. Read the provenance line, re-verify every path and every caveat, and run
git log --diff-filter=DR --name-only
since the recorded SHA against every line — update or remove lines whose evidence is gone. Every proposed removal is a ledger entry shown in step 5, never a silent edit, and handwritten instructions outside the block are treated as in adoption — any proposal touching them enters the ledger. Never re-ask what a prior run settled; the interview shrinks to what changed about how the team works. The block grows only on new evidence.
步骤相同,步骤1以差异对比形式呈现。读取来源行,重新验证所有路径和注意事项,并针对每行执行
git log --diff-filter=DR --name-only
(从记录的SHA开始)——更新或删除证据已消失的行。每个拟删除的行需作为记录台账条目在步骤5中展示,不得默默编辑;代码块外的手写指令需按采用模式处理——任何涉及这些指令的提案需进入记录台账。绝不重复询问之前运行已确定的内容;访谈仅聚焦于团队工作方式的变化。代码块仅在有新证据时才会扩展。

Adoption

采用(Adopt)

Refresh against instructions this skill has never touched. Nothing was settled by a prior run, so the full interview applies — and the file itself is maintainer testimony, so the ledger is the run's main output: the user should be able to read it and see where each of their instructions went.
The proposal states what remains of every file instructions were moved out of — commonly a
CLAUDE.md
reduced to
@AGENTS.md
, once that import is verified for every harness in use, like any loading mechanism. No instruction lives in two loaded files, where it is paid for twice; a duplicate, verbatim or reworded, is kept once — the block keeps the survivor — and that settles both entries.
针对本Skill从未处理过的指令执行更新操作。由于之前的运行未确定任何内容,需进行完整访谈——文件本身就是维护者的证词,因此记录台账是本次运行的主要输出:用户应能通过读取台账了解每条现有指令的去向。
提案需说明移出指令后的文件剩余内容——通常
CLAUDE.md
会简化为
@AGENTS.md
,但需像任何加载机制一样,验证所有使用的工具是否支持该导入。不得让指令同时存在于两个已加载的文件中(否则会重复消耗资源);重复的指令(无论原文或改写)仅保留一次——代码块保留其中一个——并同时处理两个条目。

Greenfield

全新项目(Greenfield)

Seeded from a spec or planning document, or interview alone. Commands that do not exist yet are written as explicit TODOs naming the decided stack, never a guessed invocation stated as fact, and verified on the first refresh after code exists. A genuinely contested design decision — real tradeoffs, multiple viable shapes — goes to
bmad-architecture
.
从规格文档或规划文档,或仅通过访谈生成内容。尚未存在的命令需明确标记为TODO并注明已确定的技术栈,绝不能将猜测的调用方式作为事实写入;需在代码存在后的首次更新中进行验证。真正有争议的设计决策——存在实际权衡、多种可行方案——需提交给
bmad-architecture
处理。

Migration

迁移(Migration)

If the target has a
project-context.md
from the retired skills, commonly under
{output_folder}
, read it in step 1 and offer to absorb its content. Do not delete it without agreement, and do not silently orphan it.
如果目标仓库存在已废弃Skill生成的
project-context.md
(通常位于
{output_folder}
下),需在步骤1中读取该文件并提议吸收其内容。未经用户同意不得删除该文件,也不得默默弃用。

Record

记录(Record)

Capture one observed agent mistake as it happens — the only admissible source for a pitfall.
Take the task, the mistake, the correction, and its evidence. Check the block for a line already covering it. One occurrence is noted; a recurring or costly mistake earns a line now — an exact invocation under Running and verifying when it is a command error, otherwise a pitfall. Write it and show the diff. If it is mechanically preventable, propose the hook, lint rule, or CI check instead.
实时捕获一个观察到的Agent错误——这是常见问题的唯一可接受来源。
记录任务内容、错误、修正方法及证据。检查代码块中是否已有覆盖该错误的行。单次出现的错误仅做记录;重复出现或代价高昂的错误需立即添加一行——如果是命令错误,添加到运行与验证下的精确调用示例;否则添加为常见问题。写入内容并展示差异。如果错误可通过机械方式预防,建议使用钩子、lint规则或CI检查替代文字描述。

Audit

审核(Audit)

Re-check every caveat, path-check every file, follow every pointer, and ask of every line whether removing it would change agent behavior. Verify each command claim against the target or script that runs it. Check for contradictions with other instruction files.
Failing lines get fixed, move behind an observable trigger, or become ledger entries: a removal needs one of the four grounds in
best-practices.md
, presented and settled as in step 5 before anything is removed. A policy or pitfall goes only when the thing it guards is gone or the user retires it; nothing failing lately is not grounds. Audit ends smaller or equal.
重新检查所有注意事项,对所有文件进行路径检查,跟踪所有指针,并询问每行内容:删除该行是否会改变Agent的行为。针对每条命令声明,对照执行该命令的目标文件或脚本进行验证。检查与其他指令文件的矛盾之处。
不符合要求的行需修复、移至可观察触发条件后,或成为记录台账条目:删除操作需符合
best-practices.md
中的四个理由之一,需在步骤5中展示并确定后才能删除。**策略或常见问题仅在其防护的对象消失或用户弃用时才可移除;近期未出现错误不能作为移除理由。**审核后内容应精简或保持不变。

Children

子单元

A component, nested repository, or extracted rules file gets its own file under the same shape when work keeps landing there and every condition holds: its rules are subtree-exclusive, they are substantial (a handful of rules is not a file), the split materially reduces the parent block, the loading mechanism is verified for every harness in use — checked, never assumed — and the user approves the split. Even with verified loading, keep a rule at the root when it must apply before a session enters that directory or when breaking it can affect work outside the child. Otherwise the rules stay in the parent block as path-qualified lines ("in
src/importer/
: ..."), which cost less than a file nobody loads. Why the loading check:
best-practices.md
.
Use a linked file only when the trigger is not a path.
A chosen child that ends with nothing its parent does not already say gets no file. Say so and move on.
List every child in the parent's Where things are with one line and its path. Discovery never depends on the harness finding it.
当某个组件、嵌套仓库或提取的规则文件频繁有相关工作,且满足以下所有条件时,可为其创建独立的同格式文件:其规则仅适用于子树、规则内容足够丰富(少量规则无需单独文件)、拆分可显著精简父代码块、所有使用的工具的加载机制已验证——需实际检查,不得假设、且用户批准拆分。即使加载机制已验证,若规则需在会话进入该目录前生效,或违反规则会影响子单元外的工作,则需将规则保留在根目录。否则规则需作为路径限定行保留在父代码块中(例如"在
src/importer/
中:..."),这种方式比创建无人加载的文件成本更低。为何要检查加载机制:参考
best-practices.md
仅当触发条件并非路径时才使用链接文件。
若选中的子单元最终内容与父代码块完全重复,则无需创建独立文件。需告知用户并继续处理其他内容。
在父代码块的内容位置部分列出每个子单元,每行对应一个子单元及其路径。内容发现不得依赖工具自动查找。