knowledge-layers

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Knowledge Layers

知识分层

Load
/qi-layer
when writing or editing AGENTS.md or .context/ files: it owns the craft (four principles, contents guidelines, what doesn't belong). Load
/information-hierarchy
if not already loaded for disclosure tiers. Load
/llm-writing
if not already loaded.
编写或编辑AGENTS.md或.context/文件时,请加载
/qi-layer
:它定义了相关规范(四项原则、内容指南、不属于该范畴的内容)。如果尚未加载用于披露层级的
/information-hierarchy
,请加载它。如果尚未加载
/llm-writing
,请加载它。

The Five Layers

五层结构

LayerWhat it holdsWhen to use it
AGENTS.md
Intent and mental model for a directoryFirst thing agents read on entry; what to understand before working here
.context/
Contracts, architecture, rationale (
CONTEXT.md
); deferred work (
TODO
,
FUTURE
)
Reference depth and tracked deferrals, co-located with the code they describe
KBCross-cutting decisions, domain concepts, patternsSpans directories; outlives sessions; no single directory owns it
docs/
User-facing documentationDifferent audience, different update cadence
Work directoryTemporary design decisions and scratchNot colocated with durable content; scoped to an active work item
层级存储内容使用场景
AGENTS.md
目录的意图与心智模型Agent进入目录后首先读取的内容;开始工作前需要理解的信息
.context/
契约、架构、基本原理(
CONTEXT.md
);待办工作(
TODO
FUTURE
供Agent查阅详细内容与跟踪待办事项,与所描述的代码共存
KB跨领域决策、领域概念、模式跨多个目录;生命周期长于会话;不属于单个目录
docs/
面向用户的文档受众不同,更新节奏不同
工作目录临时设计决策与草稿不与持久化内容共存;范围限定在当前活跃的工作项

Placement Rules

放置规则

If it's intent/mental-model for a directory →
AGENTS.md
. If it's directory-scoped depth an agent looks up →
.context/
. If it's deferred work scoped to this directory →
.context/TODO
(must-do) or
.context/FUTURE
(nice-to-have). Flat markdown lists — each entry names the affected path and concrete follow-up. Cross-cutting items or items needing external visibility get filed in the project's issue tracker instead. If it's big picture — cross-cutting decisions, domain concepts, higher-level system architecture → KB. If it's for end users →
docs/
. If it's a temporary work artifact → work directory.
When in doubt, colocate. Knowledge that depends on one subsystem belongs in that subsystem's AGENTS.md or .context/ even when it reads like a concept; the KB stays code-agnostic, holding what survives implementation change. Knowledge that lives far from what it describes rots faster: changes to the code don't trigger awareness that a distant doc needs updating.
如果是目录的意图/心智模型 →
AGENTS.md
。 如果是目录范围内供Agent查阅的详细内容 →
.context/
。 如果是目录范围内的待办工作 →
.context/TODO
(必须完成)或
.context/FUTURE
(期望完成)。采用扁平化Markdown列表——每个条目需注明受影响的路径和具体后续操作。跨领域事项或需要外部可见的事项需提交至项目的问题追踪器。 如果是全局视角内容——跨领域决策、领域概念、更高层级的系统架构 → KB。 如果是面向终端用户的内容 →
docs/
。 如果是临时工作产物 → 工作目录。
若存疑,优先就近放置。依赖单个子系统的知识,即使看起来是概念性内容,也应放在该子系统的AGENTS.md或.context/中;KB保持与代码无关,存储能在实现变更后留存的内容。与所描述内容相距过远的知识更容易失效:代码变更不会触发对远程文档需要更新的认知。

Current Truth Over History

以当前事实为准,而非历史

Every durable layer — AGENTS.md,
.context/
, KB,
docs/
— holds the best current understanding; work directories may keep intermediate reasoning while their work item is active. When durable content is superseded, delete it or (for KB pages) move it to
archive/
(
.kgignore
'd, excluded from the knowledge graph). Live content never references archived content. Pages read as current truth, never narrate their own evolution.
Deletion needs no replacement. A page whose subject is gone, or that describes behavior the system no longer has, gets deleted on sight — even with nothing new to write in its place. Stale knowledge is worse than a gap: agents load it and reason from it. Deletion is the content-truth owner's call; structural roles flag instead.
Git history is the archive. Commit untracked files before deleting them so the removal lands in history, and say what was removed and why in the commit message. Deletion is cheap because nothing tracked is ever truly lost.
Truth is anchored per layer. AGENTS.md and
.context/
describe the checkout that contains them: update them in the same branch as the code change and let the merge carry both — with parallel PRs in flight, each branch documents itself. The KB is code-agnostic: it records the current settled intent — what the system should be — and a settled decision is KB truth the moment it's made, merged or not. Unsettled intent isn't KB material; it stays in the work directory.
docs/
describes shipped behavior.
Decision records are the exception: preserve superseded decisions in place when they explain why the system changed. Mark the old decision as superseded and link to the replacement.
每个持久化层级——AGENTS.md、
.context/
、KB、
docs/
——都存储当前最佳认知;工作目录可在工作项活跃期间保留中间推理过程。当持久化内容被取代时,删除它,或(针对KB页面)将其移至
archive/
(被
.kgignore
忽略,不纳入知识图谱)。有效内容永远不引用归档内容。页面应呈现当前事实,而非叙述自身演变过程。
删除无需替代。 主题已消失或描述系统不再具备的行为的页面,一经发现立即删除——即使没有新内容替代。过时知识比空白更糟:Agent会加载并基于它进行推理。删除由内容事实所有者决定;结构角色仅做标记。
Git历史即为归档。 删除前提交未跟踪文件,使删除操作记录在历史中,并在提交信息中说明删除内容及原因。删除成本很低,因为所有被跟踪的内容永远不会真正丢失。
事实按层级锚定。 AGENTS.md和
.context/
描述包含它们的代码检出版本:在与代码变更相同的分支中更新它们,让合并操作同时携带两者——当存在并行PR时,每个分支自行记录文档。KB与代码无关:它记录当前已确定的意图——系统应该是什么样——已确定的决策在制定时即为KB事实,无论是否合并。未确定的意图不属于KB内容;应留在工作目录中。
docs/
描述已发布的行为。
决策记录是例外:当被取代的决策能解释系统变更原因时,保留其原位。标记旧决策为已取代,并链接至替代内容。

KB Conventions

KB约定

Structure

结构

The KB is a directory tree like any other: it carries its own AGENTS.md and
.context/
pair, written per
/qi-layer
— intent in AGENTS.md, governance depth (writing conventions, structure, validation) in
.context/
. Read the KB's own
AGENTS.md
before writing. Treat this skill as the cross-project default; the local KB guide wins for that KB. See
resources/bootstrap.md
for a suggested starting layout.
KB是一个目录树,与其他目录树相同:它包含自己的AGENTS.md和
.context/
对,遵循
/qi-layer
编写——AGENTS.md存储意图,
.context/
存储治理细节(写作约定、结构、验证规则)。编写前请阅读KB自身的
AGENTS.md
。将本技能视为跨项目默认规范;本地KB指南对该KB具有优先性。参考
resources/bootstrap.md
获取建议的初始布局。

Wiki Page Conventions

维基页面约定

Follow
/information-hierarchy
. One concept per document; name files by what they describe (
token-validation.md
), not when (
auth-redesign-notes.md
). Cross-reference instead of re-explaining. Load
/shared-dao
for vocabulary methodology. Use mermaid for anything spatial; capture what code can't easily tell you.
遵循
/information-hierarchy
。每个文档对应一个概念;文件按描述内容命名(如
token-validation.md
),而非按时间命名(如
auth-redesign-notes.md
)。使用交叉引用而非重复解释。加载
/shared-dao
获取词汇方法论。使用mermaid绘制任何空间相关内容;捕捉代码无法轻易表达的信息。

Operations

操作流程

Ingest: new information enters the KB. Read the source, extract key knowledge, write or update wiki pages, and update indexes/cross-links touched by the change.
Maintain: keep the wiki current per Current Truth Over History above.
Lint: health-check the wiki. Look for contradictions, stale claims, orphan pages, missing cross-references. Use
/md-validation
for link checking and diagram validation.
Flag content needing human attention with
> [!FLAG] **Needs human review**
.
摄入:新信息进入KB。阅读来源,提取关键知识,编写或更新维基页面,并更新受变更影响的索引/交叉链接。
维护:根据上述“以当前事实为准,而非历史”原则保持维基内容最新。
检查:对维基进行健康检查。查找矛盾、过时声明、孤立页面、缺失的交叉引用。使用
/md-validation
进行链接检查和图表验证。
使用
> [!FLAG] **需要人工审核**
标记需要人工关注的内容。