How the AI Engineering From Scratch Curriculum Manages Prerequisites Between Phases
The curriculum uses a three-layer system: explicit front‑matter in every lesson, a visual phase dependency graph in the README, and automated CI validation that blocks builds with broken dependencies.
The AI Engineering From Scratch repository by rohitg00 implements a self‑documenting, machine‑enforced prerequisite chain across 20 learning phases. This ensures learners never encounter a lesson requiring knowledge they haven't acquired, while maintainers receive immediate feedback when dependencies break.
Explicit Front‑Matter in Every Lesson
Each lesson file contains a human‑readable Prerequisites declaration at the top of its docs/en.md.
In phases/19-capstone-projects/87-end-to-end-safety-gate/docs/en.md, the front‑matter states:
**Prerequisites:** Phase 18 safety lessons, Phase 19 Track A lessons 25-29
This pattern repeats across all 20 phases, creating a granular dependency network that links individual lessons to specific prior phases and even specific lesson ranges.
You can extract these programmatically using Python:
import pathlib
import re
def get_prereqs(lesson_path: pathlib.Path) -> list[str]:
"""Return the list of prerequisite strings from a lesson's en.md."""
text = lesson_path.read_text()
match = re.search(r"\*\*Prerequisites:\*\*\s*(.+)", text)
return [p.strip() for p in match.group(1).split(",")] if match else []
# Usage:
lesson = pathlib.Path(
"phases/19-capstone-projects/87-end-to-end-safety-gate/docs/en.md"
)
print(get_prereqs(lesson))
# → ['Phase 18 safety lessons', 'Phase 19 Track A lessons 25-29']
Visual Phase Dependency Graph
The top‑level README.md encodes the global curriculum structure as a Mermaid diagram spanning lines 57‑80. This visual maps the progression from "Setup & Tooling" (Phase 0) through "Capstone Projects" (Phase 19), with explicit arrows showing cross‑phase dependencies like Phase 10 → Phase 11 and Phase 14 → Phase 15.
The diagram serves two purposes: it gives learners an at‑a‑glance understanding of the learning path, and it mirrors the formal prerequisite relationships defined in individual lesson files.
Automated CI Validation
The scripts/audit_lessons.py script enforces dependency integrity on every push and pull request via the .github/workflows/curriculum.yml workflow.
The audit performs three critical checks:
- Parses every
docs/en.mdfile for prerequisite front‑matter - Resolves each prerequisite against the actual filesystem to detect dangling references
- Fails the build immediately upon detecting missing or circular dependencies
A simplified validation implementation:
import pathlib, json, sys
def collect_all_lessons(root: pathlib.Path) -> set[str]:
"""Set of strings like 'Phase 19-Track-A-25' for every lesson."""
lessons = set()
for doc in root.glob("phases/**/docs/en.md"):
phase = doc.parts[1] # e.g. '19-capstone-projects'
lesson = doc.parent.name # folder name of the lesson
lessons.add(f"{phase}-{lesson}")
return lessons
def validate_prereqs(root: pathlib.Path):
all_lessons = collect_all_lessons(root)
for doc in root.glob("phases/**/docs/en.md"):
prereqs = get_prereqs(doc)
for p in prereqs:
if not any(p in l for l in all_lessons):
print(f"Missing prerequisite in {doc}: {p}", file=sys.stderr)
sys.exit(1)
# Run as part of CI:
validate_prereqs(pathlib.Path("."))
This guarantees the repository never ships with broken prerequisite chains.
Learner Placement via Find‑Your‑Level Skill
The curriculum includes a .claude/skills/find-your-level/SKILL.md tool that respects the same prerequisite metadata. When learners run the placement skill, it interrogates the prerequisite graph to recommend the earliest phase they can safely enter based on their existing knowledge.
curl -X POST https://api.claude.ai/v1/skills/find-your-level \
-d '{"answers": {"knowledge": "I know linear algebra and basic Python"}}'
# → Returns JSON with recommended phase e.g. { "startPhase": "Phase 2 – ML Fundamentals" }
This prevents learners from jumping ahead into phases requiring foundational concepts they haven't studied.
Key Files in the Prerequisite System
| File | Purpose |
|---|---|
README.md |
Mermaid diagram showing global phase ordering |
phases/**/docs/en.md |
Per‑lesson prerequisite front‑matter |
scripts/audit_lessons.py |
CI validation of dependency integrity |
.github/workflows/curriculum.yml |
GitHub Action triggering prerequisite audits |
.claude/skills/find-your-level/SKILL.md |
Learner placement respecting prerequisite chains |
Summary
- Front‑matter metadata in every lesson makes dependencies human‑readable and machine‑parseable
- Visual dependency graph in
README.mdprovides curriculum‑wide orientation - CI automation in
scripts/audit_lessons.pyblocks broken prerequisites before they reach learners - Placement skill uses the same metadata to personalize starting points without violating dependency rules
Frequently Asked Questions
How does the curriculum prevent circular dependencies between phases?
The scripts/audit_lessons.py CI script explicitly detects circular prerequisite chains during the automated audit. When circular references are found, the build fails with an error message identifying the cycle, forcing maintainers to resolve the conflict before merging.
Can learners skip phases if they already know the material?
The Find‑Your‑Level skill analyzes prerequisite metadata to determine the earliest phase a learner can safely enter. Rather than allowing arbitrary skipping, it validates existing knowledge against formal dependencies and recommends a starting point that preserves curricular integrity.
What happens if a prerequisite lesson is deleted or renamed?
The CI validation catches dangling prerequisites immediately. When audit_lessons.py cannot resolve a prerequisite string to an existing lesson file, it prints the missing reference to stderr and exits with code 1, blocking the pull request until the dependency is updated or restored.
Where are the prerequisite rules actually defined?
Prerequisites are defined in three synchronized locations: the **Prerequisites:** line in each lesson's docs/en.md file, the Mermaid diagram in README.md showing phase ordering, and the validation logic in scripts/audit_lessons.py that enforces consistency between these sources.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →