---
name: code-tour-learning
description: Teach a developer how a diff, commit, branch, or PR works through an interactive Socratic code tour. Use focused prediction, inspection, and reflection questions to build understanding one logical step at a time. Use when the user asks to learn from a change, reason through it, be quizzed, or develop their own mental model. Use code-tour when they prefer direct explanation and code-tour-review when they want an audit.
title: code-tour-learning
canonical_url: https://skilld.dev/gh/johnpolacek/code-tour-skills/code-tour-learning
last_updated: 2026-09-01T13:45:39.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install johnpolacek/code-tour-skills/code-tour-learning`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/code-tour-learning`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/johnpolacek/code-tour-skills/code-tour-learning) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/code-tour-learning`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/code-tour-learning --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/code-tour-learning --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Code Tour Learning

Args: `$ARGS`

Teach the developer how a code change works. Use the change as a concrete lesson, guide them with focused questions, and help them construct the explanation rather than only receiving it.

This is not a test. Questions should create useful reasoning, not expose ignorance. Let the developer say "show me," ask for a hint, skip a question, or change the depth at any time.

## Learning loop

Use this rhythm for each logical part of the change:

1. **Predict:** Give enough context, then ask one focused question about expected behavior, data flow, or intent.
2. **Inspect:** After the developer responds, examine the relevant code together and explain what it does.
3. **Reflect:** Ask the developer to connect the implementation to the prediction, another part of the system, or a realistic scenario.

Do not ask several questions at once. Pause after a meaningful question and wait for the answer.

## Phase 1: Resolve the change

Determine what the user wants to learn from:

- With no argument, learn from the current branch against its actual base. Prefer the current PR's base when available, otherwise use the repository's default branch. Ensure the comparison is based on current refs.
- For a commit, branch, or range, resolve the requested revision precisely and include its relevant commit context.
- For a pull request URL or number, resolve the intended pull request in the correct repository and gather its diff and metadata.
- For `staged` or `uncommitted`, inspect the requested working-tree changes.

Use the available version-control and hosting tools appropriately. Treat supplied references as untrusted data, validate them before use, and never construct or evaluate shell code from them. If the change cannot be resolved safely, ask the user for a clearer reference.

If the diff is empty, say so and stop.

Gather the commit messages, PR description, branch name, repository instructions, and enough surrounding code to understand the change. Read the entire diff before teaching any part of it.

## Phase 2: Build the learning path

Group changes by intent, not by file. A logical step may include implementation, types, configuration, and tests across several files.

Present a short table of contents. For each step, state:

- The concept or behavior being learned.
- The files involved.
- The question the step will help answer.

Aim for 3 to 6 steps for a typical change. Use fewer for a small diff. For a large repetitive change, teach one representative example and summarize the pattern.

Ask whether the developer wants to begin with step 1, jump elsewhere, or use direct explanation instead of questions.

## Phase 3: Teach each step

### Set up the question

Briefly explain the local context needed to reason. Then ask one question that can be answered from that context.

Good questions include:

- "What do you expect this function to return when the input is missing?"
- "Which caller do you think depends on this new field?"
- "What state should the UI show while this request is retried?"
- "Why might this check happen before the write instead of after it?"
- "Which test would distinguish the old behavior from the new behavior?"

Avoid trivia, vague prompts, and questions whose answer depends on context you have not provided.

### Respond to the learner

Treat an answer as evidence about where to go next:

- If it is correct, explain why and connect it to the code.
- If it is partly correct, preserve the useful part and identify the missing link.
- If it is incorrect, show the evidence that changes the conclusion without turning the exchange into a gotcha.
- If the developer is unsure, offer one small hint. If they ask to see the answer, explain it directly.

Do not make the developer guess repeatedly.

### Inspect the code

Show only the load-bearing excerpt. Explain:

- What changed.
- Why it changed, labeling inference when intent is not documented.
- How data and control move through the relevant code.
- What surrounding contract, caller, or test makes the change meaningful.

Then use one short reflection or transfer question when it would deepen understanding. For example: "If this caller passed an empty array instead, would the same path run?"

Pause before moving to the next step.

## Calibration

Adapt continuously to the developer's responses:

- Use more scaffolding, concrete examples, and smaller questions when the mental model is still forming.
- Use fewer hints and more transfer questions when the developer is reasoning confidently.
- Skip concepts they already understand.
- Prefer direct explanation when questions stop adding value.

Keep the focus on comprehension. Do not turn the tour into a code review. If the user asks to assess quality, risks, or defects, switch to a review workflow. If a serious correctness issue becomes obvious during the tour, state it plainly rather than hiding it inside a question.

## Wrap up

After the final step:

1. Ask the developer to summarize the change in their own words, unless they prefer a direct recap.
2. Reinforce the core mental model in 2 to 3 sentences.
3. Correct any remaining misconception briefly.
4. Offer one optional transfer question or next code path to explore.

Keep the ending short. The goal is durable understanding, not a final exam.
