Codetour authoring

From findscripter/everything-skills · View interactive version

Codetour authoring is an AI agent skill from the GitHub repository findscripter/everything-skills. 当用户要为代码库做入职引导、架构走读、PR/RCA/安全审查导览,或提出结构化「解释 X 如何工作」并想要可复用引导产物时使用;做按角色定深度、锚定真实文件与行号、按叙事弧写步骤,产出 .tours/ 下的 CodeTour .tour(JSON)文件;不适用于一次性口头解释、要散文式文档而非 .tour 产物、实现/重构任务,或无产物的宽泛代码库入职。触发词:代码导览、code tour、onboarding 导览、架构走读、PR 导览、解释这块怎么工作

How to use this skill

Skill file

何时使用

当一段走读用「带锚点的引导序列」比「平铺摘要」更有价值时使用。产物是 .tours/ 下的 CodeTour .tour(JSON)文件——能在 VS Code CodeTour 插件里直接打开到真实文件和行范围,而不是临时的 Markdown 笔记。

一份好导览是为特定读者讲的故事:他们在看什么、为什么重要、接下来该走哪条路。

典型场景:

不该用边界:

| 与其用代码导览 | 不如 |

| --- | --- |

| 聊天里一次性解释就够 | 直接回答 |

| 用户要散文式文档而非 .tour 产物 | 交给 docs-architect / 仓库文档编辑 |

| 任务是实现或重构 | 直接做实现工作 |

| 宽泛的代码库入职、不需要 .tour 产物 | 交给 codebase-onboarding-doc |

硬约束:只创建 .tour JSON 文件,本技能范围内不修改任何源代码。

步骤

1. 探索(动笔前必做)

写任何步骤前先摸清代码形状:README 与包/应用入口、目录结构、相关配置文件;若导览聚焦 PR,则先看变更文件。没理解代码结构前不要开始写步骤。

2. 推断读者(定角色与深度)

由请求形态决定 persona 和步数:

| 请求形态 | 角色 persona | 建议深度 |

| --- | --- | --- |

| 「入职」「新成员」 | new-joiner | 9–13 步 |

| 「快速导览」「快速了解」 | vibecoder | 5–8 步 |

| 「架构」 | architect | 14–18 步 |

| 「导览这个 PR」 | pr-reviewer | 7–11 步 |

| 「为什么挂了」 | rca-investigator | 7–11 步 |

| 「安全审查」 | security-reviewer | 7–11 步 |

| 「解释这个功能怎么工作」 | feature-explainer | 7–11 步 |

| 「调试这条路径」 | bug-fixer | 7–11 步 |

3. 读取并验证锚点

每个文件路径和行锚点都必须真实:确认文件存在、确认行号在范围内、用 selection 时核对确切代码块;文件易变时优先用 pattern 锚点。绝不猜测行号。

4. 写 `.tour`

路径保持确定、可读:

.tours/<persona>-<focus>.tour

5. 验证(收尾前)

指令

步骤类型(`steps[]`)

```json

{ "title": "Next Steps", "description": "You can now trace the request path end to end." }

```

```json

{ "directory": "src/services", "title": "Service Layer", "description": "The core orchestration logic lives here." }

```

```json

{ "file": "src/auth/middleware.ts", "line": 42, "title": "Auth Gate", "description": "Every protected request passes here first." }

```

```json

{ "file": "src/core/pipeline.ts", "selection": { "start": { "line": 15, "character": 0 }, "end": { "line": 34, "character": 0 } }, "title": "Request Pipeline" }

```

```json

{ "file": "src/app.ts", "pattern": "export default class App", "title": "Application Entry" }

```

```json

{ "uri": "https://github.com/org/repo/pull/456", "title": "The PR" }

```

写描述的规则:SMIG

每条 description 应回答四点,并保持简洁、具体、贴合真实代码:

叙事弧(除非任务另有需要)

  1. 定位 → 2. 模块地图 → 3. 核心执行路径 → 4. 边缘情况/陷阱 → 5. 收尾/下一步。导览应像一条路径,而非一份清单。

反模式与修复

| 反模式 | 修复 |

| --- | --- |

| 平铺的文件列表 | 让步骤间有依赖、讲成故事 |

| 通用空泛描述 | 指明具体代码路径或模式 |

| 猜测的锚点 | 先逐个验证文件与行 |

| 快速导览步骤过多 | 果断精简 |

| 第一步是纯内容 | 第一步锚定到真实文件/目录 |

| 角色错配 | 为真实读者而非「通用工程师」写 |

示例

一份最小可用的 .tour(payments 服务请求路径走读):

{
  "$schema": "https://aka.ms/codetour-schema",
  "title": "API Service Tour",
  "description": "Walkthrough of the request path for the payments service.",
  "ref": "main",
  "steps": [
    { "directory": "src", "title": "Source Root", "description": "All runtime code for the service starts here." },
    { "file": "src/server.ts", "line": 12, "title": "Entry Point", "description": "The server boots here and wires middleware before any route is reached." },
    { "file": "src/routes/payments.ts", "line": 8, "title": "Payment Routes", "description": "Every payments request enters through this router before hitting service logic." },
    { "title": "Next Steps", "description": "You can now follow any payment request end to end with the main anchors in place." }
  ]
}

注意事项

互见


采编自 affaan-m/everything-claude-code(MIT),适配重写,非逐字翻译。

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.