Skip to content

Quick Start ​

This walkthrough turns one code module and one local documentation folder into a reviewed knowledge package with a browsable site. You give instructions in plain language and the Agent runs the commands the workflow returns, so the examples below show only what you say.

Make sure Installation is done, including Node.js 20 and Bun, which installs the new knowledge workspace's dependencies, and that you have restarted the Agent session so the plugin is loaded.

1. Create the knowledge workspace ​

Tell the Agent where the Context knowledge workspace should live and what it is for:

text
/c4a:context Create a Context knowledge workspace in ./context for our component library
and its product docs. Readers are frontend developers new to the library.

The Agent creates the directory and installs its dependencies. You get this layout:

text
context/
├── AGENTS.md       # guidance for the Agent
├── src/            # source, phase and package declarations
├── sources/        # registered sources and captured evidence
├── knowledge/      # approved knowledge (empty for now)
├── dist/           # built packages (ignored by Git)
└── .tmp/           # runtime state and reports (ignored by Git)

2. Point it at your sources ​

Name the material and anything the Agent should skip:

text
Use ../component-lib for code and ../docs for product documents.
Skip the deprecated v1 folder.

The Agent registers each boundary. Registration records what is in scope; it does not decide what to write.

For a monorepo, pick the package or service your readers need. Unneeded material costs reading time and tokens, but do not exclude something just because its filename looks old.

To start building a complex knowledge base for a whole domain or business, see Planning Large Projects in Stages.

3. Confirm the work-start report ​

The Agent reads representative material, asks about anything that would change the scope, records the reader purpose, and presents a work-start report with:

  • the confirmed sources and scope;
  • the Indexer skills it will use;
  • the first pages you should expect and where they will sit in the site.

Nothing is written until you approve the report. If the plan is off, say what to change, for example "merge the two API pages" or "add a troubleshooting page", and the Agent revises it. See Confirming the Work-Start Report.

4. Let it write, then review ​

After approval, the Agent writes each page with references to exact source lines and submits them for checks on coverage and stale inputs. Expect roughly a minute per writing task; the Agent reports progress and the total number of tasks, and you can ask for a local preview at any time.

When writing finishes, you receive a review report showing each page's title, path, summary and content. Approve it, reject pages, or ask for revisions. Approved pages land in knowledge/ as Markdown; rejected or revised pages go back to writing. See Reading Review Reports.

mermaid
flowchart LR
  write["Agent writes pages"] --> review["You review"]
  review -->|revise| write
  review -->|approve| kn["knowledge/"]
  kn --> build["Build"]
  build --> kb["dist/component-kb/"]
  build --> site["dist/component-site/"]

If you are interrupted, close the conversation and come back later: invoke /c4a:context in the knowledge workspace again. It resumes from the workspace's recorded state, not from the conversation, so nothing is redone.

5. Build the package and site ​

For a new knowledge workspace, the Agent proposes two outputs by default and the build produces both:

  • dist/component-kb/: the knowledge package that Agents install and query;
  • dist/component-site/: a static documentation site with article pages and local search, for people.

To look at the site, ask "Preview the site locally." The output declarations live in src/index.ts; see Knowledge Packages if you need a different output. When the round ends, the Agent commits the knowledge workspace to Git, so the result can be inspected, versioned and refreshed later.

6. Ask your first question ​

Try the new knowledge right away:

text
/c4a:context-inspect-search How does the Button component handle loading state? Cite the code.

The answer cites approved pages and the source lines behind them. A gap in the answer is a good candidate for the next round: tell /c4a:context what is missing.

Next steps ​

快速开始 ​

本教程把一个代码模块和一个本地文档目录整理成已批准的知识包,并附带可浏览的站点。你用自然语言下达指令,Agent 执行工作流返回的命令,所以下面的示例只展示你要说的话。

请先完成 安装,包括 Node.js 20 和用于为新知识工作区安装依赖的 Bun,并重启 Agent 会话以加载插件。

1. 创建知识工作区 ​

告诉 Agent Context 知识工作区放在哪里、用来做什么:

text
/c4a:context 请在 ./context 创建一个 Context 知识工作区,整理我们的组件库和产品文档。
读者是刚开始使用这个组件库的前端开发者。

Agent 会创建目录并安装依赖。得到的目录结构如下:

text
context/
├── AGENTS.md       # 给 Agent 的使用说明
├── src/            # 来源、阶段和知识包声明
├── sources/        # 已登记的来源和采集到的证据
├── knowledge/      # 已批准的知识(目前为空)
├── dist/           # 构建后的知识包(Git 忽略)
└── .tmp/           # 运行状态和报告(Git 忽略)

2. 指定来源 ​

说明要用哪些材料,以及 Agent 应该跳过什么:

text
代码请使用 ../component-lib,产品文档使用 ../docs。
已经废弃的 v1 文件夹就不纳入了。

Agent 会逐一登记每个边界。登记只记录范围内有哪些内容,并不决定要写什么。

对于 monorepo,挑出读者真正需要的包或服务即可。无关材料会浪费阅读时间和 token,但也不要仅因为文件名看起来旧就把它排除。

如果要为整个领域或业务开始建设复杂的知识库,请参阅 分阶段规划大型项目。

3. 确认开工报告 ​

Agent 会阅读有代表性的材料,就可能改变范围的问题向你确认,记录读者目标,然后给出一份开工报告,包括:

  • 已确认的来源和范围;
  • 将使用的 Indexer 技能;
  • 预计产出的第一批页面,以及它们在站点中的位置。

在你批准报告之前,不会写入任何内容。如果计划不对,直接说要改什么,例如“合并两个 API 页面”或“增加一个故障排查页面”,Agent 会据此修订。参见 确认开工报告。

4. 让 Agent 写作,然后你来审核 ​

批准后,Agent 逐页写作,引用精确到来源行,并核对覆盖度与过期输入。每个写作任务大约需要一分钟;Agent 会汇报进度和任务总数,你也可以随时要求本地预览。

写作完成后,你会收到一份审核报告,列出每个页面的标题、路径、摘要和内容。你可以批准、拒绝部分页面,或要求修订。批准的页面以 Markdown 形式落入 knowledge/;被拒绝或要求修订的页面回到写作环节。参见 阅读审核报告。

mermaid
flowchart LR
  write["Agent 写作页面"] --> review["你来审核"]
  review -->|"修订"| write
  review -->|"批准"| kn["knowledge/"]
  kn --> build["构建"]
  build --> kb["dist/component-kb/"]
  build --> site["dist/component-site/"]

如果中途被打断,可以先关闭对话,稍后在知识工作区中再次调用 /c4a:context。它会根据知识工作区记录的状态继续,而不是根据对话,因此不会重做任何工作。

5. 构建知识包和站点 ​

对于新的知识工作区,Agent 默认会建议两个产物,构建会同时产出:

  • dist/component-kb/:供 Agent 安装和查询的知识包;
  • dist/component-site/:供人阅读的静态文档站,包含文章页面和本地搜索。

想查看站点时,可以说 “在本地预览站点。” 产物声明位于 src/index.ts;如果需要其他产物,参见 知识包。一轮结束时,Agent 会把知识工作区提交到 Git,以便之后检查、做版本管理和刷新。

6. 提出第一个问题 ​

马上试用新知识:

text
/c4a:context-inspect-search Button 组件是如何处理加载状态的?请引用代码。

回答会引用已批准的页面及其背后的来源行。回答中暴露的缺口很适合作为下一轮的内容:告诉 /c4a:context 缺了什么。

下一步 ​

  • 想深入使用,请从指南的 与 Agent 协作 开始:它说明了各方分工以及指南的组织方式。
  • 代码或文档变化时,告诉 /c4a:context 改了什么;它只会重新打开受影响的页面。参见 更新知识。
  • 知识库达到一定规模后,可以让 Agent 提出更清晰的结构;参见 大规模重组。
  • 范围更大时,请阅读 分阶段规划大型项目;所有入口和 Skill 见 命令与技能。