docs/src/mastra-code/index.mdx
import Steps from '@site/src/components/Steps'; import StepItem from '@site/src/components/StepItem'; import YouTube from '@site/src/components/YouTube';
Mastra Code is a terminal-based AI coding agent built on Mastra's Harness, Agent, and Memory primitives. It runs in your terminal, connects to 70+ AI models, and provides tools for reading, searching, editing, and executing code.
Mastra Code organizes its capabilities around these areas:
Mastra Code requires Node.js 22.13.0 or later.
```sh npm2yarn
npm install -g mastracode
```
Or run it with `npx`:
```sh npm2yarn
npx mastracode
```
```sh
cd your-project
mastracode
```
Mastra Code provides built-in slash commands for managing sessions and settings:
| Command | Description |
|---|---|
/new | Start a new conversation thread |
/clone | Clone the current thread (with optional rename) |
/threads | List all threads for this project |
/models | Select a different AI model |
/mode | Switch between Build, Plan, and Fast modes |
/cost | Show token usage for the current conversation |
/login | Authenticate with OAuth providers |
/logout | Log out from a provider |
/settings | Open the settings panel |
/theme | Switch color theme (auto, dark, or light) |
/sandbox | Add external directories to the allowed path list |
/diff | Show files modified in the current session |
/help | Show available commands |
/exit | Exit the TUI |
You can also define custom slash commands as markdown files. See Configuration for details.
| Shortcut | Action |
|---|---|
Ctrl+C | Interrupt current operation or clear input |
Ctrl+C ×2 | Exit (double-tap) |
Ctrl+D | Exit (when editor is empty) |
Ctrl+Z | Suspend process (fg to resume) |
Alt+Z | Undo last clear |
Ctrl+T | Toggle thinking blocks visibility |
Ctrl+E | Expand/collapse all tool outputs |
Enter | Send a message, or queue a follow-up while the agent is running |
Ctrl+Y | Toggle YOLO mode |
Mastra Code is built on four layers:
pi-tui components)In this demo, you'll see Mastra Code in action and learn how it came to be.
<YouTube id="Hbgh3Iyd3Mk" />