Skip to content

Writing Indexer Guidance ​

Read this page when you are writing or reviewing your own Indexer, usually after asking the creator for a first version in Creating an Indexer. An Indexer teaches the Agent how to read one technology or one family of documents: what to look at cheaply during planning, what to read in full before explaining it, and how to write articles organized around reader questions. It guides investigation and writing; the Context workflow still decides what happens next.

Both kinds follow the same rhythm: a cheap skeleton or outline first, reader topics that you confirm in the work-start report, then full reading of the sources each article needs. The two sections below follow the shipped context-code-indexer and context-markdown-indexer.

mermaid
flowchart LR
  sig["Signals or outlines<br/>manifests, entries, headings"] --> skel["Skeleton<br/>names, counts, locations"]
  skel --> topics["Reader topics<br/>and writing batches"]
  topics -->|"report confirmed"| read["Read the sources each<br/>article needs"]
  read --> art["Article with<br/>real references"]

Code Indexers ​

A code Indexer teaches the Agent how to read one technology: where its features are declared, how to find them cheaply during planning, and what to read in full before explaining them.

What the Skill is responsible for ​

Describe the supported technology, the signals that activate it, the reader questions it can help answer and how to investigate an authorized module. A module may use several Skills for different concerns — say, one for the web framework and another for its message consumers. Which Skills a task uses is planning guidance for that task, not article metadata.

Keep SKILL.md focused on discovery and decisions. Put detailed writing guidance and reusable scripts beside it, linked by relative path with a clear note on when to read them.

Skeleton first ​

During planning the Indexer should point the Agent at directories, manifests, registration points and bounded search — either for direct inspection or through a fast helper suited to the stack — and report matching names, known counts and file locations. It must not require complete symbol extraction, call graphs or reading every implementation before articles are proposed.

Typical signals and the questions they suggest:

SignalSuggests
Public exports or component declarationsHow to consume a capability
Inbound registrations or interface definitionsWhich operations are served
Event or scheduled registrationsWhat triggers work and how it completes
Storage interfacesData ownership and transaction boundaries
Adapters and generated clientsContracts at an external handoff
Package and workspace entry pointsResponsibility and consumption boundaries

Signals suggest topics; they do not prove meaning. A route registration can suggest an API topic, but not its error behavior. File counts are not feature counts, and a stopped scan is never a full total.

Bounded helpers ​

Scripts are optional and serve one concrete, repeated task. A good helper takes explicit authorized paths and bounded options, keeps source files read-only, returns concise output or writes a file in the supplied temporary area, and stops within its budget. It reports inspected and uninspected scope, returns a continuation when it can, and labels partial counts.

It must not execute repository code, read credentials, traverse unrelated directories or contact external services. Unsupported syntax and incomplete traversal are reported separately from zero matches. Full parsing belongs to the writing of selected articles; where a structural fact needs a real parser, use the built-in extractors described in Code Extraction.

Writing guidance ​

Once the work-start report is confirmed (see Confirming the Work-Start Report), the Agent reads the source each article needs. Guide it to explain contracts, state changes, failure behavior and integration points — what the module is responsible for, how to enter it, what it hands off. Parsing can locate declarations; it is not proof of runtime behavior. Preserve expressions without executing project code, keep declared defaults apart from implemented defaults, and state unknowns.

An Indexer may suggest a recurring outline for a feature family such as route groups or components, but not a fixed page count: a component manual may need component-by-component reading, while one page per symbol or a catch-all page for a large module are both wrong. Each section cites real source regions from at most five distinct files, up to eight regions in total; split an explanation when it needs separate evidence.

Example outline ​

A minimal Indexer for a hypothetical Acme RPC framework:

text
acme-rpc-indexer/
  SKILL.md
  references/
    investigate.md   # where services, methods and middleware are declared
    writing.md       # integration and maintenance guide outlines
  scripts/
    list-services.mjs  # bounded: given paths, prints service and method names with locations
  tests/fixtures/
    orders-service/  # anonymous sample module
markdown
---
name: acme-rpc-indexer
description: Investigate services built on Acme RPC and write integration and maintenance articles. Use when selected for a Context planning or writing task on such a module.
---

# Acme RPC Indexer

During planning, read `service.yaml` files and `@Method` registrations in the
authorized module. Report service names, method counts and file locations;
mark partial counts as partial. For large modules run
`scripts/list-services.mjs <paths> --max-files 2000`.

During writing, read [writing guidance](references/writing.md). For each
method, explain the request contract, errors and middleware actually applied.
A generated client is outbound, not proof that this module serves the method.

Testing ​

Test the supported technology with anonymous fixtures: feature discovery, bounded stopping, unsupported input, repeated names in different paths, and the references in the final article. For generated API explanations, check defaults, shared types and unresolved cross-file links in the final page as well as the helper output. Use fixtures relevant to the technology, not a matrix of unrelated stacks.

Verify packaged relative links and executable helpers, and keep examples free of organization-specific services; organization knowledge belongs in its own Skills.

Document Indexers ​

A document Indexer helps the Agent interpret one family of captured documents — design reviews, runbooks, API specifications, product requirements — and turn them into articles organized around reader questions rather than around the source files. Notes and session summaries have their own Indexers but can support the same reader topics.

Start from captured sources ​

The Indexer works on authorized captured documents. Capture proves which content is available, not what it means; titles, headings and file names are navigation aids, not proof that the body has been read.

It must not fetch new documents, follow external links or widen source authorization on its own. Missing material is requested through the current task, and an unavailable source is kept distinct from an irrelevant one.

Planning from outlines ​

For each document the Agent gets its title, a short introduction and the complete H2/H3 outline, plus existing article titles, descriptions and references. It reads more — a section or the whole document — only where the reader question, grouping or authority is unclear. Full reading of every document is not required before a plan can be proposed.

Guide the grouping:

  • Reuse an existing article, including a topic first discovered from code, when it answers the same question for the same audience.
  • Let business definitions in documents correct a mechanical code-topic name, rather than forcing a document under a code directory.
  • Split distinct reader tasks or lifecycles; combine sources that answer the same task. A broad shared label such as "operations" does not make all its procedures one summary.
  • Neither file count nor heading count decides article count. One document may support several articles, and several documents one article.

Age, archive location and polished language prove neither authority nor irrelevance; compare substance, audience and applicability. The first plan is shown in the work-start report and waits for your feedback before bulk writing, also in fully managed mode; see Confirming the Work-Start Report.

Writing and repairs ​

Before writing, the Agent reads the actual passages each article needs, and keeps authoritative rules, examples, decisions and proposals distinct — a suggestion in a meeting summary is not implemented behavior. Each section cites real source regions from at most five distinct files, up to eight regions in total; the Agent judges whether the evidence supports the explanation. A local problem is repaired at the affected section, and finished articles can be submitted without waiting for the rest of a batch.

Revisions keep stable article and section identities and preserve useful steps, examples, images and limitations. Do not inflate page counts, write one page per heading or turn missing evidence into speculative prose.

Images, tables and diagrams ​

The Agent reads only the authorized images that came with a document, prefers structured whiteboard or table data when available, and converts a clear flow, sequence, state or relationship diagram to Mermaid, or a table to Markdown, only when every label, value and footnote survives. Screenshots, photos and designs where the appearance is the information are kept as originals, and so is anything it cannot read reliably. It never guesses relationships or numbers. A document Indexer can add guidance for diagrams typical of its family.

Example outline ​

A minimal Indexer for design-review documents:

text
design-review-indexer/
  SKILL.md
  references/
    writing.md     # decision record and architecture guide outlines
  tests/fixtures/
    reviews/       # three anonymous design reviews, one superseded
markdown
---
name: design-review-indexer
description: Interpret design-review documents and write decision records and architecture guides. Use when selected for a Context planning or writing task on such documents.
---

# Design Review Indexer

During planning, use the title, "Context", "Decision" and "Alternatives"
headings to group reviews by the system they change. A superseded review
still explains history; link it from the current decision instead of
dropping it.

During writing, read [writing guidance](references/writing.md). State the
decision, its rationale and limits; mark open questions as open. A proposal
without a recorded decision is not adopted behavior.

Testing ​

Cover the document forms the Skill claims to support: an ordinary one-to-one article, a synthesis from several documents, reuse of an existing topic, a section repair, source line changes, links and images, and missing material. Check both fidelity to the source and the final page, keep examples anonymous and verify packaged links.

See Creating an Indexer for the creation flow and Choosing, Replacing and Disabling Indexers for using several Skills together.

编写 Indexer 指引 ​

当你在编写或审阅自己的 Indexer 时阅读本页,通常是在 创建 Indexer 中请创建器生成第一版之后。Indexer 教 Agent 如何阅读某一种技术或某一类文档:规划期间可以低成本查看什么,讲解之前需要完整阅读什么,以及如何围绕读者问题组织文章。它指导调研和撰写;接下来做什么仍由 Context 工作流决定。

两类 Indexer 遵循相同的节奏:先看低成本的骨架或大纲,再由你在开工报告中确认读者主题,然后完整阅读每篇文章所需的来源。下面两节分别参照自带的 context-code-indexer 和 context-markdown-indexer。

mermaid
flowchart LR
  sig["信号或大纲<br/>清单、入口、标题"] --> skel["骨架<br/>名称、计数、位置"]
  skel --> topics["读者主题<br/>与撰写批次"]
  topics -->|"报告已确认"| read["阅读每篇文章<br/>所需的来源"]
  read --> art["带有真实<br/>引用的文章"]

代码类 Indexer ​

代码 Indexer 教 Agent 如何阅读某一种技术:它的功能声明在哪里,规划期间如何低成本地找到它们,以及在讲解之前需要完整阅读什么。

Skill 负责什么 ​

描述所支持的技术、激活它的信号、它能帮助回答的读者问题,以及如何调研一个已授权的模块。一个模块可以针对不同关注点使用多个 Skill——比如一个用于 Web 框架,另一个用于消息消费者。某个任务使用哪些 Skill 属于该任务的规划指引,而不是文章元数据。

让 SKILL.md 专注于发现和决策。把详细的撰写指引和可复用脚本放在它旁边,用相对路径链接,并清楚说明何时阅读它们。

骨架优先 ​

在规划期间,Indexer 应当引导 Agent 查看目录、清单文件、注册点并进行有限的搜索——可以直接查看,也可以借助适合该技术栈的快速辅助工具——并报告匹配的名称、已知计数和文件位置。在提出文章之前,它不得要求完整提取符号、构建调用图或阅读每一处实现。

典型信号及其引出的问题:

信号引出的问题
公开导出或组件声明如何使用某项能力
入站注册或接口定义提供了哪些操作
事件或定时任务注册什么触发了工作,工作如何完成
存储接口数据归属和事务边界
适配器和生成的客户端外部交接处的契约
包和工作区入口职责与使用边界

信号只是提示主题,并不能证明含义。路由注册可以提示一个 API 主题,但不能说明它的错误行为。文件数不是功能数,中途停止的扫描也绝不是完整总数。

有限的辅助工具 ​

脚本是可选的,只服务于一个具体的、重复的任务。好的辅助工具接受明确的已授权路径和有限的选项,保持源文件只读,返回简洁的输出或把文件写到提供的临时区域,并在预算内停止。它报告已检查和未检查的范围,能继续时返回续接点,并为不完整的计数加上标注。

它不得执行仓库代码、读取凭据、遍历无关目录或联系外部服务。不支持的语法和未完成的遍历要与零匹配分开报告。完整解析属于选定文章的撰写阶段;如果某个结构性事实需要真正的解析器,请使用 代码抽取 中介绍的内置抽取器。

撰写指引 ​

开工报告确认后(参见 确认开工报告),Agent 会阅读每篇文章所需的源码。引导它讲解契约、状态变化、失败行为和集成点——模块负责什么、如何进入、交出什么。解析可以定位声明,但不能证明运行时行为。保留表达式原样而不执行项目代码,把声明的默认值与实现的默认值分开,并写明未知之处。

Indexer 可以为路由组或组件这类功能类别建议一套重复使用的大纲,但不能规定固定的页数:组件手册可能需要逐个组件阅读,而每个符号一页或为大模块写一个大杂烩页面都是错误的。每个小节引用的真实源码区域最多来自五个不同文件,总计最多八个区域;如果一段讲解需要不同的证据,就把它拆开。

示例结构 ​

一个针对假想的 Acme RPC 框架的最小 Indexer:

text
acme-rpc-indexer/
  SKILL.md
  references/
    investigate.md   # 服务、方法和中间件的声明位置
    writing.md       # 接入和维护指南的大纲
  scripts/
    list-services.mjs  # 限定在给定路径内,输出服务和方法名称及位置
  tests/fixtures/
    orders-service/  # 匿名化的示例模块
markdown
---
name: acme-rpc-indexer
description: Investigate services built on Acme RPC and write integration and maintenance articles. Use when selected for a Context planning or writing task on such a module.
---

# Acme RPC Indexer

During planning, read `service.yaml` files and `@Method` registrations in the
authorized module. Report service names, method counts and file locations;
mark partial counts as partial. For large modules run
`scripts/list-services.mjs <paths> --max-files 2000`.

During writing, read [writing guidance](references/writing.md). For each
method, explain the request contract, errors and middleware actually applied.
A generated client is outbound, not proof that this module serves the method.

测试 ​

用匿名测试夹具测试所支持的技术:功能发现、有限停止、不支持的输入、不同路径中的重名,以及最终文章中的引用。对于生成的 API 讲解,除了辅助工具的输出,还要在最终页面中检查默认值、共享类型和未解析的跨文件链接。使用与该技术相关的测试夹具,而不是一组互不相关的技术栈矩阵。

验证打包后的相对链接和可执行的辅助工具,并确保示例不包含特定组织的服务;组织知识应放在它们自己的 Skill 中。

文档类 Indexer ​

文档 Indexer 帮助 Agent 解读某一类已采集的文档——设计评审、运维手册、API 规范、产品需求——并把它们转化为围绕读者问题而非来源文件组织的文章。笔记和会话摘要有各自的 Indexer,但可以支撑相同的读者主题。

从已采集的来源开始 ​

Indexer 处理的是已授权、已采集的文档。采集证明的是哪些内容可用,而不是它们的含义;标题、小标题和文件名只是导航辅助,不能证明正文已被阅读。

它不得自行抓取新文档、跟随外部链接或扩大来源授权。缺失的材料通过当前任务申请,不可用的来源与无关的来源要区分开。

依据大纲规划 ​

对每份文档,Agent 会拿到标题、简短的引言和完整的 H2/H3 大纲,以及已有文章的标题、描述和引用。只有在读者问题、分组或权威性不明确时,它才会进一步阅读——某一节或整份文档。提出计划之前并不要求全文阅读每份文档。

引导分组:

  • 当某篇已有文章(包括最初从代码中发现的主题)为同一受众回答同一问题时,复用它。
  • 让文档中的业务定义修正机械生成的代码主题名称,而不是把文档硬塞到代码目录下。
  • 拆分不同的读者任务或生命周期;合并回答同一任务的来源。像“运维”这样宽泛的共用标签,并不意味着其下所有流程都要合并成一篇摘要。
  • 文件数和标题数都不决定文章数。一份文档可以支撑多篇文章,多份文档也可以支撑一篇文章。

年代、归档位置和文字是否精炼,既不能证明权威性,也不能证明无关;要比较实质内容、受众和适用范围。第一版计划会展示在开工报告中,并在批量撰写之前等待你的反馈,全托管模式下也是如此;参见 确认开工报告。

撰写与修复 ​

撰写之前,Agent 会阅读每篇文章所需的实际段落,并把权威规则、示例、决定和提议区分开——会议纪要中的一条建议并不是已实现的行为。每个小节引用的真实来源区域最多来自五个不同文件,总计最多八个区域;Agent 判断证据是否支撑讲解。局部问题在受影响的小节处修复,已完成的文章可以直接提交,无需等待同一批次的其余文章。

修订会保持文章和小节的标识稳定,并保留有用的步骤、示例、图片和限制。不要虚增页数,不要每个标题写一页,也不要把缺失的证据变成推测性的文字。

图片、表格和图表 ​

Agent 只读取文档附带的已授权图片,在可用时优先使用结构化的白板或表格数据;只有当每个标签、数值和脚注都能完整保留时,才会把清晰的流程图、时序图、状态图或关系图转换为 Mermaid,或把表格转换为 Markdown。截图、照片以及以外观本身为信息的设计稿会保留原件,无法可靠读取的内容也是如此。它绝不猜测关系或数字。文档 Indexer 可以针对其文档类别中常见的图表补充指引。

示例结构 ​

一个针对设计评审文档的最小 Indexer:

text
design-review-indexer/
  SKILL.md
  references/
    writing.md     # 决策记录和架构指南的大纲
  tests/fixtures/
    reviews/       # 三份匿名化设计评审,其中一份已被替代
markdown
---
name: design-review-indexer
description: Interpret design-review documents and write decision records and architecture guides. Use when selected for a Context planning or writing task on such documents.
---

# Design Review Indexer

During planning, use the title, "Context", "Decision" and "Alternatives"
headings to group reviews by the system they change. A superseded review
still explains history; link it from the current decision instead of
dropping it.

During writing, read [writing guidance](references/writing.md). State the
decision, its rationale and limits; mark open questions as open. A proposal
without a recorded decision is not adopted behavior.

测试 ​

覆盖该 Skill 声称支持的文档形式:普通的一对一文章、综合多份文档的文章、复用已有主题、小节修复、来源行变化、链接和图片,以及材料缺失。既要检查对来源的忠实度,也要检查最终页面;保持示例匿名,并验证打包后的链接。

创建流程参见 创建 Indexer,同时使用多个 Skill 参见 选择、替换与停用 Indexer。