AI harnesses are the software layer that turns a language model into a working agent. Mastra Code is Mastra’s terminal coding agent harness: built on the open-source Mastra framework, with Observational Memory instead of classic context compaction, and access to a broad model selection through a central model router. As of 20 September 2026.
What is Mastra Code?
Mastra Code is developed by the team behind Mastra, the TypeScript framework for AI applications and agents (the legal vendor, per its Terms of Service, is Kepler Software, Inc.). Its source code lives in the mastra-ai/mastra monorepo, under the mastracode directory; outside the separately licensed ee/ directories, the repository is licensed under Apache-2.0 according to its own licence file. Mastra Code is installed via npm install -g mastracode or run directly with npx mastracode; running mastracode in a project directory starts an onboarding wizard that configures model providers and modes for the first run. Node.js 22.19.0 or later is a documented prerequisite.
Mastra Code as an AI harness
The architecture has four layers: a terminal interface, the AgentController for mode management, thread persistence and the event flow, the underlying Mastra agent layer for model selection and tool execution, and a LibSQL storage layer for history and Observational Memory. Three modes - Build, Plan and Fast - match depth and response time to the task at hand. File and shell tools can be extended via MCP servers (/mcp), and programmatically via custom tools and subagents; on top of that, skills in SKILL.md files, which Mastra Code reads, per the documentation, from locations including .claude/skills/ and .agents/skills/ - making it compatible with Claude Code and the open Agent Skills standard. Mastra Code reads project instructions from AGENTS.md or CLAUDE.md. For multi-step tasks, /goal pursues an objective until a separate judge model reports the status “done”, “continue” or “waiting”; /subagents shows a model picker for the built-in subagents.
Models and model access
Mastra Code uses the Mastra Model Router, which automatically routes requests to the right provider based on the model ID and available credentials. For Mastra Code itself, code.mastra.ai documents native API-key or subscription-based access to Anthropic (Claude Max), OpenAI (ChatGPT Plus/Codex), Google Gemini, DeepSeek, Cerebras and Kimi For Coding; through the underlying Model Router, a much larger number of further providers is reachable in principle, per mastra.ai/models. For a custom endpoint, /custom-providers lets you enter a name, base URL, optional API key and model IDs for an OpenAI-compatible provider. Model access can therefore generally be routed through a central proxy such as our AI Gateway by registering its endpoint as a custom provider.
Enterprise use: data protection and governance
Per the documentation, Mastra Code collects anonymous product analytics by default - operating system, version numbers, CPU architecture, a hostname-derived ID, and usage of sessions, prompts and slash commands - though prompt text, message content, file paths and tool inputs are explicitly not collected, per the documentation; this can be disabled via the MASTRA_TELEMETRY_DISABLED=1 environment variable. Threads, messages, token usage and Observational Memory stay local by default, per the product announcement in SQLite and, per the configuration documentation, technically via a local LibSQL file, and are not transmitted automatically; for teams, the documentation additionally describes remote LibSQL (Turso) and PostgreSQL backends. The four permission categories - read, edit, execute and MCP - can be set via /settings or programmatically; a central enterprise SSO for Mastra Code itself is not documented. What stays constant: once a cloud model provider or provider subscription is used, source code and prompts go to that provider - this belongs in your records of processing activities in advance.
Orchestrating Mastra Code with herdr
herdr supervises several coding agents at once inside a terminal multiplexer. Per herdr’s documentation, it detects MastraCode only via installed lifecycle hooks and provides both state and session information through them - without the screen-manifest fallback common for other harnesses.
Where it fits: developer harness and enterprise harness
Mastra Code is a terminal tool for developers working on long-running projects who want to avoid losing context. For business users across an entire company who don’t work from a terminal, CompanyGPT is the fitting harness: tools via MCP servers and integrations, roles from Entra ID or Keycloak, and audit logs for governance. Our AI Gateway provides the shared cost and governance layer across different harnesses and model providers. Further agent harnesses are listed in our harness overview. If you’d like to check how a terminal coding agent like Mastra Code fits securely and cost-transparently into your development environment, get in touch.
