Code Tour

Code Tour

Creates CodeTour .tour files: persona-targeted, step-by-step walkthroughs linked to real files and lines, with validation and doc-based generation scripts.

Skill files5 files

references/

scripts/

SKILL.md433 lines
1
---
2
name: code-tour
3
description: >
4
Use this skill to create CodeTour .tour files — persona-targeted, step-by-step walkthroughs
5
that link to real files and line numbers. Trigger for: "create a tour", "make a code tour",
6
"generate a tour", "onboarding tour", "tour for this PR", "tour for this bug", "RCA tour",
7
"architecture tour", "explain how X works", "vibe check", "PR review tour",
8
"contributor guide", "help someone ramp up", or any request for a structured walkthrough
9
through code. Supports 20 developer personas (new joiner, bug fixer, architect, PR reviewer,
10
vibecoder, security reviewer, and more), all CodeTour step types (file/line, selection,
11
pattern, uri, commands, view), and tour-level fields (ref, isPrimary, nextTour).
12
Works with any repository in any language.
13
---
14
15
# Code Tour Skill
16
17
You are creating a **CodeTour** — a persona-targeted, step-by-step walkthrough of a codebase
18
that links directly to files and line numbers. CodeTour files live in `.tours/` and work with
19
the [VS Code CodeTour extension](https://github.com/microsoft/codetour).
20
21
Two scripts are bundled in `scripts/`:
22
23
- **`scripts/validate_tour.py`** — run after writing any tour. Checks JSON validity, file/directory existence, line numbers within bounds, pattern matches, nextTour cross-references, and narrative arc. Run it: `python ~/.agents/skills/code-tour/scripts/validate_tour.py .tours/<name>.tour --repo-root .`
24
- **`scripts/generate_from_docs.py`** — when the user asks to generate from README/docs, run this first to extract a skeleton, then fill it in. Run it: `python ~/.agents/skills/code-tour/scripts/generate_from_docs.py --persona new-joiner --output .tours/skeleton.tour`
25
26
Two reference files are bundled:
27
28
- **`references/codetour-schema.json`** — the authoritative JSON schema. Read it to verify any field name or type. Every field you use must conform to it.
29
- **`references/examples.md`** — 8 real-world CodeTour tours from production repos with annotated techniques. Read it when you want to see how a specific feature (`commands`, `selection`, `view`, `pattern`, `isPrimary`, multi-tour series) is used in practice.
30
31
### Real-world `.tour` files on GitHub
32
33
These are confirmed production `.tour` files. Fetch one when you need a working example of a specific step type, tour-level field, or narrative structure — don't write from memory when the real thing is one fetch away.
34
35
Find more with the GitHub code search: https://github.com/search?q=path%3A**%2F*.tour+&type=code
36
37
#### By step type / technique demonstrated
38
39
| What to study | File URL |
40
|---|---|
41
| `directory` + `file+line` (contributor onboarding) | https://github.com/coder/code-server/blob/main/.tours/contributing.tour |
42
| `selection` + `file+line` + intro content step (accessibility project) | https://github.com/a11yproject/a11yproject.com/blob/main/.tours/code-tour.tour |
43
| Minimal tutorial — tight `file+line` narration for interactive learning | https://github.com/lostintangent/rock-paper-scissors/blob/master/main.tour |
44
| Multi-tour repo with `nextTour` chaining (cloud native OCI walkthroughs) | https://github.com/lucasjellema/cloudnative-on-oci-2021/blob/main/.tours/introduction.tour |
45
| `isPrimary: true` (marks the onboarding entry point) | https://github.com/nickvdyck/webbundlr/blob/main/.tours/getting-started.tour |
46
| `pattern` instead of `line` (regex-anchored steps) | https://github.com/nickvdyck/webbundlr/blob/main/.tours/architecture.tour |
47
48
**Raw content tip:** Prefix `raw.githubusercontent.com` and drop `/blob/` for raw JSON access.
49
50
A great tour is not just annotated files. It is a **narrative** — a story told to a specific
51
person about what matters, why it matters, and what to do next. Your goal is to write the tour
52
that the right person would wish existed when they first opened this repo.
53
54
**CRITICAL: Only create `.tour` JSON files. Never create, modify, or scaffold any other files.**
55
56
---
57
58
## Step 1: Discover the repo
59
60
Before asking the user anything, explore the codebase:
61
62
- List the root directory, read the README, and check key config files
63
(package.json, pyproject.toml, go.mod, Cargo.toml, composer.json, etc.)
64
- Identify the language(s), framework(s), and what the project does
65
- Map the folder structure 1–2 levels deep
66
- Find entry points: main files, index files, app bootstrapping
67
- **Note which files actually exist** — every path you write in the tour must be real
68
69
If the repo is sparse or empty, say so and work with what exists.
70
71
**If the user says "generate from README" or "use the docs":** run the skeleton generator first, then fill in every `[TODO: ...]` by reading the actual files:
72
73
```bash
74
python skills/code-tour/scripts/generate_from_docs.py \
75
--persona new-joiner \
76
--output .tours/skeleton.tour
77
```
78
79
### Entry points by language/framework
80
81
Don't read everything — start here, then follow imports.
82
83
| Stack | Entry points to read first |
84
|-------|---------------------------|
85
| **Node.js / TS** | `index.js/ts`, `server.js`, `app.js`, `src/main.ts`, `package.json` (scripts) |
86
| **Python** | `main.py`, `app.py`, `__main__.py`, `manage.py` (Django), `app/__init__.py` (Flask/FastAPI) |
87
| **Go** | `main.go`, `cmd/<name>/main.go`, `internal/` |
88
| **Rust** | `src/main.rs`, `src/lib.rs`, `Cargo.toml` |
89
| **Java / Kotlin** | `*Application.java`, `src/main/java/.../Main.java`, `build.gradle` |
90
| **Ruby** | `config/application.rb`, `config/routes.rb`, `app/controllers/application_controller.rb` |
91
| **PHP** | `index.php`, `public/index.php`, `bootstrap/app.php` (Laravel) |
92
93
### Repo type variants — adjust focus accordingly
94
95
The same persona asks for different things depending on what kind of repo this is:
96
97
| Repo type | What to emphasize | Typical anchor files |
98
|-----------|-------------------|----------------------|
99
| **Service / API** | Request lifecycle, auth, error contracts | router, middleware, handler, schema |
100
| **Library / SDK** | Public API surface, extension points, versioning | index/exports, types, changelog |
101
| **CLI tool** | Command parsing, config loading, output formatting | main, commands/, config |
102
| **Monorepo** | Package boundaries, shared contracts, build graph | root package.json/pnpm-workspace, shared/, packages/ |
103
| **Framework** | Plugin system, lifecycle hooks, escape hatches | core/, plugins/, lifecycle |
104
| **Data pipeline** | Source → transform → sink, schema ownership | ingest/, transform/, schema/, dbt models |
105
| **Frontend app** | Component hierarchy, state management, routing | pages/, store/, router, api/ |
106
107
For **monorepos**: identify the 2–3 packages most relevant to the persona's goal. Don't try to tour everything — open the tour with a step that explains how to navigate the workspace, then stay focused.
108
109
### Large repo strategy
110
111
For repos with 100+ files: don't try to read everything.
112
113
1. Read entry points and the README first
114
2. Build a mental model of the top 5–7 modules
115
3. For the requested persona, identify the **2–3 modules that matter most** and read those deeply
116
4. For modules you're not covering, mention them in the intro step as "out of scope for this tour"
117
5. Use `directory` steps for areas you mapped but didn't read — they orient without requiring full knowledge
118
119
A focused 10-step tour of the right files beats a scattered 25-step tour of everything.
120
121
---
122
123
## Step 2: Read the intent — infer everything you can, ask only what you can't
124
125
**One message from the user should be enough.** Read their request and infer persona,
126
depth, and focus before asking anything.
127
128
### Intent map
129
130
| User says | → Persona | → Depth | → Action |
131
|-----------|-----------|---------|----------|
132
| "tour for this PR" / "PR review" / "#123" | pr-reviewer | standard | Add `uri` step for the PR; use `ref` for the branch |
133
| "why did X break" / "RCA" / "incident" | rca-investigator | standard | Trace the failure causality chain |
134
| "debug X" / "bug tour" / "find the bug" | bug-fixer | standard | Entry → fault points → tests |
135
| "onboarding" / "new joiner" / "ramp up" | new-joiner | standard | Directories, setup, business context |
136
| "quick tour" / "vibe check" / "just the gist" | vibecoder | quick | 5–8 steps, fast path only |
137
| "explain how X works" / "feature tour" | feature-explainer | standard | UI → API → backend → storage |
138
| "architecture" / "tech lead" / "system design" | architect | deep | Boundaries, decisions, tradeoffs |
139
| "security" / "auth review" / "trust boundaries" | security-reviewer | standard | Auth flow, validation, sensitive sinks |
140
| "refactor" / "safe to extract?" | refactorer | standard | Seams, hidden deps, extraction order |
141
| "performance" / "bottlenecks" / "slow path" | performance-optimizer | standard | Hot path, N+1, I/O, caches |
142
| "contributor" / "open source onboarding" | external-contributor | quick | Safe areas, conventions, landmines |
143
| "concept" / "explain pattern X" | concept-learner | standard | Concept → implementation → rationale |
144
| "test coverage" / "where to add tests" | test-writer | standard | Contracts, seams, coverage gaps |
145
| "how do I call the API" | api-consumer | standard | Public surface, auth, error semantics |
146
147
**Infer silently:** persona, depth, focus area, whether to add `uri`/`ref`, `isPrimary`.
148
149
**Ask only if you genuinely can't infer:**
150
- "bug tour" but no bug described → ask for the bug description
151
- "feature tour" but no feature named → ask which feature
152
- "specific files" explicitly requested → honor them as required stops
153
154
Never ask about `nextTour`, `commands`, `when`, or `stepMarker` unless the user mentioned them.
155
156
### PR tour recipe
157
158
For PR tours: set `"ref"` to the branch, open with a `uri` step for the PR, cover changed files first, then unchanged-but-critical files, close with a reviewer checklist.
159
160
### User-provided customization — always honor these
161
162
| User says | What to do |
163
|-----------|-----------|
164
| "cover `src/auth.ts` and `config/db.yml`" | Those files are required stops |
165
| "pin to the `v2.3.0` tag" / "this commit: abc123" | Set `"ref": "v2.3.0"` |
166
| "link to PR #456" / pastes a URL | Add a `uri` step at the right narrative moment |
167
| "lead into the security tour when done" | Set `"nextTour": "Security Review"` |
168
| "make this the main onboarding tour" | Set `"isPrimary": true` |
169
| "open a terminal at this step" | Add `"commands": ["workbench.action.terminal.focus"]` |
170
| "deep" / "thorough" / "5 steps" / "quick" | Override depth accordingly |
171
172
---
173
174
## Step 3: Read the actual files — no exceptions
175
176
**Every file path and line number in the tour must be verified by reading the file.**
177
A tour pointing to the wrong file or a non-existent line is worse than no tour.
178
179
For every planned step:
180
1. Read the file
181
2. Find the exact line of the code you want to highlight
182
3. Understand it well enough to explain it to the target persona
183
184
If a user-requested file doesn't exist, say so — don't silently substitute another.
185
186
---
187
188
## Step 4: Write the tour
189
190
Save to `.tours/<persona>-<focus>.tour`. Read `references/codetour-schema.json` for the
191
authoritative field list. Every field you use must appear in that schema.
192
193
### Tour root
194
195
```json
196
{
197
"$schema": "https://aka.ms/codetour-schema",
198
"title": "Descriptive Title — Persona / Goal",
199
"description": "One sentence: who this is for and what they'll understand after.",
200
"ref": "main",
201
"isPrimary": false,
202
"nextTour": "Title of follow-up tour",
203
"steps": []
204
}
205
```
206
207
Omit any field that doesn't apply to this tour.
208
209
**`when`** — conditional display. A JavaScript expression evaluated at runtime. Only show this tour
210
if the condition is true. Useful for persona-specific auto-launching, or hiding advanced tours
211
until a simpler one is complete.
212
```json
213
{ "when": "workspaceFolders[0].name === 'api'" }
214
```
215
216
**`stepMarker`** — embed step anchors directly in source code comments. When set, CodeTour
217
looks for `// <stepMarker>` comments in files and uses them as step positions instead of
218
(or alongside) line numbers. Useful for tours on actively changing code where line numbers
219
shift constantly. Example: set `"stepMarker": "CT"` and put `// CT` in the source file.
220
Don't suggest this unless the user asks — it requires editing source files, which is unusual.
221
222
---
223
224
### Step types — full reference
225
226
All step types: **content** (intro/closing, max 2), **directory**, **file+line** (workhorse), **selection** (code block), **pattern** (regex match), **uri** (external link), **view** (focus VS Code panel), **commands** (run VS Code commands).
227
228
> **Path rule:** `"file"` and `"directory"` must be relative to repo root. No absolute paths, no leading `./`.
229
230
---
231
232
### When to use each step type
233
234
| Situation | Step type |
235
|-----------|-----------|
236
| Tour intro or closing | content |
237
| "Here's what lives in this folder" | directory |
238
| One line tells the whole story | file + line |
239
| A function/class body is the point | selection |
240
| Line numbers shift, file is volatile | pattern |
241
| PR / issue / doc gives the "why" | uri |
242
| Reader should open terminal or explorer | view or commands |
243
244
---
245
246
### Step count calibration
247
248
Match steps to depth and persona. These are targets, not hard limits.
249
250
| Depth | Total steps | Core path steps | Notes |
251
|-------|-------------|-----------------|-------|
252
| Quick | 5–8 | 3–5 | Vibecoder, fast explorer — cut ruthlessly |
253
| Standard | 9–13 | 6–9 | Most personas — breadth + enough detail |
254
| Deep | 14–18 | 10–13 | Architect, RCA — every tradeoff surfaced |
255
256
Scale with repo size too. A 3-file CLI doesn't get 15 steps. A 200-file monolith shouldn't be squeezed into 5.
257
258
| Repo size | Recommended standard depth |
259
|-----------|---------------------------|
260
| Tiny (< 20 files) | 5–8 steps |
261
| Small (20–80 files) | 8–11 steps |
262
| Medium (80–300 files) | 10–13 steps |
263
| Large (300+ files) | 12–15 steps (scoped to relevant subsystem) |
264
265
---
266
267
### Writing excellent descriptions — the SMIG formula
268
269
Every description should answer four questions in order. You don't need four paragraphs — but every description needs all four elements, even briefly.
270
271
**S — Situation**: What is the reader looking at? One sentence grounding them in context.
272
**M — Mechanism**: How does this code work? What pattern, rule, or design is in play?
273
**I — Implication**: Why does this matter for *this persona's goal specifically*?
274
**G — Gotcha**: What would a smart person get wrong here? What's non-obvious, fragile, or surprising?
275
276
Descriptions should tell the reader something they couldn't learn by reading the file themselves. Name the pattern, explain the design decision, flag failure modes, and cross-reference related context.
277
278
---
279
280
## Narrative arc — every tour, every persona
281
282
1. **Orientation** — **must be a `file` or `directory` step, never content-only.**
283
Use `"file": "README.md", "line": 1` or `"directory": "src"` and put your welcome text in the description.
284
A content-only first step (no `file`, `directory`, or `uri`) renders as a blank page in VS Code CodeTour — this is a known VS Code extension behaviour, not configurable.
285
286
2. **High-level map** (1–3 directory or uri steps) — major modules and how they relate.
287
Not every folder — just what this persona needs to know.
288
289
3. **Core path** (file/line, selection, pattern, uri steps) — the specific code that matters.
290
This is the heart of the tour. Read and narrate. Don't skim.
291
292
4. **Closing** (content) — what the reader now understands, what they can do next,
293
2–3 suggested follow-up tours. If `nextTour` is set, reference it by name here.
294
295
### Closing steps
296
297
Don't summarize — the reader just read it. Instead, tell them what they can now *do*, what to avoid, and suggest 2-3 follow-up tours.
298
299
---
300
301
## The 20 personas
302
303
| Persona | Goal | Must cover | Avoid |
304
|---------|------|------------|-------|
305
| **Vibecoder** | Get the vibe fast | Entry point, request flow, main modules. Max 8 steps. | Deep dives, edge cases |
306
| **New joiner** | Structured ramp-up | Directories, setup, business context, service boundaries. | Advanced internals |
307
| **Bug fixer** | Root cause fast | User action → trigger → fault points. Repro hints + test locations. | Architecture tours |
308
| **RCA investigator** | Why did it fail | Causality chain, side effects, race conditions, observability. | Happy path |
309
| **Feature explainer** | One feature end-to-end | UI → API → backend → storage. Feature flags, edge cases. | Unrelated features |
310
| **PR reviewer** | Review the change correctly | Change story, invariants, risky areas, reviewer checklist. URI step for PR. | Unrelated context |
311
| **Security reviewer** | Trust boundaries | Auth flow, input validation, secret handling, sensitive sinks. | Unrelated business logic |
312
| **Refactorer** | Safe restructuring | Seams, hidden deps, coupling hotspots, safe extraction order. | Feature explanations |
313
| **External contributor** | Contribute without breaking | Safe areas, code style, architecture landmines. | Deep internals |
314
| **Tech lead / architect** | Shape and rationale | Module boundaries, design tradeoffs, risk hotspots. | Line-by-line walkthroughs |
315
316
---
317
318
## Designing a tour series
319
320
When a codebase is complex enough that one tour can't cover it well, design a series.
321
The `nextTour` field chains them: when the reader finishes one tour, VS Code offers to
322
launch the next automatically.
323
324
**Plan the series before writing any tour.** A good series has:
325
- A clear escalation path (broad → narrow, orientation → deep-dive)
326
- No duplicate steps between tours
327
- Each tour standalone enough to be useful on its own
328
329
Set `nextTour` in each tour to the `title` of the next one (must match exactly). Each tour should be standalone enough to be useful on its own.
330
331
---
332
333
## What CodeTour cannot do
334
335
If asked for any of these, say clearly that it's not supported — do not suggest a workaround that doesn't exist:
336
337
| Request | Reality |
338
|---|---|
339
| **Auto-advance to next step after X seconds** | Not supported. Navigation is always manual — the reader clicks Next. There is no timer, delay, or autoplay step mechanic in CodeTour. |
340
| **Embed a video or GIF in a step** | Not supported. Descriptions are Markdown text only. |
341
| **Run arbitrary shell commands** | Not supported. `commands` only executes VS Code commands (e.g. `workbench.action.terminal.focus`), not shell commands. |
342
| **Branch / conditional next step** | Not supported. Tours are linear. `when` controls whether a tour is shown, not which step follows which. |
343
| **Show a step without opening a file** | Partially — content-only steps work, but step 1 must have a `file` or `directory` anchor or VS Code shows a blank page. |
344
345
---
346
347
## Anti-patterns
348
349
| Anti-pattern | Fix |
350
|---|---|
351
| **File listing** — visiting files with "this file contains..." | Tell a story; each step should depend on the previous one |
352
| **Generic descriptions** | Name the specific pattern/gotcha unique to *this* codebase |
353
| **Line number guessing** | Never write a line number you didn't verify by reading the file |
354
| **Ignoring the persona** | Cut every step that doesn't serve their specific goal |
355
| **Hallucinated files** | If a file doesn't exist, skip the step |
356
357
---
358
359
## Quality checklist — verify before writing the file
360
361
- [ ] Every `file` path is **relative to the repo root** (no leading `/` or `./`)
362
- [ ] Every `file` path read and confirmed to exist
363
- [ ] Every `line` number verified by reading the file (not guessed)
364
- [ ] Every `directory` is **relative to the repo root** and confirmed to exist
365
- [ ] Every `pattern` regex would match a real line in the file
366
- [ ] Every `uri` is a complete, real URL (https://...)
367
- [ ] `ref` is a real branch/tag/commit if set
368
- [ ] `nextTour` exactly matches the `title` of another `.tour` file if set
369
- [ ] Only `.tour` JSON files created — no source code touched
370
- [ ] First step has a `file` or `directory` anchor (content-only first step = blank page in VS Code)
371
- [ ] Tour ends with a closing content step that tells the reader what they can *do* next
372
- [ ] Every description answers SMIG — Situation, Mechanism, Implication, Gotcha
373
- [ ] Persona's priorities drive step selection (cut everything that doesn't serve their goal)
374
- [ ] Step count matches requested depth and repo size (see calibration table)
375
- [ ] At most 2 content-only steps (intro + closing)
376
- [ ] All fields conform to `references/codetour-schema.json`
377
378
---
379
380
## Step 5: Validate the tour
381
382
**Always run the validator immediately after writing the tour file. Do not skip this step.**
383
384
```bash
385
python ~/.agents/skills/code-tour/scripts/validate_tour.py .tours/<name>.tour --repo-root .
386
```
387
388
The validator checks:
389
- JSON validity
390
- Every `file` path exists and every `line` is within file bounds
391
- Every `directory` exists
392
- Every `pattern` regex compiles and matches at least one line in the file
393
- Every `uri` starts with `https://`
394
- `nextTour` matches an existing tour title in `.tours/`
395
- Content-only step count (warns if > 2)
396
- Narrative arc (warns if no orientation or closing step)
397
398
**Fix every error before proceeding.** Re-run until the validator reports ✓ or only warnings. Warnings are advisory — use your judgment. Do not show the user the tour until validation passes.
399
400
**Common VS Code issues:** Content-only first step renders blank (anchor to file/directory instead). Absolute or `./`-prefixed paths silently fail. Out-of-bounds line numbers scroll nowhere.
401
402
If you can't run scripts, manually verify: step 1 has `file`/`directory`, all paths exist, all line numbers are in bounds, `nextTour` matches exactly.
403
404
**Autoplay:** `isPrimary: true` + `.vscode/settings.json` with `{ "codetour.promptForPrimaryTour": true }` prompts on repo open. Omit `ref` for tours that should appear on any branch.
405
406
**Share:** For public repos, users can open tours at `https://vscode.dev/github.com/<owner>/<repo>` with no install.
407
408
---
409
410
## Step 6: Summarize
411
412
After writing the tour, tell the user:
413
- File path (`.tours/<name>.tour`)
414
- One-paragraph summary of what the tour covers and who it's for
415
- The `vscode.dev` URL if the repo is public (so they can share it immediately)
416
- 2–3 suggested follow-up tours (or the next tour in the series if one was planned)
417
- Any user-requested files that didn't exist (be explicit — don't quietly substitute)
418
419
---
420
421
## File naming
422
423
`<persona>-<focus>.tour` — kebab-case, communicates both:
424
```
425
onboarding-new-joiner.tour
426
bug-fixer-payment-flow.tour
427
architect-overview.tour
428
vibecoder-quickstart.tour
429
pr-review-auth-refactor.tour
430
security-auth-boundaries.tour
431
concept-dependency-injection.tour
432
rca-login-outage.tour
433
```

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…