Understanding the Prerequisite Chain for Phases in AI Engineering from Scratch

The prerequisite chain for phases in AI Engineering from Scratch follows a strict linear progression through 19 cumulative phases, where each lesson declares its dependencies via YAML front-matter in phases/*/docs/en.md files and the CI pipeline enforces compliance through scripts/audit_lessons.py.

The rohitg00/ai-engineering-from-scratch repository structures machine learning education as a dependency-graph curriculum rather than a collection of standalone tutorials. Every phase builds upon the complete mastery of all earlier phases, creating a transitive closure of knowledge that culminates in production-ready capstone projects.

The 19-Phase Linear Architecture

The repository organizes content into numbered directories under the phases/ folder, forming an unbroken chain from mathematical foundations to advanced deployment. The sequence is:

Phase Directory Core Topic Position in Chain
01 01-math-foundations Linear algebra, probability, calculus Entry point — supplies mathematical language for all algorithms
02 02-ml-foundations Supervised learning, bias-variance tradeoff Builds on math foundations; required before neural networks
03 03-nlp-foundations-to-advanced NLP basics through advanced techniques Requires ML foundations for vectorizers and embeddings
04 04-computer-vision Convolutions, object detection, image processing Depends on math and ML foundations
05 05-nlp-foundations-to-advanced (continued) Dialogue state tracking, coreference Extends earlier NLP block using cumulative math/ML knowledge
06 06-speech-and-audio Audio signal processing, speech models Requires math and ML for time-series data
07 07-transformers-deep-dive Attention mechanisms, speculative decoding Needs solid ML and NLP grounding
08 08-generative-ai Diffusion models, autoregressive generation Builds on transformer knowledge and vision/audio work
09 09-reinforcement-learning Policy gradients, game AI Uses math, ML, and vision/audio for environments
10 10-llms-from-scratch Tokenizers, backpropagation, low-level implementation Cumulative synthesis of all previous phases
11 11-llm-engineering Prompt engineering, guardrails, caching Extends Phase 10's raw LLM implementation
12 12-multimodal-ai Joint text-image-audio models Combines vision, audio, and LLM skills
13 13-tools-and-protocols MCP, skill contracts, tool schemas Requires working LLM and multimodal pipelines
14 14-agent-engineering Autonomous agents, workbench protocols Draws on protocol layer and LLM capabilities
15 15-autonomous-systems Safety, risk assessment, societal impact Requires understanding of agents and protocols
16 16-multi-agent-and-swarms Coordination, consensus, swarm optimization Extends Phase 14's single-agent concepts
17 17-infrastructure-and-production Serving, scaling, observability Needs complete agent-centric stack for deployment
18 18-ethics-safety-alignment Dual-use risk, moderation, governance Integrates production systems with safeguards
19 19-capstone-projects End-to-end pipelines, RAG, safety gates Culmination — synthesizes all phases

How Prerequisites Are Defined in Lesson Metadata

Each lesson stores its dependency metadata in phases/[phase-number]-[name]/[lesson-number]-[title]/docs/en.md. The file contains YAML front-matter delimited by triple dashes, including a Prerequisites: field that lists comma-separated lesson slugs.

For example, a lesson in Phase 19 might declare:

---
Title: End-to-End Safety Gate
Prerequisites: 18-ethics-safety-alignment/01-dual-use-basics, 17-infrastructure-and-production/03-scaling-llms
---

This creates a directed acyclic graph where edges point backward through the curriculum. The chain is transitive: if Lesson C requires Lesson B, and Lesson B requires Lesson A, then Lesson C implicitly requires mastery of Lesson A.

Traversing the Prerequisite Chain Programmatically

The repository exposes the prerequisite structure through predictable file paths. You can extract the full dependency chain for any lesson by parsing the front-matter from docs/en.md files. The following Python script demonstrates how to traverse this chain recursively:


# utils/phase_prereqs.py

import pathlib
import re
import sys

def load_frontmatter(md_path: pathlib.Path) -> dict:
    """Extract YAML front-matter from a markdown file."""
    text = md_path.read_text()
    match = re.search(r"^---\n(.*?)\n---", text, re.DOTALL)
    if not match:
        return {}
    
    data = {}
    for line in match.group(1).splitlines():
        if ":" in line:
            key, value = line.split(":", 1)
            data[key.strip()] = value.strip()
    return data

def gather_prereqs(lesson_slug: str, base_dir: pathlib.Path) -> list:
    """Return ordered list of prerequisite lesson slugs using depth-first search."""
    visited = set()
    order = []

    def dfs(slug: str):
        if slug in visited:
            return
        visited.add(slug)
        
        md_file = base_dir / slug / "docs" / "en.md"
        if not md_file.exists():
            return
            
        front = load_frontmatter(md_file)
        prereqs = front.get("Prerequisites", "None")
        
        if prereqs != "None":
            for prereq in [x.strip() for x in prereqs.split(",")]:
                dfs(prereq)
        order.append(slug)

    dfs(lesson_slug)
    return order

if __name__ == "__main__":
    BASE = pathlib.Path(__file__).parent.parent / "phases"
    lesson = sys.argv[1]  # e.g., "19-capstone-projects/87-end-to-end-safety-gate"

    chain = gather_prereqs(lesson, BASE)
    print(" → ".join(chain))

Running this script against a capstone project reveals the complete linear chain:

$ python utils/phase_prereqs.py 19-capstone-projects/87-end-to-end-safety-gate
01-math-foundations/01-sets → 02-ml-foundations/01-intro-to-ml → ... → 19-capstone-projects/87-end-to-end-safety-gate

CI Validation and Enforcement

The repository prevents curriculum fragmentation through automated validation. The scripts/audit_lessons.py script runs in CI to verify that:

  1. Every lesson listed in Prerequisites: exists as a valid file path
  2. No lesson references a future phase (prevents forward dependencies)
  3. The transitive closure of prerequisites ultimately resolves to Phase 01

According to the repository's AGENTS.md policies, contributors must maintain the "one-commit-per-lesson" rule, ensuring that prerequisite chains remain atomic and traceable through git history.

Key Files Managing the Curriculum Structure

  • ROADMAP.md — Lists every phase in order and displays the high-level dependency graph for the entire curriculum
  • phases/*/docs/en.md — Contains per-lesson front-matter with the Prerequisites: field that defines the chain edges
  • scripts/audit_lessons.py — CI validator ensuring prerequisite integrity and preventing circular dependencies
  • learning-paths/*.json — Machine-readable representations of the curriculum used by the static site generator
  • AGENTS.md — Defines repository-wide policies including the strict linear progression requirement

Summary

  • The prerequisite chain for phases in AI Engineering from Scratch comprises 19 strictly sequential phases ranging from 01-math-foundations to 19-capstone-projects.
  • Dependencies are declared in YAML front-matter within each lesson's docs/en.md file using the Prerequisites: key.
  • The curriculum enforces a linear progression where each phase depends on the complete mastery of all preceding phases.
  • scripts/audit_lessons.py validates the dependency graph in CI, ensuring no forward references or missing prerequisites exist.
  • Programmatic access to the chain is possible by parsing the markdown front-matter from the phases/ directory structure.

Frequently Asked Questions

What happens if I try to skip a prerequisite phase?

Skipping phases violates the repository's dependency model and will result in missing foundational knowledge required for subsequent lessons. The scripts/audit_lessons.py validation script explicitly prevents contributors from creating lessons that skip required predecessors, ensuring the curriculum remains cumulative.

How does the repository validate prerequisite chains?

The scripts/audit_lessons.py CI script traverses the Prerequisites: fields in every phases/*/docs/en.md file to verify that all referenced slugs exist and that no lesson depends on a later phase number. This automated check runs on every pull request to maintain curriculum integrity.

Can I complete the phases in AI Engineering from Scratch out of order?

According to the repository structure and AGENTS.md policies, phases must be completed sequentially. While you could technically read files out of order, the Prerequisites: metadata and lesson content assume mastery of all earlier phases, making out-of-order learning ineffective for skill acquisition.

Where is the prerequisite metadata stored for each lesson?

Prerequisite metadata resides in the YAML front-matter of each lesson's documentation file at phases/[phase-dir]/[lesson-dir]/docs/en.md. The front-matter includes a Prerequisites: field containing comma-separated slugs of required preceding lessons, creating the dependency edges of the curriculum graph.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →