Themes
Mastra Code ships with bundled themes and loads custom ones from ~/.mastracode/themes/<name>.json.
/theme— open the theme picker (built-ins + pairs + bundled + custom, live preview)/theme list— list all available themes/theme <name>— apply and persist a theme by name/theme auto|dark|light— built-in modes/theme <light>/<dark>— follow the terminal appearance with a theme pair/theme status— show the active mode and stored preferenceMASTRA_THEME=<name>— environment override (mode, theme name, or pair)
Bundled themes
tokyo-night, catppuccin-mocha, catppuccin-latte, gruvbox-dark, dracula, nord, solarized-dark, solarized-light
Bundled themes are defined in src/tui/bundled-themes.ts. A user file in ~/.mastracode/themes/ with the same name overrides the bundled version, so you can tweak one by copying its definition into a file and editing it.
Follow your terminal's light/dark mode
Picking a single custom theme locks you into its appearance, so it keeps the same palette no matter what your terminal is set to. To follow the terminal instead, use a light/dark pair: the light theme first, the dark theme second, separated by /.
MASTRA_THEME=catppuccin-latte/catppuccin-mocha mastracode
{
"preferences": {
"theme": "solarized-light/solarized-dark"
}
}Mastra Code reads the terminal's background color (OSC 11), then the COLORFGBG environment variable, and falls back to dark. It applies the light theme when the terminal is light and the dark theme otherwise. auto does the same for the built-in palettes.
The picker offers a pair for every bundled light/dark family: catppuccin-latte/catppuccin-mocha and solarized-light/solarized-dark. Any two theme names work in a pair, and each name must not contain /.
File format
{
"name": "midnight",
"appearance": "dark",
"bg": "#1a1b26",
"vars": {
"bg-raise": "#16161e",
"blue": "#7aa2f7",
"purple": "#bb9af7",
"green": "#9ece6a",
"red": "#f7768e",
"yellow": "#e0af68",
"fg": "#c0caf5",
"fg-dim": "#565f89"
},
"colors": {
"accent": "blue",
"borderAccent": "blue",
"success": "green",
"error": "red",
"warning": "yellow",
"text": "fg",
"muted": "fg-dim",
"dim": "fg-dim",
"textHighlight": "purple",
"userMessageBg": "bg-raise",
"function": "blue",
"number": "yellow",
"path": "fg-dim"
}
}
appearance(required):"dark"or"light". Selects the surface palette and the built-in theme used as a fallback for any color you don't set.bg(optional): the terminal background the theme is designed for. Panel and overlay shades derive from it, and foreground colors contrast-adapt against it. Mastra Code does not paint the terminal background, so set it in your terminal for a theme whosebgdiffers from it. Background color keys you don't set explicitly (overlayBg,selectedBg,userMessageBg,systemReminderBg,toolPendingBg,toolSuccessBg,toolErrorBg,errorBg) are derived frombgso overlays and panels match instead of falling back to the built-in near-black/white values.vars(optional): named palette. Values must be hex colors (#rrggbbor#rgb).colors(optional): any subset of the color keys below. Values are a hex color or the name of avar. The loader ignores unknown keys, but the JSON schema is stricter and flags them so typos show up in your editor.
Without a bg, foreground colors contrast-adapt against the terminal's actual background (WCAG-based). Omitted panel and overlay color keys keep the built-in values instead of being derived from that background, so set bg or provide those colors explicitly when you need the panels to match your terminal.
JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Mastra Code custom theme",
"description": "Color theme for the Mastra Code TUI. Place in ~/.mastracode/themes/<name>.json and apply with /theme <name>.",
"type": "object",
"required": ["appearance"],
"additionalProperties": false,
"properties": {
"$schema": { "type": "string" },
"name": {
"type": "string",
"description": "Display name. Defaults to the file name."
},
"appearance": {
"enum": ["dark", "light"],
"description": "Selects the surface palette and the built-in theme used as fallback for unset colors."
},
"bg": {
"$ref": "#/definitions/colorValue",
"description": "Terminal background the theme is designed for. Panel shades and contrast adaptation derive from it; the terminal background is not painted. Omit to adapt to the terminal's own background."
},
"vars": {
"type": "object",
"description": "Named palette. Values must be hex colors.",
"additionalProperties": { "$ref": "#/definitions/hex" }
},
"colors": {
"type": "object",
"description": "Color overrides. Values are a hex color or the name of a var.",
"additionalProperties": false,
"properties": {
"accent": { "$ref": "#/definitions/colorValue" },
"border": { "$ref": "#/definitions/colorValue" },
"borderAccent": { "$ref": "#/definitions/colorValue" },
"borderMuted": { "$ref": "#/definitions/colorValue" },
"success": { "$ref": "#/definitions/colorValue" },
"error": { "$ref": "#/definitions/colorValue" },
"warning": { "$ref": "#/definitions/colorValue" },
"muted": { "$ref": "#/definitions/colorValue" },
"dim": { "$ref": "#/definitions/colorValue" },
"text": { "$ref": "#/definitions/colorValue" },
"secondary": { "$ref": "#/definitions/colorValue" },
"thinkingText": { "$ref": "#/definitions/colorValue" },
"userMessageBg": { "$ref": "#/definitions/colorValue" },
"userMessageText": { "$ref": "#/definitions/colorValue" },
"systemReminderBg": { "$ref": "#/definitions/colorValue" },
"toolPendingBg": { "$ref": "#/definitions/colorValue" },
"toolSuccessBg": { "$ref": "#/definitions/colorValue" },
"toolErrorBg": { "$ref": "#/definitions/colorValue" },
"toolBorderPending": { "$ref": "#/definitions/colorValue" },
"toolBorderSuccess": { "$ref": "#/definitions/colorValue" },
"toolBorderError": { "$ref": "#/definitions/colorValue" },
"toolTitle": { "$ref": "#/definitions/colorValue" },
"toolArgs": { "$ref": "#/definitions/colorValue" },
"toolOutput": { "$ref": "#/definitions/colorValue" },
"textHighlight": { "$ref": "#/definitions/colorValue" },
"selectedBg": { "$ref": "#/definitions/colorValue" },
"overlayBg": { "$ref": "#/definitions/colorValue" },
"errorBg": { "$ref": "#/definitions/colorValue" },
"path": { "$ref": "#/definitions/colorValue" },
"number": { "$ref": "#/definitions/colorValue" },
"function": { "$ref": "#/definitions/colorValue" }
}
}
},
"definitions": {
"hex": {
"type": "string",
"pattern": "^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
},
"colorValue": {
"type": "string",
"description": "A hex color (#rgb or #rrggbb) or the name of an entry in vars."
}
}
}Color keys
| Key | Used for |
|---|---|
accent | Primary accent: prompts, highlights, selected prefix |
border / borderAccent / borderMuted | Box borders |
success / error / warning | Status colors |
text | Main body text |
secondary | One step softer than text: tool calls, status line |
muted / dim | De-emphasized text |
thinkingText | Reasoning/thinking output |
userMessageBg / userMessageText | Sent user messages |
systemReminderBg | System reminder blocks |
toolPendingBg / toolSuccessBg / toolErrorBg | Tool call panels |
toolBorderPending / toolBorderSuccess / toolBorderError | Tool panel borders |
toolTitle / toolArgs / toolOutput | Tool call text |
textHighlight | Inline code, headings, links |
selectedBg | Selected list rows |
overlayBg | Modal overlays |
errorBg | Error display background |
path / number / function | File paths, line numbers, function names |
Translating themes from other tools
Any existing theme can be converted — pi themes (~/.pi/agent/themes/*.json), VS Code color themes, terminal schemes (iTerm2, Ghostty, Alacritty, Windows Terminal), base16/base24 palettes, and editor themes like Tokyo Night, Catppuccin, or Gruvbox. The job is always the same: extract the source's palette, then map it onto the color keys above.
Common source vocabularies and where they land:
| Source concept | mastracode |
|---|---|
| Editor / terminal background | bg |
| Accent / primary / blue | accent, borderAccent, function |
| Green / success / diff-added | success |
| Red / error / diff-removed | error, toolBorderError |
| Yellow / orange / warning | warning, number |
| Magenta / purple / keywords | textHighlight |
| Foreground / editor text | text |
| Comments / gray / inactive | muted, dim, path |
| Selection background | selectedBg |
| Panel / sidebar / raised background | overlayBg, toolPendingBg, toolSuccessBg |
| Error background | errorBg, toolErrorBg |
| Dark/light variant | appearance |
Specific source hints:
- pi (
vars+colors): structure is nearly identical — keepvars, remapcolorskeys per the table. - VS Code (
.jsontheme): useeditor.foregroundfortext,editor.backgroundforbg,editor.selectionBackgroundforselectedBg, andtokenColorsscopes (keyword →textHighlight, string →success-family, comment →muted). Setappearanceto"dark"or"light"based on the source theme's variant. - Terminal schemes (ANSI 16): foreground →
text, blue →accent, green/red/yellow →success/error/warning, bright black →muted, magenta →textHighlight. - base16: base05 →
text, base03 →muted, base0D →accent, base0B/base08/base0A →success/error/warning, base0E →textHighlight, base02 →selectedBg.
Keep hex values as-is; drop source keys with no counterpart and let the built-in fallback fill the rest. Ask your agent: "translate the theme file or name to a mastracode theme at ~/.mastracode/themes/<name>.json using the mapping in themes.mdx".