ce-compound-refresh
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCompound Refresh
Compound Refresh
Maintain the quality of over time. This workflow reviews existing learnings against the current codebase, then refreshes any derived pattern docs that depend on them.
docs/solutions/长期维护下文档的质量。该工作流会对照当前代码库审查现有学习文档,然后刷新所有依赖这些文档的衍生模式文档。
docs/solutions/Mode Detection
模式检测
Check if contains . If present, strip it from arguments (use the remainder as a scope hint) and run in autofix mode.
$ARGUMENTSmode:autofix| Mode | When | Behavior |
|---|---|---|
| Interactive (default) | User is present and can answer questions | Ask for decisions on ambiguous cases, confirm actions |
| Autofix | | No user interaction. Apply all unambiguous actions (Keep, Update, Consolidate, auto-Delete, Replace with sufficient evidence). Mark ambiguous cases as stale. Generate a summary report at the end. |
检查中是否包含。如果存在,将其从参数中移除(剩余部分作为范围提示)并以自动修复模式运行。
$ARGUMENTSmode:autofix| Mode | 触发时机 | 行为表现 |
|---|---|---|
| Interactive(默认) | 用户在场并能回答问题 | 针对模糊场景请求决策,确认操作 |
| Autofix | 参数中包含 | 无需用户交互。执行所有明确操作(保留、更新、合并、自动删除、有充分证据时替换)。将模糊场景标记为陈旧。最终生成汇总报告。 |
Autofix mode rules
自动修复模式规则
- Skip all user questions. Never pause for input.
- Process all docs in scope. No scope narrowing questions — if no scope hint was provided, process everything.
- Attempt all safe actions: Keep (no-op), Update (fix references), Consolidate (merge and delete subsumed doc), auto-Delete (unambiguous criteria met), Replace (when evidence is sufficient). If a write succeeds, record it as applied. If a write fails (e.g., permission denied), record the action as recommended in the report and continue — do not stop or ask for permissions.
- Mark as stale when uncertain. If classification is genuinely ambiguous (Update vs Replace vs Consolidate vs Delete) or Replace evidence is insufficient, mark as stale with ,
status: stale, andstale_reasonin the frontmatter. If even the stale-marking write fails, include it as a recommendation.stale_date - Use conservative confidence. In interactive mode, borderline cases get a user question. In autofix mode, borderline cases get marked stale. Err toward stale-marking over incorrect action.
- Always generate a report. The report is the primary deliverable. It has two sections: Applied (actions that were successfully written) and Recommended (actions that could not be written, with full rationale so a human can apply them or run the skill interactively). The report structure is the same regardless of what permissions were granted — the only difference is which section each action lands in.
- 跳过所有用户提问:绝不暂停等待输入。
- 处理范围内所有文档:不询问范围缩小问题——如果未提供范围提示,则处理所有内容。
- 尝试所有安全操作:保留(无操作)、更新(修复引用)、合并(合并内容并删除被覆盖文档)、自动删除(满足明确标准)、替换(有充分证据时)。如果写入成功,记录为已执行。如果写入失败(如权限不足),在报告中记录为建议操作并继续——不要停止或请求权限。
- 不确定时标记为陈旧:如果分类确实模糊(更新vs替换vs合并vs删除)或替换证据不足,在frontmatter中添加、
status: stale和stale_reason标记为陈旧。如果标记陈旧的写入操作也失败,将其纳入建议。stale_date - 使用保守的置信度:在交互式模式下,边缘情况会询问用户;在自动修复模式下,边缘情况会被标记为陈旧。宁肯标记为陈旧,也不执行错误操作。
- 始终生成报告:报告是主要交付物。包含两个部分:已执行(成功写入的操作)和建议(无法写入的操作,附带完整理由供人工执行或交互式运行该技能)。无论授予何种权限,报告结构保持不变——唯一区别是每个操作所属的部分。
Interaction Principles
交互原则
These principles apply to interactive mode only. In autofix mode, skip all user questions and apply the autofix mode rules above.
Follow the same interaction style as :
ce-brainstorm- Ask questions one at a time — use the platform's blocking question tool when available (in Claude Code,
AskUserQuestionin Codex,request_user_inputin Gemini). Otherwise, present numbered options in plain text and wait for the user's reply before continuingask_user - Prefer multiple choice when natural options exist
- Start with scope and intent, then narrow only when needed
- Do not ask the user to make decisions before you have evidence
- Lead with a recommendation and explain it briefly
The goal is not to force the user through a checklist. The goal is to help them make a good maintenance decision with the smallest amount of friction.
以下原则仅适用于交互式模式。自动修复模式下,请跳过所有用户提问并遵循上述自动修复模式规则。
遵循与相同的交互风格:
ce-brainstorm- 一次只提一个问题——如果平台提供阻塞式提问工具(如Claude Code中的、Codex中的
AskUserQuestion、Gemini中的request_user_input),请使用该工具。否则,以纯文本形式列出编号选项,等待用户回复后再继续ask_user - 优先使用选择题——当存在自然选项时
- 从范围和意图开始——仅在必要时缩小范围
- 在获取证据前不要让用户做决策
- 先给出建议并简要解释
目标不是迫使用户完成检查清单,而是帮助他们以最小的摩擦做出良好的维护决策。
Refresh Order
刷新顺序
Refresh in this order:
- Review the relevant individual learning docs first
- Note which learnings stayed valid, were updated, were consolidated, were replaced, or were deleted
- Then review any pattern docs that depend on those learnings
Why this order:
- learning docs are the primary evidence
- pattern docs are derived from one or more learnings
- stale learnings can make a pattern look more valid than it really is
If the user starts by naming a pattern doc, you may begin there to understand the concern, but inspect the supporting learning docs before changing the pattern.
按以下顺序进行刷新:
- 首先审查相关的单个学习文档
- 记录哪些学习文档仍然有效、已更新、已合并、已替换或已删除
- 然后审查所有依赖这些学习文档的模式文档
为何采用此顺序:
- 学习文档是主要证据
- 模式文档源自一个或多个学习文档
- 陈旧的学习文档可能会让模式看起来比实际更有效
如果用户从指定某份模式文档开始,你可以先从该文档入手了解问题,但在修改模式前必须检查其支撑的学习文档。
Maintenance Model
维护模型
For each candidate artifact, classify it into one of five outcomes:
| Outcome | Meaning | Default action |
|---|---|---|
| Keep | Still accurate and still useful | No file edit by default; report that it was reviewed and remains trustworthy |
| Update | Core solution is still correct, but references drifted | Apply evidence-backed in-place edits |
| Consolidate | Two or more docs overlap heavily but are both correct | Merge unique content into the canonical doc, delete the subsumed doc |
| Replace | The old artifact is now misleading, but there is a known better replacement | Create a trustworthy successor, then delete the old artifact |
| Delete | No longer useful, applicable, or distinct | Delete the file — git history preserves it if anyone needs to recover it later |
对于每个候选文档,将其归类为以下五种结果之一:
| 结果 | 含义 | 默认操作 |
|---|---|---|
| Keep(保留) | 仍然准确且有用 | 默认不编辑文件;报告该文档已审查且仍可信 |
| Update(更新) | 核心解决方案仍然正确,但引用内容已偏离 | 基于证据进行原地编辑 |
| Consolidate(合并) | 两份或多份文档高度重叠但均正确 | 将独特内容合并到标准文档中,删除被覆盖的文档 |
| Replace(替换) | 旧文档现在具有误导性,但存在已知的更好替代方案 | 创建可信的替代文档,然后删除旧文档 |
| Delete(删除) | 不再有用、适用或具有独特性 | 删除文件——git历史记录会保留该文件,供日后需要恢复时使用 |
Core Rules
核心规则
- Evidence informs judgment. The signals below are inputs, not a mechanical scorecard. Use engineering judgment to decide whether the artifact is still trustworthy.
- Prefer no-write Keep. Do not update a doc just to leave a review breadcrumb.
- Match docs to reality, not the reverse. When current code differs from a learning, update the learning to reflect the current code. The skill's job is doc accuracy, not code review — do not ask the user whether code changes were "intentional" or "a regression." If the code changed, the doc should match. If the user thinks the code is wrong, that is a separate concern outside this workflow.
- Be decisive, minimize questions. When evidence is clear (file renamed, class moved, reference broken), apply the update. In interactive mode, only ask the user when the right action is genuinely ambiguous. In autofix mode, mark ambiguous cases as stale instead of asking. The goal is automated maintenance with human oversight on judgment calls, not a question for every finding.
- Avoid low-value churn. Do not edit a doc just to fix a typo, polish wording, or make cosmetic changes that do not materially improve accuracy or usability.
- Use Update only for meaningful, evidence-backed drift. Paths, module names, related links, category metadata, code snippets, and clearly stale wording are fair game when fixing them materially improves accuracy.
- Use Replace only when there is a real replacement. That means either:
- the current conversation contains a recently solved, verified replacement fix, or
- the user has provided enough concrete replacement context to document the successor honestly, or
- the codebase investigation found the current approach and can document it as the successor, or
- newer docs, pattern docs, PRs, or issues provide strong successor evidence.
- Delete when the code is gone. If the referenced code, controller, or workflow no longer exists in the codebase and no successor can be found, delete the file — don't default to Keep just because the general advice is still "sound." A learning about a deleted feature misleads readers into thinking that feature still exists. When in doubt between Keep and Delete, ask the user (in interactive mode) or mark as stale (in autofix mode). But missing referenced files with no matching code is not a doubt case — it is strong, unambiguous Delete evidence. Auto-delete it.
- Evaluate document-set design, not just accuracy. In addition to checking whether each doc is accurate, evaluate whether it is still the right unit of knowledge. If two or more docs overlap heavily, determine whether they should remain separate, be cross-scoped more clearly, or be consolidated into one canonical document. Redundant docs are dangerous because they drift silently — two docs saying the same thing will eventually say different things.
- Delete, don't archive. There is no directory. When a doc is no longer useful, delete it. Git history preserves every deleted file — that is the archive. A dedicated archive directory creates problems: archived docs accumulate, pollute search results, and nobody reads them. If someone needs a deleted doc,
_archived/will find it.git log --diff-filter=D -- docs/solutions/
- 证据指导判断:以下信号是输入,而非机械评分卡。运用工程判断来决定文档是否仍然可信。
- 优先选择无需写入的保留操作:不要仅为留下审查痕迹而更新文档。
- 让文档匹配现实,而非相反:当当前代码与学习文档不符时,更新学习文档以反映当前代码。该技能的职责是保证文档准确性,而非代码审查——不要询问用户代码变更是否“有意”或“是回归问题”。如果代码变更了,文档应与之匹配。如果用户认为代码有误,那是此工作流之外的单独问题。
- 果断决策,减少提问:当证据明确(文件重命名、类移动、引用失效)时,直接执行更新。在交互式模式下,仅当正确操作确实模糊时才询问用户。在自动修复模式下,将模糊情况标记为陈旧而非提问。目标是实现自动化维护,仅在需要判断时由人工监督,而非对每个发现都提问。
- 避免低价值变动:不要仅为修复拼写错误、润色措辞或进行不实质提升准确性或可用性的 cosmetic(外观)修改而编辑文档。
- 仅针对有意义的、基于证据的偏离使用更新操作:路径、模块名称、相关链接、分类元数据、代码片段和明显陈旧的措辞,修复这些内容能实质提升准确性时,才进行修改。
- 仅当存在真实替代方案时使用替换操作:这意味着:
- 当前对话包含最近解决并验证的替代方案,或
- 用户提供了足够具体的替代上下文以如实记录替代文档,或
- 代码库调查发现了当前方案并可将其记录为替代方案,或
- 较新的文档、模式文档、PR或问题提供了强有力的替代证据。
- 代码删除时删除文档:如果引用的代码、控制器或工作流在代码库中已不存在且找不到替代方案,则删除文件——不要仅因为通用建议仍然“合理”就默认保留。关于已删除功能的学习文档会误导读者认为该功能仍然存在。在保留和删除之间存疑时,(在交互式模式下)询问用户或(在自动修复模式下)标记为陈旧。但引用文件缺失且无匹配代码的情况不属于存疑场景——这是明确的删除证据。自动删除该文件。
- 评估文档集设计,而非仅准确性:除了检查每份文档是否准确外,还要评估它是否仍是合适的知识单元。如果两份或多份文档高度重叠,确定它们是否应保持独立、更清晰地交叉关联,或合并为一份标准文档。冗余文档很危险,因为它们会悄然偏离——两份表述相同的文档最终会出现差异。
- 删除,而非归档:不存在目录。当文档不再有用时,删除它。Git历史记录会保留所有已删除文件——这就是归档。专用归档目录会带来问题:归档文档会堆积、污染搜索结果,且无人阅读。如果有人需要已删除的文档,
_archived/可以找到它。git log --diff-filter=D -- docs/solutions/
Scope Selection
范围选择
Start by discovering learnings and pattern docs under .
docs/solutions/Exclude:
README.md- (legacy — if this directory exists, flag it for cleanup in the report)
docs/solutions/_archived/
Find all files under , excluding files and anything under . If an directory exists, note it in the report as a legacy artifact that should be cleaned up (files either restored or deleted).
.mddocs/solutions/README.md_archived/_archived/If is provided, use it to narrow scope before proceeding. Try these matching strategies in order, stopping at the first that produces results:
$ARGUMENTS- Directory match — check if the argument matches a subdirectory name under (e.g.,
docs/solutions/,performance-issues)database-issues - Frontmatter match — search ,
module, orcomponentfields in learning frontmatter for the argumenttags - Filename match — match against filenames (partial matches are fine)
- Content search — search file contents for the argument as a keyword (useful for feature names or feature areas)
If no matches are found, report that and ask the user to clarify. In autofix mode, report the miss and stop — do not guess at scope.
If no candidate docs are found, report:
text
No candidate docs found in docs/solutions/.
Run `ce-compound` after solving problems to start building your knowledge base.首先发现下的学习文档和模式文档。
docs/solutions/排除:
README.md- (遗留目录——如果存在该目录,在报告中标记为需要清理)
docs/solutions/_archived/
查找下所有文件,排除和下的所有文件。如果存在目录,在报告中注明这是需要清理的遗留工件(文件要么恢复要么删除)。
docs/solutions/.mdREADME.md_archived/_archived/如果提供了,在继续前使用它缩小范围。按以下匹配策略依次尝试,直到找到结果:
$ARGUMENTS- 目录匹配——检查参数是否匹配下的子目录名称(如
docs/solutions/、performance-issues)database-issues - Frontmatter匹配——在学习文档的frontmatter中搜索、
module或component字段是否包含该参数tags - 文件名匹配——匹配文件名(部分匹配即可)
- 内容搜索——在文件内容中搜索该参数作为关键词(适用于功能名称或功能领域)
如果未找到匹配项,报告该情况并请用户澄清。在自动修复模式下,报告未找到匹配项并停止——不要猜测范围。
如果未找到候选文档,报告:
text
未在docs/solutions/中找到候选文档。
解决问题后运行`ce-compound`以开始构建你的知识库。Phase 0: Assess and Route
阶段0:评估与路由
Before asking the user to classify anything:
- Discover candidate artifacts
- Estimate scope
- Choose the lightest interaction path that fits
在要求用户进行任何分类之前:
- 发现候选工件
- 估算范围
- 选择最合适的最轻量交互路径
Route by Scope
按范围路由
| Scope | When to use it | Interaction style |
|---|---|---|
| Focused | 1-2 likely files or user named a specific doc | Investigate directly, then present a recommendation |
| Batch | Up to ~8 mostly independent docs | Investigate first, then present grouped recommendations |
| Broad | 9+ docs, ambiguous, or repo-wide stale-doc sweep | Triage first, then investigate in batches |
| 范围 | 使用场景 | 交互风格 |
|---|---|---|
| 聚焦式 | 1-2个可能的文件或用户指定了某份具体文档 | 直接调查,然后给出建议 |
| 批量式 | 最多约8个基本独立的文档 | 先调查,然后分组呈现建议 |
| 宽泛式 | 9个以上文档、范围模糊或全仓库陈旧文档清理 | 先分类筛选,然后分批调查 |
Broad Scope Triage
宽泛范围分类筛选
When scope is broad (9+ candidate docs), do a lightweight triage before deep investigation:
- Inventory — read frontmatter of all candidate docs, group by module/component/category
- Impact clustering — identify areas with the densest clusters of learnings + pattern docs. A cluster of 5 learnings and 2 patterns covering the same module is higher-impact than 5 isolated single-doc areas, because staleness in one doc is likely to affect the others.
- Spot-check drift — for each cluster, check whether the primary referenced files still exist. Missing references in a high-impact cluster = strongest signal for where to start.
- Recommend a starting area — present the highest-impact cluster with a brief rationale and ask the user to confirm or redirect. In autofix mode, skip the question and process all clusters in impact order.
Example:
text
Found 24 learnings across 5 areas.
The auth module has 5 learnings and 2 pattern docs that cross-reference
each other — and 3 of those reference files that no longer exist.
I'd start there.
1. Start with auth (recommended)
2. Pick a different area
3. Review everythingDo not ask action-selection questions yet. First gather evidence.
当范围宽泛(9个以上候选文档)时,在深入调查前进行轻量级分类筛选:
- 盘点——读取所有候选文档的frontmatter,按模块/组件/分类分组
- 影响聚类——识别学习文档+模式文档最密集的领域。涵盖同一模块的5份学习文档和2份模式文档的聚类,比5个孤立的单文档领域影响更大,因为一份文档的陈旧可能会影响其他文档。
- 抽查偏离情况——对于每个聚类,检查主要引用文件是否仍然存在。高影响聚类中存在缺失引用是最强烈的起始信号。
- 建议起始领域——呈现影响最高的聚类并简要说明理由,请求用户确认或重定向。在自动修复模式下,跳过提问并按影响顺序处理所有聚类。
示例:
text
在5个领域中找到24份学习文档。
auth模块有5份学习文档和2份模式文档相互交叉引用——其中3份引用的文件已不存在。
我建议从这里开始。
1. 从auth开始(推荐)
2. 选择其他领域
3. 审查所有内容此时不要询问操作选择问题。先收集证据。
Phase 1: Investigate Candidate Learnings
阶段1:调查候选学习文档
For each learning in scope, read it, cross-reference its claims against the current codebase, and form a recommendation.
A learning has several dimensions that can independently go stale. Surface-level checks catch the obvious drift, but staleness often hides deeper:
- References — do the file paths, class names, and modules it mentions still exist or have they moved?
- Recommended solution — does the fix still match how the code actually works today? A renamed file with a completely different implementation pattern is not just a path update.
- Code examples — if the learning includes code snippets, do they still reflect the current implementation?
- Related docs — are cross-referenced learnings and patterns still present and consistent?
- Auto memory (Claude Code only) — does the injected auto-memory block in your system prompt contain entries in the same problem domain? Scan that block directly. If the block is absent, skip this dimension. A memory note describing a different approach than what the learning recommends is a supplementary drift signal.
- Overlap — while investigating, note when another doc in scope covers the same problem domain, references the same files, or recommends a similar solution. For each overlap, record: the two file paths, which dimensions overlap (problem, solution, root cause, files, prevention), and which doc appears broader or more current. These signals feed Phase 1.75 (Document-Set Analysis).
Match investigation depth to the learning's specificity — a learning referencing exact file paths and code snippets needs more verification than one describing a general principle.
对于范围内的每份学习文档,读取内容,对照当前代码库验证其主张,并形成建议。
学习文档的多个维度可能会独立变得陈旧。表面检查可以发现明显的偏离,但陈旧性往往隐藏在更深层次:
- 引用——它提及的文件路径、类名和模块是否仍然存在或已移动?
- 推荐解决方案——该修复方案是否仍然与当前代码的实际工作方式匹配?重命名的文件如果实现模式完全不同,就不只是路径更新的问题。
- 代码示例——如果学习文档包含代码片段,它们是否仍然反映当前实现?
- 相关文档——交叉引用的学习文档和模式文档是否仍然存在且一致?
- 自动记忆(仅Claude Code)——你的系统提示中注入的自动记忆块是否包含同一问题域的条目?直接扫描该块。如果该块不存在,跳过此维度。记忆笔记中描述的方法与学习文档推荐的方法不同,是补充性的偏离信号。
- 重叠——在调查时,记录范围内另一份文档是否涵盖同一问题域、引用相同文件或推荐类似解决方案。对于每一处重叠,记录:两个文件路径、重叠维度(问题、解决方案、根本原因、文件、预防措施)、以及哪份文档更全面或更新。这些信号将用于阶段1.75(文档集分析)。
根据学习文档的具体程度调整调查深度——引用确切文件路径和代码片段的学习文档比描述通用原则的文档需要更多验证。
Drift Classification: Update vs Replace
偏离分类:更新vs替换
The critical distinction is whether the drift is cosmetic (references moved but the solution is the same) or substantive (the solution itself changed):
- Update territory — file paths moved, classes renamed, links broke, metadata drifted, but the core recommended approach is still how the code works. fixes these directly.
ce-compound-refresh - Replace territory — the recommended solution conflicts with current code, the architectural approach changed, or the pattern is no longer the preferred way. This means a new learning needs to be written. A replacement subagent writes the successor following 's document format (frontmatter, problem, root cause, solution, prevention), using the investigation evidence already gathered. The orchestrator does not rewrite learnings inline — it delegates to a subagent for context isolation.
ce-compound
The boundary: if you find yourself rewriting the solution section or changing what the learning recommends, stop — that is Replace, not Update.
Memory-sourced drift signals are supplementary, not primary. A memory note describing a different approach does not alone justify Replace or Delete. Use memory signals to:
- Corroborate codebase-sourced drift (strengthens the case for Replace)
- Prompt deeper investigation when codebase evidence is borderline
- Add context to the evidence report ("(auto memory [claude]) notes suggest approach X may have changed since this learning was written")
In autofix mode, memory-only drift (no codebase corroboration) should result in stale-marking, not action.
关键区别在于偏离是外观性(引用移动但解决方案相同)还是实质性(解决方案本身已更改):
- 更新适用场景——文件路径移动、类重命名、链接失效、元数据偏离,但核心推荐方法仍然符合代码工作方式。会直接修复这些问题。
ce-compound-refresh - 替换适用场景——推荐解决方案与当前代码冲突、架构方法更改或模式不再是首选方式。这意味着需要编写新的学习文档。替换子代理会遵循的文档格式(frontmatter、问题、根本原因、解决方案、预防措施)编写替代文档,使用已收集的调查证据。协调器不会内联重写学习文档——它会委托给子代理以实现上下文隔离。
ce-compound
边界:如果你发现自己需要重写解决方案部分或更改学习文档的推荐内容,请停止——这属于替换,而非更新。
基于记忆的偏离信号是补充性的,而非主要信号。仅记忆笔记中描述的不同方法不足以证明替换或删除的合理性。使用记忆信号:
- 佐证基于代码库的偏离(强化替换的理由)
- 当代码库证据不明确时,促使深入调查
- 为证据报告添加上下文(“(auto memory [claude]) 笔记表明自该学习文档编写以来,方法X可能已更改”)
在自动修复模式下,仅基于记忆的偏离(无代码库佐证)应标记为陈旧,而非执行操作。
Judgment Guidelines
判断指南
Three guidelines that are easy to get wrong:
- Contradiction = strong Replace signal. If the learning's recommendation conflicts with current code patterns or a recently verified fix, that is not a minor drift — the learning is actively misleading. Classify as Replace.
- Age alone is not a stale signal. A 2-year-old learning that still matches current code is fine. Only use age as a prompt to inspect more carefully.
- Check for successors before deleting. Before recommending Replace or Delete, look for newer learnings, pattern docs, PRs, or issues covering the same problem space. If successor evidence exists, prefer Replace over Delete so readers are directed to the newer guidance.
三个容易出错的指南:
- 矛盾=强烈的替换信号——如果学习文档的推荐与当前代码模式或最近验证的修复冲突,这不是轻微偏离——学习文档具有误导性。归类为替换。
- 仅年龄不是陈旧信号——一份2年前的学习文档如果仍然匹配当前代码,就是没问题的。仅将年龄作为更仔细检查的提示。
- 删除前检查是否有替代方案——在建议替换或删除前,查找涵盖同一问题空间的较新学习文档、模式文档、PR或问题。如果存在替代证据,优先选择替换而非删除,以便读者被引导至较新的指南。
Phase 1.5: Investigate Pattern Docs
阶段1.5:调查模式文档
After reviewing the underlying learning docs, investigate any relevant pattern docs under .
docs/solutions/patterns/Pattern docs are high-leverage — a stale pattern is more dangerous than a stale individual learning because future work may treat it as broadly applicable guidance. Evaluate whether the generalized rule still holds given the refreshed state of the learnings it depends on.
A pattern doc with no clear supporting learnings is a stale signal — investigate carefully before keeping it unchanged.
审查完基础学习文档后,调查下的所有相关模式文档。
docs/solutions/patterns/模式文档的影响力很高——陈旧的模式比陈旧的单个学习文档更危险,因为未来的工作可能会将其视为广泛适用的指南。根据其所依赖的学习文档的刷新状态,评估通用规则是否仍然成立。
没有明确支撑学习文档的模式文档是陈旧信号——在保持不变前需仔细调查。
Phase 1.75: Document-Set Analysis
阶段1.75:文档集分析
After investigating individual docs, step back and evaluate the document set as a whole. The goal is to catch problems that only become visible when comparing docs to each other — not just to reality.
调查完单个文档后,退一步从整体评估文档集。目标是发现只有在文档之间对比时才会显现的问题——而非仅与现实对比。
Overlap Detection
重叠检测
For docs that share the same module, component, tags, or problem domain, compare them across these dimensions:
- Problem statement — do they describe the same underlying problem?
- Solution shape — do they recommend the same approach, even if worded differently?
- Referenced files — do they point to the same code paths?
- Prevention rules — do they repeat the same prevention bullets?
- Root cause — do they identify the same root cause?
High overlap across 3+ dimensions is a strong Consolidate signal. The question to ask: "Would a future maintainer need to read both docs to get the current truth, or is one mostly repeating the other?"
对于共享同一模块、组件、标签或问题域的文档,从以下维度进行比较:
- 问题陈述——它们是否描述相同的潜在问题?
- 解决方案形态——它们是否推荐相同的方法,即使措辞不同?
- 引用文件——它们是否指向相同的代码路径?
- 预防规则——它们是否重复相同的预防措施要点?
- 根本原因——它们是否识别出相同的根本原因?
在3个以上维度高度重叠是强烈的合并信号。需要问的问题是:“未来的维护人员是否需要阅读两份文档才能了解当前真相,还是其中一份主要重复另一份的内容?”
Supersession Signals
取代信号
Detect "older narrow precursor, newer canonical doc" patterns:
- A newer doc covers the same files, same workflow, and broader runtime behavior than an older doc
- An older doc describes a specific incident that a newer doc generalizes into a pattern
- Two docs recommend the same fix but the newer one has better context, examples, or scope
When a newer doc clearly subsumes an older one, the older doc is a consolidation candidate — its unique content (if any) should be merged into the newer doc, and the older doc should be deleted.
检测“旧的窄范围前驱文档,新的标准文档”模式:
- 较新的文档涵盖相同文件、相同工作流,且比旧文档覆盖更广泛的运行时行为
- 旧文档描述的特定事件被较新的文档概括为模式
- 两份文档推荐相同的修复,但较新的文档具有更好的上下文、示例或范围
当较新的文档明显覆盖旧文档时,旧文档是合并候选——其独特内容(如果有)应合并到较新的文档中,然后删除旧文档。
Canonical Doc Identification
标准文档识别
For each topic cluster (docs sharing a problem domain), identify which doc is the canonical source of truth:
- Usually the most recent, broadest, most accurate doc in the cluster
- The one a maintainer should find first when searching for this topic
- The one that other docs should point to, not duplicate
All other docs in the cluster are either:
- Distinct — they cover a meaningfully different sub-problem and have independent retrieval value. Keep them separate.
- Subsumed — their unique content fits as a section in the canonical doc. Consolidate.
- Redundant — they add nothing the canonical doc doesn't already say. Delete.
对于每个主题聚类(共享同一问题域的文档),识别哪份文档是权威真相来源:
- 通常是聚类中最新、最全面、最准确的文档
- 维护人员搜索该主题时应首先找到的文档
- 其他文档应指向的文档,而非重复的文档
聚类中的所有其他文档要么是:
- 独特的——它们涵盖有意义的不同子问题,具有独立检索价值。保持独立。
- 被覆盖的——其独特内容适合作为标准文档的一个章节。合并。
- 冗余的——它们没有提供标准文档未涵盖的内容。删除。
Retrieval-Value Test
检索价值测试
Before recommending that two docs stay separate, apply this test: "If a maintainer searched for this topic six months from now, would having these as separate docs improve discoverability, or just create drift risk?"
Separate docs earn their keep only when:
- They cover genuinely different sub-problems that someone might search for independently
- They target different audiences or contexts (e.g., one is about debugging, another about prevention)
- Merging them would create an unwieldy doc that is harder to navigate than two focused ones
If none of these apply, prefer consolidation. Two docs covering the same ground will eventually drift apart and contradict each other — that is worse than a slightly longer single doc.
在建议两份文档保持独立前,应用此测试:“如果维护人员在六个月后搜索该主题,将这些文档分开是否能提高可发现性,还是只会增加偏离风险?”
只有满足以下条件时,分开的文档才有存在的价值:
- 它们涵盖真正不同的子问题,有人可能会独立搜索这些子问题
- 它们针对不同的受众或场景(例如,一份关于调试,另一份关于预防)
- 合并它们会创建一个难以导航的冗长文档,比两份聚焦的文档更难使用
如果以上条件都不满足,优先选择合并。两份涵盖相同内容的文档最终会偏离并相互矛盾——这比一份稍长的单文档更糟糕。
Cross-Doc Conflict Check
跨文档冲突检查
Look for outright contradictions between docs in scope:
- Doc A says "always use approach X" while Doc B says "avoid approach X"
- Doc A references a file path that Doc B says was deprecated
- Doc A and Doc B describe different root causes for what appears to be the same problem
Contradictions between docs are more urgent than individual staleness — they actively confuse readers. Flag these for immediate resolution, either through Consolidate (if one is right and the other is a stale version of the same truth) or through targeted Update/Replace.
查找范围内文档之间的明显矛盾:
- 文档A说“始终使用方法X”,而文档B说“避免使用方法X”
- 文档A引用的文件路径被文档B标记为已弃用
- 文档A和文档B描述的根本原因似乎针对相同的问题
文档之间的矛盾比单个文档的陈旧更紧急——它们会直接混淆读者。标记这些矛盾以便立即解决,要么通过合并(如果其中一份正确,另一份是同一真相的陈旧版本),要么通过针对性的更新/替换。
Subagent Strategy
子代理策略
Use subagents for context isolation when investigating multiple artifacts — not just because the task sounds complex. Choose the lightest approach that fits:
| Approach | When to use |
|---|---|
| Main thread only | Small scope, short docs |
| Sequential subagents | 1-2 artifacts with many supporting files to read |
| Parallel subagents | 3+ truly independent artifacts with low overlap |
| Batched subagents | Broad sweeps — narrow scope first, then investigate in batches |
When spawning any subagent, omit the parameter so the user's configured permission settings apply. Include this instruction in its task prompt:
modeUse dedicated file search and read tools (Glob, Grep, Read) for all investigation. Do NOT use shell commands (ls, find, cat, grep, test, bash) for file operations. This avoids permission prompts and is more reliable.Also scan the "user's auto-memory" block injected into your system prompt (Claude Code only). Check for notes related to the learning's problem domain. Report any memory-sourced drift signals separately from codebase-sourced evidence, tagged with "(auto memory [claude])" in the evidence section. If the block is not present in your context, skip this check.
There are two subagent roles:
- Investigation subagents — read-only. They must not edit files, create successors, or delete anything. Each returns: file path, evidence, recommended action, confidence, and open questions. These can run in parallel when artifacts are independent.
- Replacement subagents — write a single new learning to replace a stale one. These run one at a time, sequentially (each replacement subagent may need to read significant code, and running multiple in parallel risks context exhaustion). The orchestrator handles all deletions and metadata updates after each replacement completes.
The orchestrator merges investigation results, detects contradictions, coordinates replacement subagents, and performs all deletions/metadata edits centrally. In interactive mode, it asks the user questions on ambiguous cases. In autofix mode, it marks ambiguous cases as stale instead. If two artifacts overlap or discuss the same root issue, investigate them together rather than parallelizing.
当调查多个工件时,使用子代理进行上下文隔离——不仅因为任务听起来复杂。选择最合适的最轻量方法:
| 方法 | 使用场景 |
|---|---|
| 仅主线程 | 范围小、文档短 |
| 顺序子代理 | 1-2个工件,有许多支撑文件需要读取 |
| 并行子代理 | 3个以上真正独立的工件,重叠度低 |
| 批量子代理 | 宽泛清理——先缩小范围,然后分批调查 |
生成任何子代理时,省略参数,以便应用用户配置的权限设置。在其任务提示中包含以下指令:
mode使用专用文件搜索和读取工具(Glob、Grep、Read)进行所有调查。请勿使用shell命令(ls、find、cat、grep、test、bash)进行文件操作。这可以避免权限提示,且更可靠。同时扫描系统提示中注入的“用户自动记忆”块(仅Claude Code)。检查与学习文档问题域相关的笔记。将任何基于记忆的偏离信号与基于代码库的证据分开报告,在证据部分标记为“(auto memory [claude])”。如果上下文不存在该块,跳过此检查。
有两种子代理角色:
- 调查子代理——只读。不得编辑文件、创建替代文档或删除任何内容。每个子代理返回:文件路径、证据、建议操作、置信度和未解决问题。当工件独立时,这些子代理可以并行运行。
- 替换子代理——编写单个新的学习文档以替换陈旧文档。这些子代理必须一次一个、按顺序运行(每个替换子代理可能需要读取大量代码,并行运行多个可能会导致上下文耗尽)。协调器在每次替换完成后处理所有删除和元数据更新。
协调器合并调查结果、检测矛盾、协调替换子代理,并集中执行所有删除/元数据编辑。在交互式模式下,它会就模糊情况询问用户。在自动修复模式下,它会将模糊情况标记为陈旧。如果两个工件重叠或讨论相同的根本问题,应一起调查而非并行处理。
Phase 2: Classify the Right Maintenance Action
阶段2:分类正确的维护操作
After gathering evidence, assign one recommended action.
收集证据后,分配一个建议操作。
Keep
保留(Keep)
The learning is still accurate and useful. Do not edit the file — report that it was reviewed and remains trustworthy. Only add if you are already making a meaningful update for another reason.
last_refreshed学习文档仍然准确且有用。不要编辑文件——报告该文档已审查且仍可信。仅当因其他原因进行有意义的更新时,才添加字段。
last_refreshedUpdate
更新(Update)
The core solution is still valid but references have drifted (paths, class names, links, code snippets, metadata). Apply the fixes directly.
核心解决方案仍然有效,但引用内容已偏离(路径、类名、链接、代码片段、元数据)。直接应用修复。
Consolidate
合并(Consolidate)
Choose Consolidate when Phase 1.75 identified docs that overlap heavily but are both materially correct. This is different from Update (which fixes drift in a single doc) and Replace (which rewrites misleading guidance). Consolidate handles the "both right, one subsumes the other" case.
When to consolidate:
- Two docs describe the same problem and recommend the same (or compatible) solution
- One doc is a narrow precursor and a newer doc covers the same ground more broadly
- The unique content from the subsumed doc can fit as a section or addendum in the canonical doc
- Keeping both creates drift risk without meaningful retrieval benefit
When NOT to consolidate (apply the Retrieval-Value Test from Phase 1.75):
- The docs cover genuinely different sub-problems that someone would search for independently
- Merging would create an unwieldy doc that harms navigation more than drift risk harms accuracy
Consolidate vs Delete: If the subsumed doc has unique content worth preserving (edge cases, alternative approaches, extra prevention rules), use Consolidate to merge that content first. If the subsumed doc adds nothing the canonical doc doesn't already say, skip straight to Delete.
The Consolidate action is: merge unique content from the subsumed doc into the canonical doc, then delete the subsumed doc. Not archive — delete. Git history preserves it.
当阶段1.75识别出高度重叠但均实质正确的文档时,选择合并。这不同于更新(修复单个文档的偏离)和替换(重写具有误导性的指南)。合并处理“两份都正确,一份覆盖另一份”的情况。
何时合并:
- 两份文档描述相同的问题并推荐相同(或兼容)的解决方案
- 一份文档是窄范围前驱文档,而较新的文档更全面地涵盖相同内容
- 被覆盖文档的独特内容可以作为标准文档的一个章节或附录
- 保留两份文档会增加偏离风险,且无有意义的检索收益
何时不合并(应用阶段1.75的检索价值测试):
- 文档涵盖真正不同的子问题,有人会独立搜索这些子问题
- 合并会创建一个难以导航的冗长文档,对导航的损害大于偏离风险对准确性的损害
**合并vs删除:**如果被覆盖文档有值得保留的独特内容(边缘情况、替代方法、额外预防规则),先使用合并将该内容合并。如果被覆盖文档没有提供标准文档未涵盖的内容,直接跳过至删除。
合并操作是:将被覆盖文档的独特内容合并到标准文档中,然后删除被覆盖文档。不要归档——删除。Git历史记录会保留它。
Replace
替换(Replace)
Choose Replace when the learning's core guidance is now misleading — the recommended fix changed materially, the root cause or architecture shifted, or the preferred pattern is different.
The user may have invoked the refresh months after the original learning was written. Do not ask them for replacement context they are unlikely to have — use agent intelligence to investigate the codebase and synthesize the replacement.
Evidence assessment:
By the time you identify a Replace candidate, Phase 1 investigation has already gathered significant evidence: the old learning's claims, what the current code actually does, and where the drift occurred. Assess whether this evidence is sufficient to write a trustworthy replacement:
- Sufficient evidence — you understand both what the old learning recommended AND what the current approach is. The investigation found the current code patterns, the new file locations, the changed architecture. → Proceed to write the replacement (see Phase 4 Replace Flow).
- Insufficient evidence — the drift is so fundamental that you cannot confidently document the current approach. The entire subsystem was replaced, or the new architecture is too complex to understand from a file scan alone. → Mark as stale in place:
- Add ,
status: stale,stale_reason: [what you found]to the frontmatterstale_date: YYYY-MM-DD - Report what evidence you found and what is missing
- Recommend the user run after their next encounter with that area, when they have fresh problem-solving context
ce-compound
- Add
当学习文档的核心指南现在具有误导性时选择替换——推荐的修复已实质更改、根本原因或架构已转变,或首选模式已不同。
用户可能在原始学习文档编写数月后调用刷新。不要询问他们不太可能拥有的替换上下文——使用代理智能调查代码库并合成替代文档。
证据评估:
当你识别出替换候选时,阶段1的调查已收集了大量证据:旧学习文档的主张、当前代码的实际行为、以及偏离发生的位置。评估此证据是否足以编写可信的替代文档:
- 证据充分——你既了解旧学习文档的推荐内容,也了解当前方法。调查发现了当前代码模式、新文件位置、已更改的架构。→ 继续编写替代文档(见阶段4替换流程)。
- 证据不足——偏离非常根本,你无法自信地记录当前方法。整个子系统已被替换,或新架构过于复杂,无法通过文件扫描理解。→ 原地标记为陈旧:
- 在frontmatter中添加、
status: stale、stale_reason: [你发现的内容]stale_date: YYYY-MM-DD - 报告你发现的证据和缺失的内容
- 建议用户下次遇到该领域时运行
ce-compound
- 在frontmatter中添加
Delete
删除(Delete)
Choose Delete when:
- The code or workflow no longer exists and the problem domain is gone
- The learning is obsolete and has no modern replacement worth documenting
- The learning is fully redundant with another doc (use Consolidate if there is unique content to merge first)
- There is no meaningful successor evidence suggesting it should be replaced instead
Action: delete the file. No archival directory, no metadata — just delete it. Git history preserves every deleted file if recovery is ever needed.
在以下情况选择删除:
- 代码或工作流已不存在,且问题域已消失
- 学习文档已过时,且没有值得记录的现代替代方案
- 学习文档与另一份文档完全冗余(如果有独特内容需要合并,先使用合并)
- 没有有意义的替代证据表明应替换而非删除
操作:删除文件。没有归档目录,没有元数据——直接删除。如果需要恢复,Git历史记录会保留所有已删除文件。
Before deleting: check if the problem domain is still active
删除前:检查问题域是否仍然活跃
When a learning's referenced files are gone, that is strong evidence — but only that the implementation is gone. Before deleting, reason about whether the problem the learning solves is still a concern in the codebase:
- A learning about session token storage where is gone — does the application still handle session tokens? If so, the concept persists under a new implementation. That is Replace, not Delete.
auth_token.rb - A learning about a deprecated API endpoint where the entire feature was removed — the problem domain is gone. That is Delete.
Do not search mechanically for keywords from the old learning. Instead, understand what problem the learning addresses, then investigate whether that problem domain still exists in the codebase. The agent understands concepts — use that understanding to look for where the problem lives now, not where the old code used to be.
Auto-delete only when both the implementation AND the problem domain are gone:
- the referenced code is gone AND the application no longer deals with that problem domain
- the learning is fully superseded by a clearly better successor AND the old doc adds no distinct value
- the document is plainly redundant and adds nothing the canonical doc doesn't already say
If the implementation is gone but the problem domain persists (the app still does auth, still processes payments, still handles migrations), classify as Replace — the problem still matters and the current approach should be documented.
Do not keep a learning just because its general advice is "still sound" — if the specific code it references is gone, the learning misleads readers. But do not delete a learning whose problem domain is still active — that knowledge gap should be filled with a replacement.
当学习文档引用的文件消失时,这是强有力的证据——但仅表明实现已消失。删除前,判断学习文档解决的问题在代码库中是否仍然是关注点:
- 一份关于会话令牌存储的学习文档,其中已消失——应用程序是否仍在处理会话令牌?如果是,该概念在新实现下仍然存在。这属于替换,而非删除。
auth_token.rb - 一份关于已弃用API端点的学习文档,其中整个功能已被移除——问题域已消失。这属于删除。
不要机械地搜索旧学习文档中的关键词。相反,理解学习文档解决的问题,然后调查该问题域是否仍存在于代码库中。代理理解概念——使用这种理解来查找问题现在所在的位置,而非旧代码曾经所在的位置。
仅当实现和问题域都消失时自动删除:
- 引用的代码已消失,且应用程序不再处理该问题域
- 学习文档已被明显更好的替代方案完全取代,且旧文档没有独特价值
- 文档明显冗余,没有提供标准文档未涵盖的内容
如果实现已消失但问题域仍然活跃(应用程序仍在处理认证、支付、迁移),归类为替换——问题仍然重要,应记录当前方法。
不要仅因为学习文档的通用建议“仍然合理”就保留它——如果它引用的特定代码已消失,该学习文档会误导读者。但不要删除问题域仍然活跃的学习文档——应通过替换填补知识空白。
Pattern Guidance
模式指南
Apply the same five outcomes (Keep, Update, Consolidate, Replace, Delete) to pattern docs, but evaluate them as derived guidance rather than incident-level learnings. Key differences:
- Keep: the underlying learnings still support the generalized rule and examples remain representative
- Update: the rule holds but examples, links, scope, or supporting references drifted
- Consolidate: two pattern docs generalize the same set of learnings or cover the same design concern — merge into one canonical pattern
- Replace: the generalized rule is now misleading, or the underlying learnings support a different synthesis. Base the replacement on the refreshed learning set — do not invent new rules from guesswork
- Delete: the pattern is no longer valid, no longer recurring, or fully subsumed by a stronger pattern doc with no unique content remaining
对模式文档应用相同的五种结果(保留、更新、合并、替换、删除),但将其作为衍生指南而非事件级学习文档进行评估。关键区别:
- 保留:基础学习文档仍然支持通用规则,且示例仍具代表性
- 更新:规则仍然成立,但示例、链接、范围或支撑引用已偏离
- 合并:两份模式文档概括了相同的学习文档集或涵盖相同的设计关注点——合并为一份标准模式
- 替换:通用规则现在具有误导性,或基础学习文档支持不同的综合结论。基于刷新后的学习文档集进行替换——不要凭空发明新规则
- 删除:模式不再有效、不再重复出现,或已被更强的模式文档完全覆盖且无独特内容剩余
Phase 3: Ask for Decisions
阶段3:请求决策
Autofix mode
自动修复模式
Skip this entire phase. Do not ask any questions. Do not present options. Do not wait for input. Proceed directly to Phase 4 and execute all actions based on the classifications from Phase 2:
- Unambiguous Keep, Update, Consolidate, auto-Delete, and Replace (with sufficient evidence) → execute directly
- Ambiguous cases → mark as stale
- Then generate the report (see Output Format)
**跳过整个阶段。不要提问。不要呈现选项。不要等待输入。**直接进入阶段4,根据阶段2的分类执行所有操作:
- 明确的保留、更新、合并、自动删除和替换(证据充分)→ 直接执行
- 模糊情况 → 标记为陈旧
- 然后生成报告(见输出格式)
Interactive mode
交互式模式
Most Updates and Consolidations should be applied directly without asking. Only ask the user when:
- The right action is genuinely ambiguous (Update vs Replace vs Consolidate vs Delete)
- You are about to Delete a document and the evidence is not unambiguous (see auto-delete criteria in Phase 2). When auto-delete criteria are met, proceed without asking.
- You are about to Consolidate and the choice of canonical doc is not clear-cut
- You are about to create a successor via Replace
Do not ask questions about whether code changes were intentional, whether the user wants to fix bugs in the code, or other concerns outside doc maintenance. Stay in your lane — doc accuracy.
大多数更新和合并应直接应用,无需询问。仅在以下情况询问用户:
- 正确操作确实模糊(更新vs替换vs合并vs删除)
- 你即将删除文档且证据不明确(见阶段2的自动删除标准)。当满足自动删除标准时,直接执行无需询问。
- 你即将合并且标准文档的选择不明确
- 你即将通过替换创建替代文档
不要询问代码变更是否有意、用户是否想要修复代码中的错误,或其他文档维护之外的问题。专注于你的职责——文档准确性。
Question Style
提问风格
Always present choices using the platform's blocking question tool when available ( in Claude Code, in Codex, in Gemini). Otherwise, present numbered options in plain text and wait for the user's reply before proceeding.
AskUserQuestionrequest_user_inputask_userQuestion rules:
- Ask one question at a time
- Prefer multiple choice
- Lead with the recommended option
- Explain the rationale for the recommendation in one concise sentence
- Avoid asking the user to choose from actions that are not actually plausible
如果平台提供阻塞式提问工具(如Claude Code中的、Codex中的、Gemini中的),始终使用该工具呈现选项。否则,以纯文本形式列出编号选项,等待用户回复后再继续。
AskUserQuestionrequest_user_inputask_user提问规则:
- 一次只提一个问题
- 优先使用选择题
- 先给出推荐选项
- 用一句话简要解释推荐理由
- 避免让用户选择实际上不可行的操作
Focused Scope
聚焦范围
For a single artifact, present:
- file path
- 2-4 bullets of evidence
- recommended action
Then ask:
text
This [learning/pattern] looks like a [Keep/Update/Consolidate/Replace/Delete].
Why: [one-sentence rationale based on the evidence]
What would you like to do?
1. [Recommended action]
2. [Second plausible action]
3. Skip for nowDo not list all five actions unless all five are genuinely plausible.
对于单个工件,呈现:
- 文件路径
- 2-4条证据要点
- 推荐操作
然后询问:
text
这份[学习/模式]文档看起来适合[保留/更新/合并/替换/删除]。
理由:[基于证据的一句话理由]
你想要执行什么操作?
1. [推荐操作]
2. [第二个可行操作]
3. 暂时跳过除非所有五种操作都真正可行,否则不要列出全部五种。
Batch Scope
批量范围
For several learnings:
- Group obvious Keep cases together
- Group obvious Update cases together when the fixes are straightforward
- Present Consolidate cases together when the canonical doc is clear
- Present Replace cases individually or in very small groups
- Present Delete cases individually unless they are strong auto-delete candidates
Ask for confirmation in stages:
- Confirm grouped Keep/Update recommendations
- Then handle Consolidate groups (present the canonical doc and what gets merged)
- Then handle Replace one at a time
- Then handle Delete one at a time unless the deletion is unambiguous and safe to auto-apply
对于多份学习文档:
- 将明显的保留案例分组
- 当修复简单时,将明显的更新案例分组
- 当标准文档明确时,将合并案例分组呈现
- 单独或非常小的组呈现替换案例
- 单独呈现删除案例,除非它们是强自动删除候选
分阶段请求确认:
- 确认分组的保留/更新建议
- 然后处理组合并案例(呈现标准文档和要合并的内容)
- 然后逐个处理替换案例
- 然后逐个处理删除案例,除非删除明确且安全可自动执行
Broad Scope
宽泛范围
If the user asked for a sweeping refresh, keep the interaction incremental:
- Narrow scope first
- Investigate a manageable batch
- Present recommendations
- Ask whether to continue to the next batch
Do not front-load the user with a full maintenance queue.
如果用户要求全面刷新,保持交互增量式:
- 先缩小范围
- 调查可管理的批次
- 呈现建议
- 询问是否继续处理下一批次
不要一次性向用户展示完整的维护队列。
Phase 4: Execute the Chosen Action
阶段4:执行所选操作
Keep Flow
保留流程
No file edit by default. Summarize why the learning remains trustworthy.
默认不编辑文件。总结为何该学习文档仍然可信。
Update Flow
更新流程
Apply in-place edits only when the solution is still substantively correct.
Examples of valid in-place updates:
- Rename reference to
app/models/auth_token.rbapp/models/session_token.rb - Update to
module: AuthTokenmodule: SessionToken - Fix outdated links to related docs
- Refresh implementation notes after a directory move
Examples that should not be in-place updates:
- Fixing a typo with no effect on understanding
- Rewording prose for style alone
- Small cleanup that does not materially improve accuracy or usability
- The old fix is now an anti-pattern
- The system architecture changed enough that the old guidance is misleading
- The troubleshooting path is materially different
Those cases require Replace, not Update.
仅当解决方案仍然实质正确时,应用原地编辑。
有效原地更新示例:
- 将引用重命名为
app/models/auth_token.rbapp/models/session_token.rb - 将更新为
module: AuthTokenmodule: SessionToken - 修复指向相关文档的过时链接
- 目录移动后刷新实现说明
不应进行原地更新的示例:
- 修复不影响理解的拼写错误
- 仅为风格重写 prose(散文)
- 不实质提升准确性或可用性的小清理
- 旧修复现在是反模式
- 系统架构变更足够大,旧指南具有误导性
- 故障排除路径已实质不同
这些情况需要替换,而非更新。
Consolidate Flow
合并流程
The orchestrator handles consolidation directly (no subagent needed — the docs are already read and the merge is a focused edit). Process Consolidate candidates by topic cluster. For each cluster identified in Phase 1.75:
- Confirm the canonical doc — the broader, more current, more accurate doc in the cluster.
- Extract unique content from the subsumed doc(s) — anything the canonical doc does not already cover. This might be specific edge cases, additional prevention rules, or alternative debugging approaches.
- Merge unique content into the canonical doc in a natural location. Do not just append — integrate it where it logically belongs. If the unique content is small (a bullet point, a sentence), inline it. If it is a substantial sub-topic, add it as a clearly labeled section.
- Update cross-references — if any other docs reference the subsumed doc, update those references to point to the canonical doc.
- Delete the subsumed doc. Do not archive it, do not add redirect metadata — just delete the file. Git history preserves it.
If a doc cluster has 3+ overlapping docs, process pairwise: consolidate the two most overlapping docs first, then evaluate whether the merged result should be consolidated with the next doc.
Structural edits beyond merge: Consolidate also covers the reverse case. If one doc has grown unwieldy and covers multiple distinct problems that would benefit from separate retrieval, it is valid to recommend splitting it. Only do this when the sub-topics are genuinely independent and a maintainer might search for one without needing the other.
协调器直接处理合并(无需子代理——文档已读取,合并是聚焦编辑)。按主题聚类处理合并候选。对于阶段1.75识别的每个聚类:
- 确认标准文档——聚类中更全面、更新、更准确的文档。
- 提取被覆盖文档的独特内容——标准文档未涵盖的任何内容。这可能是特定边缘情况、额外预防规则或替代调试方法。
- 将独特内容合并到标准文档的自然位置。不要只是追加——将其整合到逻辑所属的位置。如果独特内容很小(一个要点、一句话),直接内联。如果是实质性子主题,添加为清晰标记的章节。
- 更新交叉引用——如果任何其他文档引用被覆盖文档,将这些引用更新为指向标准文档。
- 删除被覆盖文档。不要归档,不要添加重定向元数据——直接删除文件。Git历史记录会保留它。
如果文档聚类有3份以上重叠文档,成对处理:先合并两份重叠度最高的文档,然后评估合并结果是否应与下一份文档合并。
**合并之外的结构编辑:**合并也涵盖相反情况。如果一份文档变得过于冗长,涵盖多个不同问题,拆分后可独立检索,则建议拆分是有效的。仅当子主题真正独立且维护人员可能会独立搜索其中一个而不需要另一个时才这样做。
Replace Flow
替换流程
Process Replace candidates one at a time, sequentially. Each replacement is written by a subagent to protect the main context window.
When a replacement is needed, read the documentation contract files and pass their contents into the replacement subagent's task prompt:
- — frontmatter fields and enum values
references/schema.yaml - — category mapping
references/yaml-schema.md - — section structure
assets/resolution-template.md
Do not let replacement subagents invent frontmatter fields, enum values, or section order from memory.
When evidence is sufficient:
- Spawn a single subagent to write the replacement learning. Pass it:
- The old learning's full content
- A summary of the investigation evidence (what changed, what the current code does, why the old guidance is misleading)
- The target path and category (same category as the old learning unless the category itself changed)
- The relevant contents of the three support files listed above
- The subagent writes the new learning using the support files as the source of truth: for frontmatter fields and enum values,
references/schema.yamlfor category mapping, andreferences/yaml-schema.mdfor section order. It should use dedicated file search and read tools if it needs additional context beyond what was passed.assets/resolution-template.md - After the subagent completes, the orchestrator deletes the old learning file. The new learning's frontmatter may include for traceability, but this is optional — the git history and commit message provide the same information.
supersedes: [old learning filename]
When evidence is insufficient:
- Mark the learning as stale in place:
- Add to frontmatter: ,
status: stale,stale_reason: [what you found]stale_date: YYYY-MM-DD
- Add to frontmatter:
- Report what evidence was found and what is missing
- Recommend the user run after their next encounter with that area
ce-compound
一次一个、按顺序处理替换候选。每个替换由子代理编写,以保护主上下文窗口。
当需要替换时,读取文档契约文件并将其内容传递给替换子代理的任务提示:
- ——frontmatter字段和枚举值
references/schema.yaml - ——分类映射
references/yaml-schema.md - ——章节结构
assets/resolution-template.md
不要让替换子代理凭记忆发明frontmatter字段、枚举值或章节顺序。
证据充分时:
- 生成单个子代理来编写替代学习文档。传递给它:
- 旧学习文档的完整内容
- 调查证据摘要(变更内容、当前代码行为、旧指南为何具有误导性)
- 目标路径和分类(与旧学习文档相同,除非分类本身已更改)
- 上述三个支持文件的相关内容
- 子代理使用支持文件作为真相来源编写新学习文档:用于frontmatter字段和枚举值,
references/schema.yaml用于分类映射,references/yaml-schema.md用于章节顺序。如果需要传递内容之外的额外上下文,它应使用专用文件搜索和读取工具。assets/resolution-template.md - 子代理完成后,协调器删除旧学习文档文件。新学习文档的frontmatter可包含以实现可追溯性,但这是可选的——git历史记录和提交消息提供相同信息。
supersedes: [旧学习文档文件名]
证据不足时:
- 原地标记学习文档为陈旧:
- 在frontmatter中添加:、
status: stale、stale_reason: [你发现的内容]stale_date: YYYY-MM-DD
- 在frontmatter中添加:
- 报告发现的证据和缺失的内容
- 建议用户下次遇到该领域时运行
ce-compound
Delete Flow
删除流程
Delete only when a learning is clearly obsolete, redundant (with no unique content to merge), or its problem domain is gone. Do not delete a document just because it is old — age alone is not a signal.
仅当学习文档明显过时、冗余(无独特内容可合并)或其问题域已消失时才删除。不要仅因为文档旧就删除——年龄本身不是信号。
Output Format
输出格式
The full report MUST be printed as markdown output. Do not summarize findings internally and then output a one-liner. The report is the deliverable — print every section in full, formatted as readable markdown with headers, tables, and bullet points.
After processing the selected scope, output the following report:
text
Compound Refresh Summary
========================
Scanned: N learnings
Kept: X
Updated: Y
Consolidated: C
Replaced: Z
Deleted: W
Skipped: V
Marked stale: SThen for EVERY file processed, list:
- The file path
- The classification (Keep/Update/Consolidate/Replace/Delete/Stale)
- What evidence was found -- tag any memory-sourced findings with "(auto memory [claude])" to distinguish them from codebase-sourced evidence
- What action was taken (or recommended)
- For Consolidate: which doc was canonical, what unique content was merged, what was deleted
For Keep outcomes, list them under a reviewed-without-edits section so the result is visible without creating git churn.
**完整报告必须以markdown格式输出。**不要在内部总结发现然后输出单行内容。报告是交付物——完整打印每个部分,格式化为可读的markdown,包含标题、表格和要点。
处理完所选范围后,输出以下报告:
text
Compound Refresh 汇总
========================
已扫描:N份学习文档
保留:X
更新:Y
合并:C
替换:Z
删除:W
跳过:V
标记为陈旧:S然后列出每一个处理的文件:
- 文件路径
- 分类(保留/更新/合并/替换/删除/陈旧)
- 发现的证据——将任何基于记忆的发现标记为“(auto memory [claude])”,以区别于基于代码库的证据
- 执行(或建议)的操作
- 对于合并:标准文档是哪份、合并了哪些独特内容、删除了哪些文档
对于保留结果,将其列在“已审查未编辑”部分,以便结果可见而不会产生git变动。
Autofix mode report
自动修复模式报告
In autofix mode, the report is the sole deliverable — there is no user present to ask follow-up questions, so the report must be self-contained and complete. Print the full report. Do not abbreviate, summarize, or skip sections.
Split actions into two sections:
Applied (writes that succeeded):
- For each Updated file: the file path, what references were fixed, and why
- For each Consolidated cluster: the canonical doc, what unique content was merged from each subsumed doc, and the subsumed docs that were deleted
- For each Replaced file: what the old learning recommended vs what the current code does, and the path to the new successor
- For each Deleted file: the file path and why it was removed (problem domain gone, fully redundant, etc.)
- For each Marked stale file: the file path, what evidence was found, and why it was ambiguous
Recommended (actions that could not be written — e.g., permission denied):
- Same detail as above, but framed as recommendations for a human to apply
- Include enough context that the user can apply the change manually or re-run the skill interactively
If all writes succeed, the Recommended section is empty. If no writes succeed (e.g., read-only invocation), all actions appear under Recommended — the report becomes a maintenance plan.
Legacy cleanup (if exists):
docs/solutions/_archived/- List archived files found and recommend disposition: restore (if still relevant), delete (if truly obsolete), or consolidate (if overlapping with active docs)
在自动修复模式下,报告是唯一交付物——没有用户在场提问,因此报告必须自包含且完整。打印完整报告。不要缩写、总结或跳过部分。
将操作分为两个部分:
已执行(写入成功):
- 每个更新文件:文件路径、修复了哪些引用、原因
- 每个合并聚类:标准文档、从每个被覆盖文档合并的独特内容、被删除的被覆盖文档
- 每个替换文件:旧学习文档的推荐内容vs当前代码行为、新替代文档的路径
- 每个删除文件:文件路径、删除原因(问题域消失、完全冗余等)
- 每个标记为陈旧文件:文件路径、发现的证据、为何模糊
建议(无法写入的操作——如权限不足):
- 与上述相同的细节,但表述为供人工执行的建议
- 包含足够上下文,以便用户可以手动应用更改或交互式重新运行该技能
如果所有写入成功,建议部分为空。如果没有写入成功(如只读调用),所有操作都列在建议部分——报告成为维护计划。
遗留清理(如果存在):
docs/solutions/_archived/- 列出找到的归档文件并建议处理方式:恢复(如果仍然相关)、删除(如果确实过时)、合并(如果与活跃文档重叠)
Phase 5: Commit Changes
阶段5:提交变更
After all actions are executed and the report is generated, handle committing the changes. Skip this phase if no files were modified (all Keep, or all writes failed).
执行完所有操作并生成报告后,处理变更提交。如果未修改任何文件(全部保留,或所有写入失败),跳过此阶段。
Detect git context
检测git上下文
Before offering options, check:
- Which branch is currently checked out (main/master vs feature branch)
- Whether the working tree has other uncommitted changes beyond what compound-refresh modified
- Recent commit messages to match the repo's commit style
提供选项前,检查:
- 当前检出的是哪个分支(main/master vs 功能分支)
- 工作树是否有除compound-refresh修改之外的其他未提交变更
- 最近的提交消息以匹配仓库的提交风格
Autofix mode
自动修复模式
Use sensible defaults — no user to ask:
| Context | Default action |
|---|---|
| On main/master | Create a branch named for what was refreshed (e.g., |
| On a feature branch | Commit as a separate commit on the current branch |
| Git operations fail | Include the recommended git commands in the report and continue |
Stage only the files that compound-refresh modified — not other dirty files in the working tree.
使用合理的默认值——无需询问用户:
| 上下文 | 默认操作 |
|---|---|
| 在main/master分支 | 创建以刷新内容命名的分支(如 |
| 在功能分支 | 在当前分支上作为单独提交进行提交 |
| Git操作失败 | 在报告中包含推荐的git命令并继续 |
仅暂存compound-refresh修改的文件——不暂存工作树中的其他脏文件。
Interactive mode
交互式模式
First, run to determine the current branch. Then present the correct options based on the result. Stage only compound-refresh files regardless of which option the user picks.
git branch --show-currentIf the current branch is main, master, or the repo's default branch:
- Create a branch, commit, and open a PR (recommended) — the branch name should be specific to what was refreshed, not generic (e.g., not
docs/refresh-auth-learnings)docs/compound-refresh - Commit directly to
{current branch name} - Don't commit — I'll handle it
If the current branch is a feature branch, clean working tree:
- Commit to as a separate commit (recommended)
{current branch name} - Create a separate branch and commit
- Don't commit
If the current branch is a feature branch, dirty working tree (other uncommitted changes):
- Commit only the compound-refresh changes to (selective staging — other dirty files stay untouched)
{current branch name} - Don't commit
首先运行确定当前分支。然后根据结果呈现正确选项。无论用户选择哪个选项,仅暂存compound-refresh文件。
git branch --show-current如果当前分支是main、master或仓库的默认分支:
- 创建分支、提交并打开PR(推荐)——分支名称应具体描述刷新内容,而非通用名称(如而非
docs/refresh-auth-learnings)docs/compound-refresh - 直接提交到
{当前分支名称} - 不提交——我会处理
如果当前分支是功能分支,工作树干净:
- 作为单独提交提交到(推荐)
{当前分支名称} - 创建单独分支并提交
- 不提交
如果当前分支是功能分支,工作树有脏文件(其他未提交变更):
- 仅将compound-refresh变更提交到(选择性暂存——其他脏文件保持不变)
{当前分支名称} - 不提交
Commit message
提交消息
Write a descriptive commit message that:
- Summarizes what was refreshed (e.g., "update 3 stale learnings, consolidate 2 overlapping docs, delete 1 obsolete doc")
- Follows the repo's existing commit conventions (check recent git log for style)
- Is succinct — the details are in the changed files themselves
编写描述性提交消息:
- 总结刷新内容(如“更新3份陈旧学习文档,合并2份重叠文档,删除1份过时文档”)
- 遵循仓库现有的提交约定(查看最近的git日志了解风格)
- 简洁——细节在变更文件本身中
Relationship to ce-compound
与ce-compound的关系
- captures a newly solved, verified problem
ce-compound - maintains older learnings as the codebase evolves — both their individual accuracy and their collective design as a document set
ce-compound-refresh
Use Replace only when the refresh process has enough real evidence to write a trustworthy successor. When evidence is insufficient, mark as stale and recommend for when the user next encounters that problem area.
ce-compoundUse Consolidate proactively when the document set has grown organically and redundancy has crept in. Every invocation adds a new doc — over time, multiple docs may cover the same problem from slightly different angles. Periodic consolidation keeps the document set lean and authoritative.
ce-compound- 捕获新解决并验证的问题
ce-compound - 随着代码库的发展维护旧学习文档——包括它们的个体准确性和作为文档集的整体设计
ce-compound-refresh
仅当刷新过程有足够真实证据编写可信替代文档时,才使用替换。当证据不足时,标记为陈旧并建议用户下次遇到该问题领域时运行。
ce-compound当文档集自然增长且出现冗余时,主动使用合并。每次调用都会添加新文档——随着时间推移,多份文档可能会从略有不同的角度覆盖相同问题。定期合并可保持文档集精简且权威。
ce-compoundDiscoverability Check
可发现性检查
After the refresh report is generated, check whether the project's instruction files would lead an agent to discover and search before starting work in a documented area. This runs every time — the knowledge store only compounds value when agents can find it. If this check produces edits, they are committed as part of (or immediately after) the Phase 5 commit flow — see step 5 below.
docs/solutions/-
Identify which root-level instruction files exist (AGENTS.md, CLAUDE.md, or both). Read the file(s) and determine which holds the substantive content — one file may just be a shim that-includes the other (e.g.,
@containing onlyCLAUDE.md, or vice versa). The substantive file is the assessment and edit target; ignore shims. If neither file exists, skip this check entirely.@AGENTS.md -
Assess whether an agent reading the instruction files would learn three things:
- That a searchable knowledge store of documented solutions exists
- Enough about its structure to search effectively (category organization, YAML frontmatter fields like ,
module,tags)problem_type - When to search it (before implementing features, debugging issues, or making decisions in documented areas — learnings may cover bugs, best practices, workflow patterns, or other institutional knowledge)
This is a semantic assessment, not a string match. The information could be a line in an architecture section, a bullet in a gotchas section, spread across multiple places, or expressed without ever using the exact path. Use judgment — if an agent would reasonably discover and use the knowledge store after reading the file, the check passes.docs/solutions/ -
If the spirit is already met, no action needed.
-
If not: a. Based on the file's existing structure, tone, and density, identify where a mention fits naturally. Before creating a new section, check whether the information could be a single line in the closest related section — an architecture tree, a directory listing, a documentation section, or a conventions block. A line added to an existing section is almost always better than a new headed section. Only add a new section as a last resort when the file has clear sectioned structure and nothing is even remotely related. b. Draft the smallest addition that communicates the three things. Match the file's existing style and density. The addition should describe the knowledge store itself, not the plugin.Keep the tone informational, not imperative. Express timing as description, not instruction — "relevant when implementing or debugging in documented areas" rather than "check before implementing or debugging." Imperative directives like "always search before implementing" cause redundant reads when a workflow already includes a dedicated search step. The goal is awareness: agents learn the folder exists and what's in it, then use their own judgment about when to consult it.Examples of calibration (not templates — adapt to the file):When there's an existing directory listing or architecture section — add a line:
docs/solutions/ # documented solutions to past problems (bugs, best practices, workflow patterns), organized by category with YAML frontmatter (module, tags, problem_type)When nothing in the file is a natural fit — a small headed section is appropriate:## Documented Solutions `docs/solutions/` — documented solutions to past problems (bugs, best practices, workflow patterns), organized by category with YAML frontmatter (`module`, `tags`, `problem_type`). Relevant when implementing or debugging in documented areas.c. In interactive mode, explain to the user why this matters — agents working in this repo (including fresh sessions, other tools, or collaborators without the plugin) won't know to checkunless the instruction file surfaces it. Show the proposed change and where it would go, then use the platform's blocking question tool (docs/solutions/in Claude Code,AskUserQuestionin Codex,request_user_inputin Gemini) to get consent before making the edit. If no question tool is available, present the proposal and wait for the user's reply. In autofix mode, include it as a "Discoverability recommendation" line in the report — do not attempt to edit instruction files (autofix scope is doc maintenance, not project config).ask_user -
Amend or create a follow-up commit when the check produces edits. If step 4 resulted in an edit to an instruction file and Phase 5 already committed the refresh changes, stage the newly edited file and either amend the existing commit (if still on the same branch and no push has occurred) or create a small follow-up commit (e.g.,). If Phase 5 already pushed the branch to a remote (e.g., the branch+PR path), push the follow-up commit as well so the open PR includes the discoverability change. This keeps the working tree clean and the remote in sync at the end of the run. If the user chose "Don't commit" in Phase 5, leave the instruction-file edit unstaged alongside the other uncommitted refresh changes — no separate commit logic needed.
docs: add docs/solutions/ discoverability to AGENTS.md
生成刷新报告后,检查项目的指令文件是否会引导代理在开始记录区域的工作前发现并搜索。每次运行都会执行此检查——只有当代理能找到知识库时,知识库才会不断增值。如果此检查产生编辑,将其作为阶段5提交流程的一部分(或之后立即)提交——见步骤5。
docs/solutions/-
确定存在哪些根级指令文件(AGENTS.md、CLAUDE.md或两者都有)。读取文件并确定哪个包含实质内容——一个文件可能只是包含另一个文件的垫片(如仅包含
CLAUDE.md,反之亦然)。实质文件是评估和编辑目标;忽略垫片。如果两个文件都不存在,完全跳过此检查。@AGENTS.md -
评估读取指令文件的代理是否会了解三件事:
- 存在可搜索的已记录解决方案知识库
- 足够了解其结构以有效搜索(分类组织、YAML frontmatter字段如、
module、tags)problem_type - 何时搜索(在记录区域实现功能、调试问题或做出决策之前——学习文档可能涵盖错误、最佳实践、工作流模式或其他机构知识)
这是语义评估,而非字符串匹配。信息可能在架构部分的一行、注意事项部分的一个要点、多个地方分散,或未使用确切路径表达。运用判断——如果代理读取文件后能合理发现并使用知识库,检查通过。docs/solutions/ -
如果精神已满足,无需操作。
-
如果未满足: a. 根据文件的现有结构、语气和密度,确定提及内容的自然位置。在创建新章节前,检查信息是否可以添加到最相关章节的单行中——架构树、目录列表、文档部分或约定块。添加到现有章节的一行几乎总是比新标题章节更好。仅当文件有清晰的章节结构且没有任何相关内容时,才作为最后手段添加新章节。 b. 起草传达三件事的最小添加内容。匹配文件的现有风格和密度。添加内容应描述知识库本身,而非插件。保持语气信息性,而非命令式。将时机描述为说明,而非指令——“在记录区域实现或调试时相关”而非“实现或调试前检查”。像“实现前始终搜索”这样的命令式指令会在工作流已包含专门搜索步骤时导致冗余读取。目标是提高认知:代理了解文件夹存在及其内容,然后自行判断何时查阅。校准示例(非模板——适应文件):当存在现有目录列表或架构部分时——添加一行:
docs/solutions/ # 已记录的过往问题解决方案(错误、最佳实践、工作流模式),按分类组织,带有YAML frontmatter(module、tags、problem_type)当文件中没有自然适配位置时——添加一个小型标题章节是合适的:## 已记录解决方案 `docs/solutions/` — 已记录的过往问题解决方案(错误、最佳实践、工作流模式),按分类组织,带有YAML frontmatter(`module`、`tags`、`problem_type`)。在记录区域实现或调试时相关。c. 在交互式模式下,向用户解释为何这很重要——在此仓库工作的代理(包括新会话、其他工具或没有插件的协作者)除非指令文件提及,否则不会知道要检查。展示提议的更改及其位置,然后使用平台的阻塞式提问工具(Claude Code中的docs/solutions/、Codex中的AskUserQuestion、Gemini中的request_user_input)在进行编辑前获得同意。如果没有提问工具,呈现提议并等待用户回复。在自动修复模式下,将其作为报告中的“可发现性建议”行——不要尝试编辑指令文件(自动修复范围是文档维护,而非项目配置)。ask_user -
**当检查产生编辑时,修改或创建后续提交。**如果步骤4导致编辑指令文件且阶段5已提交刷新变更,暂存新编辑的文件,要么修改现有提交(如果仍在同一分支且未推送),要么创建小型后续提交(如)。如果阶段5已将分支推送到远程(如分支+PR路径),也推送后续提交,以便打开的PR包含可发现性变更。这会在运行结束时保持工作树干净且远程同步。如果用户在阶段5选择“不提交”,将指令文件编辑与其他未提交的刷新变更一起保持未暂存——无需单独提交逻辑。
docs: add docs/solutions/ discoverability to AGENTS.md