with one click
diffity-tour
// Create a guided code tour that walks through the codebase to answer a question or explain a feature. Opens in the browser with step-by-step navigation and highlighted code.
// Create a guided code tour that walks through the codebase to answer a question or explain a feature. Opens in the browser with step-by-step navigation and highlighted code.
Create a guided code tour that walks through the codebase to answer a question or explain a feature. Opens in the browser with step-by-step navigation and highlighted code.
Start a project-driven learning journey for any technical topic — programming languages, tools, frameworks, or concepts. Teaches through real projects, Diffity tours, and interactive conversation, adapting to the learner's pace.
Start a project-driven learning journey for any technical topic — programming languages, tools, frameworks, or concepts. Teaches through real projects, Diffity tours, and interactive conversation, adapting to the learner's pace.
Review current diff and leave comments using diffity agent commands
Review current diff and leave comments using diffity agent commands
Read open review comments and resolve them by making code fixes
| name | diffity-tour |
| description | Create a guided code tour that walks through the codebase to answer a question or explain a feature. Opens in the browser with step-by-step navigation and highlighted code. |
| user-invocable | true |
You are creating a guided code tour — a narrated, step-by-step walkthrough of the codebase that answers the user's question or explains how a feature works. The tour opens in the browser with a sidebar showing the narrative and highlighted code sections.
question (required): The user's question, topic, concept, or a GitHub PR URL. Examples:
/diffity-tour how does authentication work?/diffity-tour explain the request lifecycle/diffity-tour how are comments stored and retrieved?/diffity-tour closures/diffity-tour React hooks/diffity-tour walk me through this branch before I merge/diffity-tour https://github.com/owner/repo/pull/123When the argument is a GitHub PR URL (matching github.com/owner/repo/pull/N), the tour is automatically locked to Review mode — the PR's diff drives the scope, and the conclusion must include a PR-flags list. See the Review tours section below.
{{binary}} agent tour-start --topic "<text>" [--body "<text>"] --json
{{binary}} agent tour-step --tour <id> --file <path> --line <n> [--end-line <n>] --body "<text>" [--annotation "<text>"] --json
{{binary}} agent tour-done --tour <id> --json
{{binary}} list --json
{{binary}} is available: run which {{binary}}. If not found, {{install_hint}}.gh is installed and authenticated: run gh auth status. If not authenticated, stop and ask the user to run gh auth login.gh repo view --json nameWithOwner -q .nameWithOwner and confirm it matches the owner/repo in the URL. If it doesn't, stop and tell the user they need to be inside the PR's repository clone — diffity can't tour a PR for a repo you don't have checked out.{{binary}} --no-open <pr-url> using the Bash tool with run_in_background: true. The --no-open flag must come BEFORE the URL — commander's passThroughOptions() will slurp any flag that appears after the positional URL into the refs array, skipping PR handling and producing an "unknown ref" error. This command checks out the PR's branch locally and starts a diff-scoped session. Wait 2 seconds, then run {{binary}} list --json to get the port. You do not also need a tree instance — the diff session supports agent tour-* commands.{{binary}} list --json.
{{binary}} tree --no-open using the Bash tool with run_in_background: true, wait 2 seconds, then run {{binary}} list --json to get the port.Before doing anything else, decide which mode this tour belongs to. The rest of the skill branches on this choice — scope, research method, and output shape all differ by mode. Do this before any tool calls.
Shortcut: if the argument is a GitHub PR URL (matches github.com/owner/repo/pull/N), skip the decision — it is locked to Review mode.
| Mode | Use when the user asks... | Scoped by | Target steps |
|---|---|---|---|
| Focused | a narrow "how does X work?" question | one code path | 3-6 |
| Feature | "how does this feature work?" | a feature boundary | 6-10 |
| System | "how does the whole thing work?" | architecture | 8-15 |
| Concept | about a programming concept | examples in the code | 3-8 |
| Review | to audit a branch/PR/feature before merge | git diff <base>..HEAD | variable — cover every meaningful change |
Trigger words that steer toward each mode:
closures, React hooks, async/await, generics)If multiple modes fit, prefer the more specific one (Review > Concept > Focused > Feature > System). If you genuinely can't tell which the user wants, ask before researching — don't guess and produce the wrong tour shape.
Mode changes which sections of this skill apply:
Before creating any tour steps, you must deeply understand the answer to the user's question.
Confirm the scope. The mode you picked sets a rough step count (see Pick a mode above). If the user's question is too broad to fit at that size (e.g. "explain everything" landing in System mode), mentally narrow to the most important aspect and state in the intro what you're covering and what you're leaving out.
Identify the audience. Consider how the question was phrased:
Research the codebase. Read the relevant source files thoroughly. Follow the code path from entry point to completion.
For review tours especially, also read git log --reverse <base>..HEAD and open any commit whose message describes a non-obvious fix, refactor, or defensive change. The author's own narrative is often the best source of why — far better than inferring intent from the code alone. Quote or paraphrase commit reasoning in step bodies where it illuminates a design decision (e.g. "commit abc1234 introduced this check after a production incident where...").
When touring a GitHub PR, use gh for metadata and diff:
gh pr view <url> --json title,body,baseRefName,headRefName,commits,files — PR title, body, base/head branches, commit list, and changed-file list. The PR body often contains the richest "why" (design context, screenshots, trade-offs the author considered) — quote or summarize it in the intro.gh pr diff <url> — the unified diff that defines the tour's scope. Use this to confirm the full surface area, not just what you see in git diff.baseRefName (from the JSON above) as the diff base — not master/main by default. Commands like git log --reverse <baseRefName>..<headRefName> walk the PR's commits in author order.{{binary}} <pr-url> has already checked out the PR branch locally.Identify the key locations that tell the story — the files and line ranges that someone needs to see to understand the answer.
Note configuration dependencies. If the behavior changes based on environment variables, feature flags, config files, or runtime conditions, note these. They must be called out in the tour so the reader understands "this is what happens when X is configured, but if Y were set instead, the flow would differ here."
Plan a logical sequence of steps that builds understanding progressively. Each step should lead naturally to the next.
Guidelines for choosing steps:
{{binary}} main, this becomes...").Top-down, not bottom-up. A tour mirrors how the code runs at runtime, not how it was built. Do not walk config → schema → helpers → routes → actions. Walk route → action → (schema appears here because a query reads it) → (config appears here because a handler references it) → (helper appears here because something calls it). Readers retain context better when each new piece is introduced at the moment it becomes relevant. The reader should feel they're sitting next to you as you trace a real request, not sitting through a lecture about architecture before the demo starts.
Handling cross-module flows: When the code path crosses into a library, utility module, or deeply nested abstraction, decide whether to follow it:
Patterns applied across many files. When a single change is replicated across N similar call sites (e.g. the same guard added to 8 handlers, the same middleware registered on every route), do not make N steps. Make one step on the most representative file with full context, then list the other call sites as goto links in the body ("the same guard is also added to X, Y, Z"). One concept, one step — the tour should teach the reader the pattern once, not N times. The exception: if one of the applications is subtly different from the others (e.g. called twice in a transfer flow, or with different args), spend a separate step on that one.
The tour UI has a dedicated explanation panel. The intro (from tour-start --body) is displayed as step 0 — the first thing the reader sees, filling the full panel. Each subsequent step shows its narrative in the same panel alongside the highlighted code. Since the panel has generous space, write rich, detailed explanations.
Start the tour with a short topic title and introductory body:
{{binary}} agent tour-start --topic "<short title>" --body "<intro>" --json
The --topic is displayed in the tour panel header — keep it to 3–6 words (e.g. "Authentication Flow", "How Routing Works", "Comment System Architecture"). Do NOT use the user's full question as the topic.
Writing the intro body (step 0): This is the first thing the reader sees and it fills the entire explanation panel. Use this space for a thorough architectural overview that sets up everything the reader needs before diving into code. Include:
If you scoped down a broad question, state what you're covering: "This tour focuses on the OAuth login flow. Token refresh and session management are related but covered separately."
Use rich markdown formatting — paragraphs, bold, code, tables, code blocks. This is not a table of contents of what the tour will cover; it's a standalone overview that orients the reader.
Extract the tour ID from the JSON output.
Add steps in order. For each step:
{{binary}} agent tour-step --tour <id> --file <path> --line <start> --end-line <end> --body "<narrative>" --annotation "<short label>" --json
Writing step content:
--file: Path relative to repo root (e.g. src/server.ts)--line / --end-line: The exact line range to highlight. Keep it focused on the relevant section.--annotation: A short label (3-6 words) shown as the step title. Think of it as a chapter heading.--body: The narrative shown in the explanation panel. This has generous space — use it to write thorough explanations using markdown:Verify targets before committing to a step. Before calling tour-step, verify that the --file path is readable from the repo root and that the function or block you're describing actually lives at the advertised --line/--end-line range — read the range, don't trust memory from earlier in the session. The same applies to every goto: link in the body: a broken goto link is worse than no link because the reader trusts it and gets dropped in the wrong place without any signal that the link is wrong. If you're not sure of the exact line, use plain backtick code instead of a goto link.
Step body structure. Every step body should follow this arc, in order:
focus:X-Y) if the range breaks into distinct sections.A step body without a transition feels dropped-in; one without a takeaway feels unfinished. Aim for roughly 150-300 words per step body — longer only if the logic genuinely demands it. If your draft is over 400 words, the step is probably trying to cover two things; consider splitting it.
Step transitions — connecting the narrative: Each step should feel like a natural continuation of the previous one. Start each step body with a transition sentence that connects it to what came before:
Never start a step as if the reader arrived out of context. The tour is a story — each step is a chapter, not an isolated paragraph.
Do:
Write in prose paragraphs, supplemented by structured content where it helps
Use code for function names, variables, refs, commands. When referencing a function, class, or code symbol that lives in a known file and line, make it a goto link so the reader can click to jump there. Syntax: [`symbolName`](goto:path/to/file.ts:startLine-endLine) or [`symbolName`](goto:path/to/file.ts:line) for a single line. These render as clickable inline code that navigates to the file and highlights the target lines. Example: [`handleDragEnd`](goto:src/KanbanContent.jsx:42-58). Use plain backtick code for generic terms, CLI commands, or symbols you haven't located in the codebase.
Use bold for key concepts being introduced
Explain why the code exists and the design decisions behind it, not just what it does
Use concrete examples: "When you run diffity main, this line calls normalizeRef('main') which computes git merge-base main HEAD"
Use tables for mappings (input → output, ref → git command)
Use code blocks for data structures or command outputs
Connect each step to the bigger picture from the intro
Call out edge cases and gotchas — if there's a non-obvious behavior, a known limitation, or a "this looks wrong but it's intentional" moment, flag it. These are the things that trip people up when they work on this code later.
For large highlighted ranges, use sub-highlight links to focus on specific sub-sections within the step. Syntax: [label](focus:startLine-endLine). These render as clickable chips that shift the highlight to the specified lines. Example:
First, the function validates its parameters:
[Parameter validation](focus:15-22)
Then the core transform processes each entry:
[Core transform](focus:25-40)
Finally, results are cached before returning:
[Result caching](focus:42-48)
Use sub-highlights when a step covers 30+ lines and the narrative naturally breaks into distinct sections. The line ranges must be within the step's --line / --end-line range.
Mermaid diagrams: When a concept is easier to understand visually — architecture relationships, data flows, state machines, sequence diagrams — include a mermaid code block. Don't force diagrams into every step; use them where they genuinely clarify the explanation. Good candidates:
Choose the most appropriate diagram type:
graph TD/LR for architecture, module dependencies, data flowsequenceDiagram for call chains, request/response flowsstateDiagram-v2 for state machines, lifecycle transitionsclassDiagram for type hierarchies, struct relationshipsflowchart for algorithms, decision trees, control flowKeep diagrams concise (under ~12 nodes). They render inline in the tour panel.
Don't:
Add a conclusion step. The final step of the tour should wrap things up. Reuse the file/line range from the last meaningful step and write a body that:
Use the annotation "Putting It Together" for this step.
Finish the tour:
{{binary}} agent tour-done --tour <id> --json
Get the running instance port from {{binary}} list --json.
Open the tour: open "http://localhost:<port>/tour/<tour-id>" (or the appropriate command for the user's OS).
Tell the user the tour is ready:
Your tour is ready — check your browser.
When the user asks about a programming concept rather than a feature or flow (e.g. "closures", "generics", "error handling patterns"), the tour becomes a teaching tool.
How concept tours differ from feature tours:
All other tour guidelines (transitions, goto links, sub-highlights, mermaid diagrams, conclusion) still apply.
When the user asks for a tour to review a branch, PR, or feature before merge, organize the tour as a request trace through the user-facing flows, not as an architecture walkthrough. This is the mode most likely to produce an audit the reader can act on.
How review tours differ from feature tours:
git diff <base>...HEAD (and relevant commits) to know the full surface area. Every meaningful change should be visited; skip only pure boilerplate.All other tour guidelines (transitions, goto links, sub-highlights, mermaid diagrams, conclusion) still apply.
Before finishing, verify:
goto: link and every --file / --line value has been verified against the actual file — no guessed line numbers