Learning Curriculum
Turns a real codebase into a numbered course: tool chapters first, then a day-by-day rebuild. The reader must be able to recreate the project without copying files, and leave with the habits (vertical slices, consumer-owned interfaces, context, cheapest fake) rather than a folder tour.
This is not reverse-architect (knowledge map) and not systems-analyst (observability gaps). Those explain a system. This skill teaches someone to build one.
Core Philosophy
"After reading, a newbie can rebuild the same project from an empty folder — and every file they write has a reason."
A tour of internal/ fails that test. A curriculum passes it.
Anti-patterns to avoid:
- A single "how the code works today" essay (the user will say: that's not how I'd build it)
- Generic tutorials that never cite this repo's types, paths, or tests
- Finishing one layer (all SQL, then all HTTP) instead of one vertical slice
- Trusting README / Copilot instructions over Makefile, OpenAPI
paths:, and tests - Hiding design flaws; "what not to copy" is part of the lesson
- Dumping entire source files into markdown
Put long templates in references/. Keep this file as the thinking process.
Thinking Process
When activated, follow these steps in order. If the user rejects the genre ("I wanted build order, not a tour"), go back to Step 1 — do not patch the wrong document.
Step 1: Lock Outcome and Audience
Goal: Know who reads this and what they can do when they finish.
Key Questions to Ask:
- Newbie rebuilding, or experienced engineer contributing? (This skill assumes newbie rebuild unless they say otherwise.)
- Which stack topics must be taught explicitly? (Gin, layers, Zap,
testing, mocks, OTel, SQL, DI, context — teach any the user named.) - Language of the docs: match the user's latest message; keep code identifiers in English.
Thinking Framework:
- "The exam is: empty folder, same product, tests green."
- "Mindset is the residue after they forget the file names."
Actions:
- Write one outcome sentence: "When they finish they can _____ and they will habitually _____."
- List required tool chapters from the user's request (do not invent a 20-chapter book).
- If they already have
learning/docs of the wrong genre, plan to replace or split — do not append a tour to a rebuild guide.
Decision Point: You can complete:
- "Audience is [newbie]; success is [rebuild + named habits]; tool chapters are [list]; rebuild is last."
Step 2: Ground in Executable Sources
Goal: Inventory the real system so every claim is verifiable.
Key Questions to Ask:
- What does Makefile / CI / Dockerfile actually run?
- Where is the HTTP contract (
openapi.ymlpaths:, proto, routes)? - Where is
main/ composition root? - Which tests exist at handler, service, and DB layers?
Thinking Framework:
- Docs and comments lie. Tests, generated interfaces, and compose files do not.
- Run
scripts/scan-repo.shfor a first pass; then read entry points, one handler, one service, one repo, one test of each kind.
Actions:
- Run the scan script on the project root (see Usage).
- Read composition root, consumer-owned interfaces, one request path, schema/migrations, mock tests.
- Note drifts (README path vs generated path, 404 vs 409) — they become "do not copy" callouts.
Decision Point: You can complete:
- "I trust [Makefile/OpenAPI/tests] over [README/copilot-instructions] because [concrete mismatch]."
Step 3: Extract Seams the Curriculum Must Teach
Goal: Name the boundaries a rebuilder must reproduce, not every function.
Key Questions to Ask:
- Who owns each interface — the caller or the implementer?
- Where is DI? (constructors in
main, no framework, tests inject mocks) - How does
context.Contexttravel? (c.Request.Context()→ service →*ContextSQL) - How is SQL shaped? (wide row vs mapping table, JSONB vs arrays, indexes vs queries)
- What is the cheapest fake per layer? (httptest mock, function-field mock, sqlmock, E2E last)
Thinking Framework:
| Seam | Newbie must be able to say |
|------|----------------------------|
| Layers | Handler may not SQL; service may not import Gin |
| DI | main news concretes; tests pass fakes into the same New* |
| Context | Request ctx downward; Background() only at process start |
| SQL | One query ↔ one product question; parameterized *Context |
| Tests | Prove the rule at the cheapest layer that can fail |
Actions:
- Fill the seam table from real types (
CaseServicein handler,CaseRepositoryin service, etc.). - Trace one request (create/get) across all seams — that becomes the first rebuild slice.
- List domain rules a clone must hit or it is a different product (duplicate key, 409, TTL, auth header).
Decision Point: You can complete:
- "If they skip [seam], they will [specific failure in tests or production]."
Step 4: Design the Curriculum Map
Goal: Order files so tools are learned before they are required in the rebuild.
Thinking Framework — File order:
learning/README.md path + outcome
00-mindset.md habits (pain, slices, caller-owned interface, ctx)
01-… tool chapters one concern each (layers, SQL/DI/ctx, framework, logs, tests, otel)
NN-rebuild.md last: vertical slices that *use* the tools
Key Questions to Ask:
- Does each tool chapter answer: pain, how this repo does it, what not to do, one exercise?
- Does rebuild say "learn first: chapter X" before a phase that needs X?
- Can they stop after slice 1 (health + one POST) and still have a running process?
Actions:
- Optionally run
scripts/scaffold-curriculum.shto create stubs (see Usage). - Keep README to a table of files and the exam (rebuild, don't peek).
- Number tool chapters so rebuild can stay last even if you insert
01a.
Decision Point: You can point at a README table and say:
- "Chapters 0–K are tools; chapter N is when they use them in order."
Step 5: Write Tool Chapters (Pain → This Repo → Exercise)
Goal: Each tool file teaches a mechanism using this codebase's names.
Structure for every tool chapter:
- Pain — one sentence, no library name.
- How this repo does it — real types, file paths, short snippets (not whole files).
- What not to do — including flaws in this repo (e.g. service importing handler errors).
- Exercise — they must produce or point at something without memorizing the tree.
Actions:
- Write mindset first (vertical slice, caller-owned interface, ctx first param, composition root, cheapest fake).
- Write named topics the user asked for (framework, layers, logger,
testing+ mocks, OTel, SQL, DI, context). Combine SQL+DI+context if they share one request picture. - Cite
pathorpath:linefor hops.
Decision Point: A reader can explain the chapter out loud without opening the file.
Step 6: Write the Rebuild Playbook (Vertical Slices)
Goal: Day-by-day construction order. Interface methods are added per slice, not on day one.
Thinking Framework — one slice:
contract (OpenAPI/proto) → generate
→ add 1 method to the *caller* interface
→ repo + sqlmock
→ service + mock repo
→ handler + mock service
→ pass request ctx
→ go test green
→ next API
Phase order that usually works for an HTTP+DB service:
A skeleton (health, config, logger, no DB) → B contract for one path → C two tiny interfaces → D connection + minimum schema → E first write path → F deepen same path (duplicates, etc.) → G reads → H domain graph (state machine) → I remaining field updates one-by-one → J list/delete → K versioned API → L side concerns (archive/S3) → M metrics/OTel → N E2E/CI last.
Actions:
- Map this repo's real APIs onto that sequence.
- Each phase: files to create, checklist, "learn first" link to a tool chapter.
- State the repo is the answer key — peek after 20 minutes stuck or after tests are green.
- End with "differences that are fine" vs "differences that mean you drifted."
Decision Point: Slice 1 has a test at three layers. Later slices only add interface methods they need.
Step 7: Honest Gaps and Iteration
Goal: Teach judgment, not worship.
Actions:
- Include a copy / don't-copy table (inverted deps, missing SQL spans, stale docs).
- If the user says the docs are the wrong kind, rewrite the genre (rebuild vs tour) instead of adding sections.
- Keep
learning/README.mdas the only index.
Decision Point: A senior would agree the "don't copy" list is real, not generic advice.
Usage
# Inventory the repo (JSON on stdout; status on stderr)
bash /mnt/skills/user/learning-curriculum/scripts/scan-repo.sh [project-root]
# Create learning/ stubs
bash /mnt/skills/user/learning-curriculum/scripts/scaffold-curriculum.sh --out learning --topics mindset,layers,rebuild
Arguments (scan-repo.sh):
project-root— directory to scan (default.)
Arguments (scaffold-curriculum.sh):
--out— directory to write (defaultlearning)--topics— comma-separated stub names, ordered (default see script)
Examples:
bash /mnt/skills/user/learning-curriculum/scripts/scan-repo.sh .
bash /mnt/skills/user/learning-curriculum/scripts/scaffold-curriculum.sh --out learning --topics mindset,layers,gin,zap,testing,otel,rebuild
Read references/curriculum-template.md when filling stubs. Read references/anti-patterns.md before the first draft.
Output
A learning/ tree, for example:
learning/README.md
learning/00-mindset.md
learning/01-layered-architecture.md
learning/01a-sql-di-context.md
learning/02-gin.md
learning/03-zap.md
learning/04-testing-and-mocks.md
learning/05-otel.md
learning/06-rebuild.md
Each tool file: pain, this-repo mechanism, mistakes, exercise. Rebuild file: phases with checklists. README: numbered path + exam.
Present Results to User
- Point at
learning/README.mdas the start. - One sentence: exam = rebuild, repo = answer key.
- List tool chapters vs rebuild chapter.
- Do not paste the curriculum into chat.
Always end with:
"Read 0–N for tools, then the rebuild. Peek at the repo only after a slice's tests are green (or after 20 minutes stuck)."
Troubleshooting
"The user wanted a tour of the current code."
- Wrong skill. Use reverse-architect or systems-analyst. This skill's first draft of a tour will be rejected.
"They asked in Chinese / English."
- Write prose in that language. Keep identifiers (
CreateCase,ExecContext) in English.
"SKILL.md is not enough to cover SQL, DI, and ctx."
- One combined tool chapter with three sections sharing a single request picture is better than three disconnected essays.
"Rebuild chapter is repeating the tool chapters."
- Rebuild should only sequence work and say "learn first: 04-testing". Mechanisms stay in tool files.
"No OpenAPI / no Gin."
- Same process. Substitute the real contract and framework. Do not invent Gin lessons for a CLI.