What Is the Build It / Use It Methodology in AI Engineering From Scratch?

The Build It / Use It methodology is a two-phase pedagogical strategy where learners first implement AI algorithms from raw mathematics using only standard libraries, then refactor identical logic to run through production frameworks—revealing exactly what the abstraction layer conceals.

The Build It / Use It methodology forms the pedagogical spine of the rohitg00/ai-engineering-from-scratch curriculum, a comprehensive 503-lesson program designed to transform beginners into expert AI engineers. Anchored within a strict six-beat lesson structure, this approach ensures students understand the mechanics beneath every API call they make, from linear regression to multimodal agent orchestration.

The Six-Beat Architecture Behind the Curriculum

Every lesson in the repository follows an immutable pattern: MOTTO → PROBLEM → CONCEPT → BUILD IT → USE IT → SHIP IT. According to the curriculum's top-level README.md, the third and fourth beats—Build It and Use It—constitute the core learning mechanism that differentiates this course from framework-centric tutorials. This rigid structure guarantees that abstraction is earned, not assumed.

Build It Phase: Implementing From First Principles

The Build It phase requires learners to write algorithms using nothing beyond standard Python and NumPy-style operations. This forces engagement with the underlying linear algebra, calculus, and control flow that production libraries normally obscure.

In phases/14-agent-engineering/01-the-agent-loop/code/main.py, this principle manifests as a complete ReAct agent loop implemented without external AI libraries. Students must manually parse token streams, manage the tool registry, and enforce turn budgets to prevent infinite loops.

Example: Hand-Coding a Toy ReAct Loop

The following implementation from Phase 14 demonstrates a deterministic ToyLLM class that emits Thought/Action/Observation tokens, paired with a hand-rolled parser for the "Action: name(args)" format:


# File: phases/14-agent-engineering/01-the-agent-loop/code/main.py

class ToyLLM:
    """Deterministic toy LLM that emits Thought/Action/Observation tokens."""
    def __call__(self, history):
        last = history[-1]
        if "capital of France" in last:
            return "Thought: I need to look that up.\nAction: search('capital of France')"
        if "search" in last:
            return "Observation: Paris is the capital of France.\nThought: The answer is Paris.\nAction: finish('Paris')"
        return "Finish: I have nothing to do."

tools = {
    "search": lambda query: "Paris is the capital of France.",
    "finish": lambda ans: ans,
}

def run_agent():
    llm = ToyLLM()
    history = ["User: What is the capital of France?"]
    for turn in range(5):  # Turn budget prevents infinite loops

        response = llm(history)
        if "Action:" in response:
            name, args = response.split("Action: ")[1].split("(")
            args = args.rstrip(")")
            result = tools[name](args.strip("'\""))
            history.append(f"Tool ({name}): {result}")
        else:
            print("🔚 Final answer:", response)
            break

run_agent()

Running this script produces a complete ReAct trace, proving that the student comprehends the message buffer mechanics and tool-calling protocol before introducing network latency or API failures.

Use It Phase: Abstracting to Production Frameworks

The Use It phase demands the exact same logic operate through a production-grade library. Because the student already owns the low-level implementation, they can map every library method to its manual equivalent, identifying what the framework handles for them—whether that is automatic differentiation in PyTorch, tensor sharding in JAX, or the Model-Context-Protocol (MCP) in agent engineering.

Swapping to the MCP Client

In phases/14-agent-engineering/01-the-agent-loop/code/main_mcp.py, the curriculum demonstrates this transition by replacing the ToyLLM instantiation with a real MCPClient. The surrounding logic—history management, tool registry structure, and turn budget enforcement—remains identical:


# File: phases/14-agent-engineering/01-the-agent-loop/code/main_mcp.py

from mcp_client import MCPClient

client = MCPClient(endpoint="https://mcp.example.com")
tools = {
    "search": lambda q: client.search(q),   # Real remote call

    "finish": lambda ans: client.finish(ans),
}

# Agent loop logic remains unchanged from main.py

This single-line substitution reveals that the MCP client abstracts network I/O, authentication, and response streaming while preserving the same ReAct protocol the student coded manually.

Why the Build It / Use It Split Matters

By first building the component, students develop intuition for why libraries enforce specific constraints—such as fixed tensor shapes or timeout budgets. When they later use the production framework, they possess the mental model to debug mismatches between expected and actual behavior, safely extend functionality, and reason about performance bottlenecks or security vulnerabilities that pure abstraction would hide.

This methodology repeats across all 503 lessons, from hand-coded linear regression to multimodal agent orchestration, ensuring graduates can operate at the intersection of research and production engineering.

Summary

  • The Build It / Use It methodology enforces a two-phase learning cycle: raw implementation followed by framework integration.
  • Phase one occurs in main.py files where students write algorithms using only standard libraries to understand underlying mechanics.
  • Phase two occurs in main_mcp.py (or equivalent) where identical logic is refactored to use production tools like PyTorch, JAX, or MCP clients.
  • This split enables developers to debug library internals, reason about abstraction costs, and safely extend production code according to the rohitg00/ai-engineering-from-scratch source code.

Frequently Asked Questions

Does the Build It phase require writing everything from scratch without any imports?

No. The Build It phase restricts high-level AI frameworks like PyTorch or Transformers, but permits standard libraries and NumPy for matrix operations. The constraint forces engagement with algorithmic logic—such as manually computing attention scores or gradient updates—rather than boilerplate networking code.

How does the Use It phase differ from standard tutorial-based learning?

Standard tutorials typically start with framework APIs, creating a dependency on abstraction layers the learner does not understand. The Use It phase occurs only after the student has implemented identical functionality manually, allowing them to map library methods to their low-level equivalents and spot deviations immediately.

Which lessons in the curriculum use the Build It / Use It methodology?

All 503 lessons follow this pattern, from early linear algebra exercises in Phase 2 through advanced agent engineering in Phase 14. The phases/14-agent-engineering/01-the-agent-loop/docs/en.md file explicitly documents this split for the ReAct loop implementation.

Can I apply this methodology to learning other technical domains outside AI?

Yes. The Build It / Use It approach generalizes to any domain where abstraction hides complexity—such as database engines, compilers, or distributed systems. The principle remains constant: implement the protocol manually, then refactor to use the library, ensuring you understand what the abstraction conceals.

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 →