AI Deck

Mastra Code — An open-source terminal coding agent from Mastra AI that keeps context without compaction

Released in February 2026 by Mastra AI, known for its TypeScript AI agent framework, Mastra Code is a coding agent that runs in your terminal. It is distributed as open source under Apache 2.0 and can be started right away with npm install -g mastracode or npx mastracode. Its defining feature is a mechanism called “Observational Memory,” which preserves context without forcing conversation compaction. Even during long working sessions, the agent is less likely to lose track of decisions made earlier, which makes it well suited to sustained development work.

Key Features

  • Persistent context through Observational Memory: The agent watches the conversation, accumulates key points as “observations,” and reflects on them to compress context. This avoids the forced compaction that typically happens when a coding agent hits its context limit, along with the information loss that comes with it
  • Three modes: Build, Plan, and Fast: Use Plan mode to investigate existing code and draft an implementation plan, Build mode to actually carry it out, and Fast mode for low-latency answers and small edits ─ switching according to the granularity of the work
  • Project-scoped persistent threads: Conversation threads are stored per project, so you can pick up where you left off even across days
  • A model router connecting to many models: You can use models from many providers including Anthropic, OpenAI, and Google, and even switch models mid-conversation to compare answers. In addition to API keys, it supports authentication through existing subscriptions such as Claude Max and ChatGPT Plus
  • Tools for files, shell, and web search: Viewing, editing, and searching files, running shell commands, web search, and Git operations can all be delegated to the agent
  • MCP server support and extensibility: You can extend functionality by connecting Model Context Protocol (MCP) servers, and because it is built on the Mastra framework, custom tools, subagents, and storage can be added programmatically

Pricing

PlanPriceWhat it covers
Mastra Code itselfFree (open source, Apache 2.0)All features of the terminal agent. No payment to Mastra
LLM usageActual cost to each providerUse your own API keys, or existing subscriptions such as Claude Max / ChatGPT Plus
Mastra Cloud (separate service)Starter free, Teams $250/month, Enterprise on requestHosting, observability, and operations for agents. Not required to use Mastra Code

Pricing is as of August 2026. Check the official site for the latest rates.

Pros & Cons

Pros

  • Context loss from compaction is less likely, so direction stays consistent even in long, large sessions
  • Open source under Apache 2.0, with no charge for the tool itself
  • You are not locked into one model; choose from many providers based on task and cost
  • Separating Plan, Build, and Fast lets you deliberately split investigation from implementation
  • MCP support and the underlying framework make it easy to extend for your own environment

⚠️ Cons

  • As a terminal-first CUI tool, there is an initial hurdle for people who work mainly in GUI editors
  • Requires Node.js 22.13.0 or later, so the runtime environment must be prepared
  • LLM usage is paid by you, so API charges can grow depending on how you use it
  • Released in February 2026, it is still young, with fewer accumulated resources and case studies than more mature competitors
  • Observational Memory itself consumes model calls, so the memory processing also carries a cost

Comparison with Similar Services

CriteriaMastra CodeClaude CodeOpenCodeGemini CLI
ProviderMastra AIAnthropicOpenCodeGoogle
Form factorTerminalTerminalTerminalTerminal
LicenseOpen source (Apache 2.0)ProprietaryOpen sourceOpen source
Model choiceMany providersClaude familyMultiple providersGemini family
Context managementObservational Memory (no compaction)Automatic compactionAutomatic compactionAutomatic compaction
CostTool free, LLM at costSubscription or API usageTool free, LLM at costFree tier available

Who Is It For

  • Developers who want the agent to hold context through long refactors or large investigations
  • People who would rather pick a model per task than be tied to a single vendor
  • Those who value open source and want to read or modify the internals when needed
  • Anyone who wants to combine MCP servers and custom tools into their own agent environment
  • Teams already building agents with the Mastra framework who want a tool with the same design philosophy at hand

Summary

Mastra Code takes on a weakness often pointed out in terminal coding agents ─ losing context to compression ─ with a design called Observational Memory. The tool itself is free and open source under Apache 2.0, and because you choose your own model, cost visibility stays in your hands. It is still new with few published case studies, but if losing context during long sessions is a pain point for you, it is worth trying with npx mastracode.

← Blog