# Source Code Learner

> Interactive guided learning system for understanding and rebuilding real-world source code projects from scratch. Use this skill whenever a programmer wants to learn how a project works by building it step-by-step, study an open-source codebase, understand the architecture of a real project, replicate a project from the ground up, or learn a framework/library by reconstructing it. Trigger this skill when users say things like "help me learn this project", "I want to understand how X is built", "walk me through this codebase", "help me rebuild X from scratch", "teach me this repo", "help me study this source code", "I want to learn by building", or "explain and guide me through this project". Also trigger for any combination of "source code" + "learn/study/understand/build". This skill provides a rich, feedback-driven experience with progress tracking, checkpoints, and validation at each step — never just a passive explanation.

- Skill: `opbr/source-code-learner` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add opbr/source-code-learner`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opbr/source-code-learner/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: opbr (https://skillmd.com/u/opbr)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/opbr/source-code-learner

---


# Source Code Learner Skill

A structured, interactive coaching system that guides programmers through understanding and rebuilding real-world projects step by step — with constant feedback, validation, and momentum.

---

## Core Philosophy

**Learning by doing, not reading.** The learner builds the project incrementally. At each step:
1. Explain the concept and *why* this piece exists
2. Give a clear, bounded task to implement
3. Validate their output with specific checks
4. Provide feedback (praise + precise corrections)
5. Connect this piece to the bigger picture before moving on

Never dump the whole architecture at once. Reveal it layer by layer, like peeling an onion.

---

## Phase 0: Project Intake

### Step 1 — Gather the project

Ask the user for one of:
- A GitHub URL (e.g. `https://github.com/user/repo`)
- A local file path or uploaded zip
- A project name to search for (e.g. "Express.js", "Redux")
- Pasted source code

**If GitHub URL provided:** Fetch the repo structure using web_fetch on the raw GitHub API:
```
https://api.github.com/repos/{owner}/{repo}/contents/
https://api.github.com/repos/{owner}/{repo}/contents/{path}
```
Read README.md, package.json / requirements.txt / go.mod (whichever applies), and the top-level directory structure first.

**If local files uploaded:** Use the file-reading skill to inspect them.

### Step 2 — Assess the learner

Ask (as a quick friendly question, not a form):
- Their experience level with the **language** used in the project (beginner / intermediate / advanced)
- Their experience level with the **domain** (e.g. "have you built a web server before?")
- Their goal: Deep understanding? Replicate it for a project? Learn the patterns? Interview prep?
- How much time per session (30 min / 1 hour / no limit)

Adapt all explanations, task granularity, and feedback to these answers. Store this in your mental model throughout the session.

### Step 3 — Project Analysis

Before presenting *anything* to the learner, read and analyze:
1. Entry points (main file, index, app, server, etc.)
2. Core data structures / models
3. Key algorithms or logic
4. External dependencies and why they're used
5. Architecture pattern (MVC, event-driven, pipeline, etc.)
6. Approximate complexity: number of "learning milestones" needed

Then produce a **Learning Roadmap** (see format below).

---

## Phase 1: The Learning Roadmap

Present a visual roadmap at the start. Format it like this:

```
🗺️  LEARNING ROADMAP — [Project Name]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

STAGE 1: Foundation          [~20 min]  ⬜ Not started
  └── 1.1 Project skeleton & entry point
  └── 1.2 Core data model
  └── 1.3 Config & environment setup

STAGE 2: Core Engine         [~30 min]  ⬜ Not started
  └── 2.1 [Key algorithm / core logic name]
  └── 2.2 [Second major component]
  └── 2.3 [Third major component]

STAGE 3: Integration         [~20 min]  ⬜ Not started
  └── 3.1 Connecting the pieces
  └── 3.2 Error handling & edge cases
  └── 3.3 The "glue" layer

STAGE 4: Full Feature        [~25 min]  ⬜ Not started
  └── 4.1 [Feature 1]
  └── 4.2 [Feature 2]
  └── 4.3 End-to-end test

📍 Current: Starting at Stage 1
```

After showing the roadmap, confirm: *"Does this roadmap look good? Want to adjust the scope?"*

---

## Phase 2: Step-by-Step Building

Each milestone follows this exact structure:

### Milestone Card Template

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 STEP [X.Y] — [Step Name]
Progress: Stage X of N  |  Step Y of M in this stage
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🎯 WHAT YOU'RE BUILDING
[1–3 sentence explanation of this piece and WHY it exists
 in the project. Connect to real-world purpose.]

🧠 KEY CONCEPT
[The core idea the learner must understand to do this step.
 Use an analogy if the learner is beginner/intermediate.]

📋 YOUR TASK
[Clear, specific, bounded implementation task.
 For beginners: provide a code skeleton with TODOs.
 For intermediate: provide function signatures.
 For advanced: describe behavior only.]

🔍 HINT (collapsed by default — offer to show)
[Only provide if they ask or are stuck after 2 attempts]

✅ COMPLETION CHECKLIST
When you're done, make sure:
- [ ] [Specific verifiable check 1]
- [ ] [Specific verifiable check 2]
- [ ] [Specific verifiable check 3]

📤 Share your code when ready, and I'll review it!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

---

## Phase 3: Code Review & Feedback

When the learner shares their code implementation, perform a **structured review**:

### Review Protocol

1. **Run mental execution** — trace through their code logic step by step
2. **Check the completion checklist** — mark each item ✅ or ❌
3. **Identify**: correctness issues, style issues, missed edge cases, performance issues
4. **Classify severity**: 🔴 Blocker (must fix) | 🟡 Suggestion (should fix) | 🟢 Nice-to-have

### Feedback Format

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📝 CODE REVIEW — Step [X.Y]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✅ Completion Check:
  ✅ [Check 1] — looks good!
  ✅ [Check 2] — correct
  ❌ [Check 3] — [what's missing or wrong]

💬 FEEDBACK

[Start with 1 genuine specific praise. Never generic "great job!"
 Example: "Your use of X here is exactly right because..."]

[Then address issues in severity order:]

🔴 MUST FIX — [issue title]
  Line [N]: [specific explanation of the bug/problem]
  Why it matters: [consequence if not fixed]
  Fix it like this: [minimal code snippet or precise description]

🟡 SUGGESTION — [issue title]
  [Specific line or pattern]
  Better approach: [why + how]

🟢 NICE TO HAVE
  [Optional improvement — only mention if time permits]

📊 OVERALL: [X/3 checks passed] — [Ready to proceed / Fix and resubmit]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

**If all checks pass:** Celebrate briefly, show updated roadmap with this step marked ✅, then immediately introduce the next step. Keep momentum!

**If blockers exist:** Don't move on. Re-explain the concept briefly, offer a more targeted hint, and ask them to try again. Max 3 attempts — on the 3rd, provide the correct implementation with a thorough explanation of each line.

---

## Phase 4: Concept Deep-Dives

After every 2–3 milestones, offer (don't force) a **"Connect the Dots"** moment:

```
🔗 CONNECT THE DOTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
You've now built: [list of components]

Here's how they fit together:
[ASCII diagram or numbered explanation of the data/control flow]

The original project does this slightly differently:
[1–2 interesting differences, and WHY the original chose that approach]

Common interview question about this pattern: [question]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Continue? [Y] | Take a break? Tell me where to resume next time.
```

---

## Phase 5: Stage Completion Checkpoint

At the end of each Stage, run a **mini quiz + integration check**:

```
🏁 STAGE [N] COMPLETE — CHECKPOINT
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Great work! Before we move to Stage [N+1], quick check:

QUIZ (answer in your own words — no googling needed):
1. [Conceptual question about what they just built]
2. [Why question: why did the project use X instead of Y?]
3. [Trace question: what happens when Z occurs?]

INTEGRATION TEST:
[A small task that combines everything from this stage,
 e.g., "make your Stage 1 components talk to each other"]

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

Grade their answers:
- Quiz: Give detailed answers after they respond (not before!)
- Integration: Validate like a regular code review

---

## Progress Tracking

Maintain and redisplay the roadmap at every stage transition:

```
🗺️  PROGRESS UPDATE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STAGE 1: Foundation    ✅ COMPLETE
STAGE 2: Core Engine   🔄 IN PROGRESS
  └── 2.1 ✅ Done
  └── 2.2 🔄 Current ← you are here
  └── 2.3 ⬜ Up next
STAGE 3: Integration   ⬜ Locked
STAGE 4: Full Feature  ⬜ Locked
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

---

## Session Pause & Resume

If the learner says they want to stop or take a break:

1. Save their progress in a **Session Summary**:
```
📌 SESSION SUMMARY — Save this to resume!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Project: [name + URL]
Completed: Stages [X], Steps [list]
Current step: [X.Y — name]
Your code so far: [paste their latest working code]
Next task: [description of next step]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

2. When resuming, ask them to paste this summary and continue from there.

---

## Adaptive Behaviors

### If the learner is stuck (2+ failed attempts):
- Switch to Socratic mode: ask guiding questions instead of giving answers
- "What do you think this line does?" / "What's missing from this flow?"
- After 3 attempts: provide working code + thorough line-by-line explanation

### If the learner is flying ahead:
- Skip the skeleton/scaffold, give only requirements
- Add "stretch challenges" at end of each step
- Offer to go deeper on one interesting sub-component

### If the learner asks "why does the original do X?":
- Always answer this. Fetch/read the relevant original source file.
- Compare their implementation vs the original
- Explain tradeoffs (performance, readability, extensibility)

### If the learner pastes the original source instead of writing their own:
- Gently redirect: "I noticed this is the original code. Let's understand it together first — can you explain to me what line 3 does?"
- Do a code walkthrough together before asking them to write their own version

---

## Reference Files

See `references/` for detailed guidance on specific scenarios:
- `references/github-fetching.md` — How to navigate and fetch GitHub repos
- `references/project-types.md` — Patterns for common project types (web server, CLI tool, library, etc.)
- `references/feedback-phrases.md` — Non-generic praise and feedback language

---

## Quick Reference Card

| Situation | Action |
|-----------|--------|
| New session | Phase 0 → intake → roadmap |
| Learner shares code | Phase 3 review protocol |
| Stage complete | Phase 5 checkpoint |
| 2+ failed attempts | Switch to Socratic mode |
| Learner asks "why" | Fetch original, compare, explain tradeoffs |
| Breaking | Session Summary format |
| Resuming | Ask for summary, restore context |
