Build Your Own Claude Code
February 19, 2026 · View on GitHub
A hands-on workshop by Abhi Aiyer (Founder/CTO, Mastra) and Tyler Barnes (Founding Engineer, Mastra) covering the architecture behind MastraCode — an open-source AI coding agent you can run, extend, and make your own.
What You'll Learn
The workshop dissects every layer that makes MastraCode work, from the execution harness to cost tracking:
| # | Topic | What It Covers |
|---|---|---|
| 1 | Intro | Key components overview |
| 2 | The Harness | Stateful, resumable execution architecture |
| 3 | Prompts & Context | Dynamic system prompt composition (env, mode, tools, tasks, skills) |
| 4 | Workspace | Skills, filesystem sandboxing, purpose-built tools vs bash |
| 5 | Memory | Context growth, compaction, observational memory |
| 6 | Modes | PLAN, BUILD, FAST, REVIEW, TRIAGE, CUSTOM — rewiring agent behavior |
| 7 | Steering | Human-in-the-loop: interrupts, abort, free-form input |
| 8 | Protocols | Event system, MCP, SubAgents |
| 9 | Streaming | Multi-model streaming, interrupt handling, provider routing |
| 10 | Policies | Tool permission matrix, YOLO mode, cost tracking |
| 11 | Checklist | Production-readiness criteria |
Slides
Open slides/index.html in a browser. Navigate with arrow keys or the top nav bar.
Examples
The examples/ directory contains runnable TypeScript examples that progressively build up from a raw harness to a full TUI:
cd examples
pnpm install
| Example | Run | Description |
|---|---|---|
basic.ts | npx tsx basic.ts | Hand-built Harness with subagents (researcher + poet), memory, and event subscriptions |
basic-tui.ts | npx tsx basic-tui.ts | Same hand-built Harness wired into MastraTUI for an interactive terminal UI |
mc.ts | npx tsx mc.ts | createMastraCode() factory — modes, tool grants, MCP manager |
tui.ts | npx tsx tui.ts | Full MastraCode TUI in ~14 lines |
MastraCode
MastraCode is a coding agent built on the Mastra Harness. It ships with modes, memory, streaming, tool policies, subagents, observational memory, and a terminal UI — everything covered in this workshop. During the live session, MastraCode was used to work on its own codebase as the final demo.
npm i -g mastracode
mastracode # in the dir you want to work in
Source Code
- MastraCode — the full CLI agent
- Harness — the core execution engine in
@mastra/core