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:

#TopicWhat It Covers
1IntroKey components overview
2The HarnessStateful, resumable execution architecture
3Prompts & ContextDynamic system prompt composition (env, mode, tools, tasks, skills)
4WorkspaceSkills, filesystem sandboxing, purpose-built tools vs bash
5MemoryContext growth, compaction, observational memory
6ModesPLAN, BUILD, FAST, REVIEW, TRIAGE, CUSTOM — rewiring agent behavior
7SteeringHuman-in-the-loop: interrupts, abort, free-form input
8ProtocolsEvent system, MCP, SubAgents
9StreamingMulti-model streaming, interrupt handling, provider routing
10PoliciesTool permission matrix, YOLO mode, cost tracking
11ChecklistProduction-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
ExampleRunDescription
basic.tsnpx tsx basic.tsHand-built Harness with subagents (researcher + poet), memory, and event subscriptions
basic-tui.tsnpx tsx basic-tui.tsSame hand-built Harness wired into MastraTUI for an interactive terminal UI
mc.tsnpx tsx mc.tscreateMastraCode() factory — modes, tool grants, MCP manager
tui.tsnpx tsx tui.tsFull 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