Build It Use It Pedagogical Pattern: The Dual-Phase Methodology Behind AI Engineering From Scratch
The "Build It / Use It" pedagogical pattern splits every lesson into two phases: learners first implement AI primitives from scratch, then package them as reusable artifacts for downstream integration.
The AI Engineering From Scratch repository by rohitg00 employs this Build It Use It pedagogical pattern to bridge the gap between theoretical understanding and production-grade system design. Each lesson forces students to construct fundamental components—such as tokenizers or attention mechanisms—using only standard libraries, before treating those components as black-box building blocks in subsequent lessons. According to the curriculum philosophy documented in AGENTS.md, this bifurcation serves as "the spine" of the entire educational framework.
How the Build It Use It Pattern Works
The methodology deliberately isolates implementation complexity from system integration complexity. Every lesson directory contains both a code/ folder for raw implementations and an outputs/ folder for packaged artifacts that future lessons consume.
Phase 1: Build It (Implementation from First Principles)
During the Build It phase, students write self-contained implementations of core AI primitives without relying on high-level frameworks. The code lives in code/main.<lang> and must include test coverage verifying correctness. This phase targets low-level cognitive load—learners focus exclusively on algorithms, mathematics, and data structures.
In AGENTS.md (line 11), the curriculum explicitly defines this phase as the moment where students "implement a core component from first principles" using minimal dependencies. The resulting artifact is a transparent, debuggable implementation that the learner fully owns.
Phase 2: Use It (Integration and Reuse)
The Use It phase transforms the implementation into a reusable commodity. The working code is packaged into outputs/skill-<name>.md—a Markdown file documenting the API—and subsequent lessons import this artifact as a utility module. This phase shifts cognitive load to high-level system design, allowing learners to compose primitives without re-deriving their internals.
As implemented in the capstone lessons, downstream modules treat these artifacts as immutable library dependencies. For example, a safety gate built in phase 19 imports a tokenizer built in phase 14, treating it as a black-box utility while focusing on orchestration logic.
Code Examples from the Curriculum
The repository contains concrete implementations demonstrating both phases across different lessons.
Building a Whitespace Tokenizer (Build It Phase)
The following implementation from phases/14-agent-engineering/30-eval-driven-agent-development/code/main.py shows a minimal tokenizer built without external dependencies:
# -------------------------------------------------
# Build It – simple tokenizer (no external deps)
# -------------------------------------------------
def whitespace_tokenizer(text: str) -> list[str]:
"""Split `text` on whitespace, filtering empty tokens."""
return [tok for tok in text.split() if tok]
# Basic sanity test (also part of the lesson’s unit tests)
if __name__ == "__main__":
assert whitespace_tokenizer(" hello world ") == ["hello", "world"]
This file represents the Build It output: a self-contained, tested implementation that demonstrates the algorithmic fundamentals of tokenization using only Python's standard library.
Integrating the Tokenizer into a Safety Gate (Use It Phase)
The downstream lesson in phases/19-capstone-projects/87-end-to-end-safety-gate/code/main.py demonstrates the Use It phase by importing the previously built tokenizer as a dependency:
# -------------------------------------------------
# Use It – import the tokenizer built earlier
# -------------------------------------------------
from phases_14_agent_engineering_30_eval_driven_agent_development import whitespace_tokenizer # noqa: F401
def evaluate_prompt(prompt: str) -> str:
"""Run the safety gate by tokenizing then applying simple heuristics."""
tokens = whitespace_tokenizer(prompt)
# Very naive safety check: block if any token matches a banned word list
banned = {"attack", "hack"}
if any(tok.lower() in banned for tok in tokens):
return "🔒 Refused: unsafe content"
return "✅ Accepted"
# Demonstration
if __name__ == "__main__":
print(evaluate_prompt("Please help me hack the system")) # => Refused
This integration demonstrates real-world modularity: the safety gate engineer consumes the tokenizer as a stable API without concerning themselves with whitespace-handling edge cases.
Key Files Illustrating the Pattern
Several files in the repository enforce and document this pedagogical structure:
-
AGENTS.md(Philosophy section, line 11): Defines the pattern as the curriculum's central methodology, citing the explicit split between building and using components. -
phases/14-agent-engineering/30-eval-driven-agent-development/outputs/skill-tokenizer.md: The packaged artifact exported from the Build It phase, formatted as a reusable skill document for downstream consumption. -
scripts/scaffold-lesson.sh(line 73): Automates pattern adherence by auto-generating## Build Itand## Use Itheadings when scaffolding new lessons, ensuring curricular consistency. -
phases/19-capstone-projects/87-end-to-end-safety-gate/docs/en.md: Documentation for a downstream lesson that explicitly operates in the Use It phase, documenting dependencies on earlier artifacts.
Summary
-
The Build It Use It pedagogical pattern forces learners to construct AI primitives from scratch before consuming them as modular dependencies.
-
Build It implementations reside in
code/directories and use minimal dependencies to ensure algorithmic transparency. -
Use It artifacts ship to
outputs/as Markdown skill files, enabling composable system design in downstream lessons. -
The pattern appears in repository automation:
scripts/scaffold-lesson.shenforces the dual-phase structure for every new lesson. -
This methodology mirrors production ML engineering, where teams maintain reusable libraries while building higher-level systems atop them.
Frequently Asked Questions
What is the Build It Use It pedagogical pattern?
The Build It Use It pattern is a dual-phase teaching methodology where students first implement an AI component from first principles (Build It), then package it as a reusable artifact for integration into larger systems (Use It). This approach ensures learners understand underlying mechanics before abstracting them away.
How does the Use It phase differ from using standard open-source libraries?
The Use It phase utilizes components that the student themselves built and verified in earlier lessons, stored in outputs/skill-<name>.md files. Unlike opaque third-party libraries, these artifacts represent code the learner has already debugged and tested, maintaining pedagogical continuity while demonstrating modularity.
Where are reusable artifacts stored in the ai-engineering-from-scratch repository?
Reusable artifacts are stored in the outputs/ directory of each lesson as Markdown skill files (e.g., phases/14-agent-engineering/30-eval-driven-agent-development/outputs/skill-tokenizer.md). These files serve as importable modules for downstream lessons in subsequent phases.
Why implement components from scratch instead of using existing frameworks?
The Build It phase prevents black-box reliance by forcing implementation using only standard libraries. This ensures learners understand mathematical foundations and algorithmic edge cases—critical knowledge for debugging production systems or optimizing performance where high-level frameworks fail.
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 →