# Claude Code - Customizing Output Styling and Syntax Highlighting
## What It Does
Claude Code supports custom output styles that let you transform the default blue monochrome output into a richly highlighted, syntax-aware display. You can configure custom themes, syntax highlighting for code blocks, ANSI color support, and even custom formatters for different content types.
## The Problem: Everything is Blue
**Default Claude Code output:**
- All text rendered in blue terminal color
- No syntax highlighting in code blocks
- No visual distinction between headings, code, and prose
- Hard to scan large outputs quickly
**What you want:**
- Syntax highlighting in code blocks (keywords, strings, comments in different colors)
- Visual hierarchy (headings, lists, emphasis)
- Custom color schemes matching your terminal theme
- Better readability for long conversations
## How to Use It
### Method 1: Use Built-in Output Styles
Claude Code includes several pre-configured output styles you can enable.
**Check available styles:**
```bash
ls ~/.config/opencode/output-styles/
# or
ls ~/Library/Application Support/opencode/output-styles/
```
**Enable a style (in Claude Code TUI):**
```
/output-style <style-name>
```
**Common built-in styles:**
- `default` - Standard blue monochrome
- `syntax` - Syntax highlighting for code blocks
- `rich` - Enhanced markdown rendering with colors
- `minimal` - Clean, distraction-free output
### Method 2: Create Custom Output Style
**Step 1: Create a new output style file**
```bash
# Create output styles directory if it doesn't exist
mkdir -p ~/.config/opencode/output-styles
# Create custom style
nano ~/.config/opencode/output-styles/my-theme.lua
```
**Step 2: Define your style (Lua configuration)**
```lua
-- my-theme.lua
-- Custom output styling for Claude Code
return {
name = "my-theme",
description = "Custom syntax highlighting and colors",
-- Markdown element styles
markdown = {
heading1 = { fg = "bright_blue", bold = true },
heading2 = { fg = "bright_cyan", bold = true },
heading3 = { fg = "cyan", bold = true },
heading4 = { fg = "blue" },
emphasis = { fg = "yellow", italic = true },
strong = { fg = "bright_white", bold = true },
list_bullet = { fg = "magenta" },
list_number = { fg = "magenta" },
link = { fg = "bright_blue", underline = true },
link_text = { fg = "blue" },
code_inline = { fg = "bright_green", bg = "black" },
code_block = { bg = "black" },
blockquote = { fg = "bright_black", italic = true },
rule = { fg = "bright_black" },
},
-- Syntax highlighting for code blocks
syntax = {
-- Language detection
auto_detect = true,
-- Color scheme for code
keyword = { fg = "magenta", bold = true },
string = { fg = "green" },
number = { fg = "cyan" },
comment = { fg = "bright_black", italic = true },
function_name = { fg = "bright_yellow" },
variable = { fg = "white" },
type = { fg = "bright_cyan" },
operator = { fg = "bright_white" },
constant = { fg = "red" },
-- Language-specific overrides
languages = {
python = {
keyword = { fg = "blue", bold = true },
string = { fg = "bright_green" },
builtin = { fg = "magenta" },
},
javascript = {
keyword = { fg = "magenta", bold = true },
string = { fg = "green" },
template_string = { fg = "bright_green" },
},
bash = {
keyword = { fg = "blue", bold = true },
variable = { fg = "cyan" },
string = { fg = "green" },
},
rust = {
keyword = { fg = "red", bold = true },
macro = { fg = "yellow" },
lifetime = { fg = "cyan" },
},
},
},
-- Tool output styling
tool_output = {
success = { fg = "green" },
error = { fg = "red", bold = true },
warning = { fg = "yellow" },
info = { fg = "blue" },
},
-- Diff highlighting
diff = {
added = { fg = "green", bg = "black" },
removed = { fg = "red", bg = "black" },
changed = { fg = "yellow", bg = "black" },
unchanged = { fg = "bright_black" },
},
}
```
**Step 3: Enable your custom style**
```bash
# In Claude Code TUI
/output-style my-theme
# Or set as default in config
opencode config set output_style my-theme
```
### Method 3: Use ANSI Color Codes Directly
If you want to quickly test colors without creating a full style file:
**Enable ANSI color support:**
```bash
# In Claude Code config
opencode config set render_ansi true
```
**Claude will then render ANSI escape codes in output:**
- `\033[31m` - Red text
- `\033[32m` - Green text
- `\033[33m` - Yellow text
- `\033[1m` - Bold text
- `\033[0m` - Reset formatting
### Method 4: Integration with Terminal Theme
**Match Claude Code colors to your terminal theme:**
If you use a specific terminal theme (like Dracula, Solarized, Nord), you can create an output style that matches.
**Example: Dracula theme**
```lua
-- dracula.lua
return {
name = "dracula",
description = "Dracula color scheme for Claude Code",
markdown = {
heading1 = { fg = "#ff79c6", bold = true }, -- Pink
heading2 = { fg = "#bd93f9", bold = true }, -- Purple
heading3 = { fg = "#8be9fd" }, -- Cyan
emphasis = { fg = "#f1fa8c", italic = true }, -- Yellow
strong = { fg = "#f8f8f2", bold = true }, -- Foreground
code_inline = { fg = "#50fa7b", bg = "#282a36" }, -- Green on bg
},
syntax = {
keyword = { fg = "#ff79c6", bold = true }, -- Pink
string = { fg = "#f1fa8c" }, -- Yellow
number = { fg = "#bd93f9" }, -- Purple
comment = { fg = "#6272a4", italic = true }, -- Comment
function_name = { fg = "#50fa7b" }, -- Green
type = { fg = "#8be9fd" }, -- Cyan
},
}
```
## When to Use It
**Use custom styling when:**
- Working on projects with lots of code output
- Reading long conversations with mixed content types
- You want to match your terminal theme
- Collaborating with team (shared style configurations)
**Stick with default when:**
- Quick one-off tasks
- You prefer minimal distraction
- Terminal doesn't support 256 colors or truecolor
## How It Works
### Rendering Pipeline
```
Claude generates markdown → Claude Code parses markdown
→ Applies output style rules → Renders to terminal with ANSI codes
```
**Key components:**
1. **Markdown parser**: Identifies structure (headings, code blocks, lists)
2. **Syntax highlighter**: Detects language, tokenizes code
3. **Style engine**: Applies colors/formatting based on rules
4. **Terminal renderer**: Converts to ANSI escape sequences
### Configuration Hierarchy
```
1. Built-in default style (fallback)
2. User config: ~/.config/opencode/config.yaml
3. Per-session override: /output-style command
4. Inline ANSI codes (if render_ansi: true)
```
### Syntax Detection
**Auto-detection based on:**
- Code block language tag: ` ```python`
- File extension in tool output
- Heuristics (keywords, structure)
**Manual override:**
```
/output-style-language python
```
## Where It Appears
**Configuration locations:**
**macOS:**
```
~/Library/Application Support/opencode/output-styles/
~/.config/opencode/config.yaml
```
**Linux:**
```
~/.config/opencode/output-styles/
~/.local/share/opencode/output-styles/
```
**Windows:**
```
%APPDATA%\opencode\output-styles\
```
**Global config:**
```yaml
# ~/.config/opencode/config.yaml
output_style: my-theme
render_ansi: true
syntax_highlighting: true
```
## Pro Tips
### 1. Create Multiple Theme Variants
```bash
# Light theme for daytime
~/.config/opencode/output-styles/light.lua
# Dark theme for evening
~/.config/opencode/output-styles/dark.lua
# High contrast for accessibility
~/.config/opencode/output-styles/high-contrast.lua
# Switch easily
/output-style dark
```
### 2. Match Your Code Editor Theme
If you use VS Code with Dracula theme, create a matching Claude Code theme:
```lua
-- dracula-code.lua
-- Matches VS Code Dracula theme
return {
name = "dracula-code",
syntax = {
keyword = { fg = "#ff79c6" }, -- Same as VS Code
string = { fg = "#f1fa8c" },
comment = { fg = "#6272a4" },
-- ... match all token colors
},
}
```
**Benefit:** Consistent visual experience across tools
### 3. Use Semantic Highlighting
```lua
-- semantic.lua
return {
name = "semantic",
syntax = {
-- Group by semantic meaning, not syntax
declaration = { fg = "cyan", bold = true }, -- Functions, classes
definition = { fg = "green" }, -- Variables, constants
reference = { fg = "white" }, -- Usage
modification = { fg = "yellow" }, -- Mutations
-- Apply to multiple token types
token_map = {
["function"] = "declaration",
["class"] = "declaration",
["method"] = "declaration",
["variable"] = "definition",
["constant"] = "definition",
["identifier"] = "reference",
["assignment"] = "modification",
["mutation"] = "modification",
},
},
}
```
### 4. Highlight Diffs More Clearly
```lua
-- diff-focused.lua
return {
name = "diff-focused",
diff = {
added = { fg = "black", bg = "green" }, -- High contrast
removed = { fg = "black", bg = "red" },
changed = { fg = "black", bg = "yellow" },
-- Add line number styling
line_number = { fg = "bright_black" },
line_number_added = { fg = "green" },
line_number_removed = { fg = "red" },
},
}
```
### 5. Terminal Compatibility Check
**Test your theme across terminals:**
```bash
# Create test file
cat > ~/.config/opencode/output-styles/test-colors.lua << 'EOF'
return {
name = "test-colors",
markdown = {
heading1 = { fg = "red" },
heading2 = { fg = "green" },
heading3 = { fg = "blue" },
heading4 = { fg = "yellow" },
heading5 = { fg = "magenta" },
heading6 = { fg = "cyan" },
},
}
EOF
# Test in Claude Code
/output-style test-colors
# Type in Claude Code:
# Heading 1
## Heading 2
### Heading 3
```
**Check if colors render correctly in:**
- Ghostty (your terminal)
- iTerm2
- VS Code integrated terminal
- tmux
### 6. Create Project-Specific Styles
**For different project types:**
```bash
# Rust projects - emphasize lifetimes and macros
~/.config/opencode/output-styles/rust-focused.lua
# Python projects - emphasize type hints
~/.config/opencode/output-styles/python-focused.lua
# Web projects - emphasize template literals
~/.config/opencode/output-styles/web-focused.lua
# Switch based on project
cd ~/rust-project && opencode
/output-style rust-focused
```
### 7. Export Style as Shareable Config
```lua
-- team-theme.lua
-- Shared theme for team consistency
return {
name = "team-theme",
description = "Company standard Claude Code theme",
author = "Nakul Tiruviluamala",
version = "1.0.0",
-- ... theme configuration
}
```
**Share with team:**
```bash
# Copy to team repo
cp ~/.config/opencode/output-styles/team-theme.lua \
~/team-repo/.opencode/themes/
# Team members install
cp ~/team-repo/.opencode/themes/team-theme.lua \
~/.config/opencode/output-styles/
```
## Advanced: Using output-style-setup Agent
Claude Code 2.0 includes a specialized agent for creating output styles.
**Invoke the agent:**
```
Prompt: "I want to create a custom output style with syntax highlighting
for Python, JavaScript, and Bash. Use warm colors (yellows, oranges,
reds) for keywords, cool colors (blues, greens) for strings and
comments. Make headings bold and cyan."
Claude will:
1. Use output-style-setup agent
2. Create Lua configuration file
3. Save to output-styles directory
4. Enable the style automatically
```
**Agent capabilities:**
- Read existing styles as templates
- Generate color schemes algorithmically
- Test color combinations for contrast
- Validate Lua syntax
- Enable style after creation
## Practical Examples
### Example 1: Solarized Dark Theme
```lua
-- solarized-dark.lua
return {
name = "solarized-dark",
markdown = {
heading1 = { fg = "#b58900", bold = true }, -- Yellow
heading2 = { fg = "#cb4b16", bold = true }, -- Orange
heading3 = { fg = "#dc322f" }, -- Red
heading4 = { fg = "#d33682" }, -- Magenta
emphasis = { fg = "#2aa198", italic = true }, -- Cyan
strong = { fg = "#839496", bold = true }, -- Base0
code_inline = { fg = "#859900", bg = "#073642" }, -- Green
list_bullet = { fg = "#b58900" },
},
syntax = {
keyword = { fg = "#859900" }, -- Green
string = { fg = "#2aa198" }, -- Cyan
comment = { fg = "#586e75", italic = true }, -- Base01
function_name = { fg = "#268bd2" }, -- Blue
number = { fg = "#d33682" }, -- Magenta
type = { fg = "#b58900" }, -- Yellow
},
}
```
### Example 2: Minimal Monochrome
```lua
-- minimal.lua
return {
name = "minimal",
description = "Distraction-free minimal styling",
markdown = {
heading1 = { bold = true },
heading2 = { bold = true },
heading3 = { bold = true },
emphasis = { italic = true },
strong = { bold = true },
code_inline = { fg = "bright_white" },
list_bullet = { fg = "white" },
},
syntax = {
-- All code same color, only structure emphasized
keyword = { bold = true },
comment = { fg = "bright_black", italic = true },
},
}
```
### Example 3: High Contrast (Accessibility)
```lua
-- high-contrast.lua
return {
name = "high-contrast",
description = "High contrast for accessibility",
markdown = {
heading1 = { fg = "black", bg = "bright_yellow", bold = true },
heading2 = { fg = "black", bg = "bright_cyan", bold = true },
heading3 = { fg = "bright_yellow", bold = true },
emphasis = { fg = "bright_yellow", bold = true },
strong = { fg = "bright_white", bold = true },
code_inline = { fg = "black", bg = "bright_white" },
},
syntax = {
keyword = { fg = "bright_yellow", bold = true },
string = { fg = "bright_green", bold = true },
comment = { fg = "white", italic = true },
function_name = { fg = "bright_cyan", bold = true },
},
}
```
## Color Reference
### Named Colors (ANSI)
**Basic colors:**
- `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
**Bright variants:**
- `bright_black`, `bright_red`, `bright_green`, `bright_yellow`
- `bright_blue`, `bright_magenta`, `bright_cyan`, `bright_white`
### Hex Colors (Truecolor)
If your terminal supports truecolor (24-bit):
```lua
syntax = {
keyword = { fg = "#ff6b6b" }, -- Custom red
string = { fg = "#4ecdc4" }, -- Custom teal
}
```
**Check terminal truecolor support:**
```bash
# Should display smooth color gradient
awk 'BEGIN{
s="/\\/\\/\\/\\/\\"; s=s s s s s s s s;
for (colnum = 0; colnum<77; colnum++) {
r = 255-(colnum*255/76);
g = (colnum*510/76);
b = (colnum*255/76);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s\033[0m", substr(s,colnum+1,1);
}
printf "\n";
}'
```
## Troubleshooting
### Issue 1: Colors Not Showing
**Symptoms:** Style enabled but output still blue
**Solutions:**
1. Check terminal color support:
```bash
echo $COLORTERM # Should be "truecolor" or "24bit"
tput colors # Should be 256 or higher
```
2. Enable ANSI rendering:
```bash
opencode config set render_ansi true
```
3. Verify style loaded:
```bash
opencode config get output_style
```
### Issue 2: Syntax Highlighting Not Working
**Symptoms:** Code blocks render without colors
**Solutions:**
1. Ensure language specified in code fence:
````markdown
```python # Not just ```
def hello():
pass
```
````
2. Check if language supported:
```bash
opencode config get syntax_languages
```
3. Enable syntax highlighting globally:
```bash
opencode config set syntax_highlighting true
```
### Issue 3: Theme Looks Wrong in tmux
**Symptoms:** Colors different in tmux vs normal terminal
**Solution:** Configure tmux for truecolor:
```bash
# In ~/.tmux.conf
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",*256col*:Tc"
# Reload tmux config
tmux source-file ~/.tmux.conf
```
### Issue 4: Lua Syntax Errors
**Symptoms:** "Failed to load output style" error
**Solution:** Validate Lua syntax:
```bash
# Check Lua syntax
lua -c ~/.config/opencode/output-styles/my-theme.lua
# If error, check:
# - All tables properly closed with }
# - All strings properly quoted
# - Commas between table entries
# - No trailing commas
```
## Integration with Your Workflow
### For Your midimaze Vault
**Recommended style for documentation work:**
```lua
-- midimaze-docs.lua
return {
name = "midimaze-docs",
description = "Optimized for Obsidian vault work",
markdown = {
-- Headings match Obsidian colors
heading1 = { fg = "#7c3aed", bold = true }, -- Purple (Obsidian accent)
heading2 = { fg = "#2563eb", bold = true }, -- Blue
heading3 = { fg = "#0891b2" }, -- Cyan
-- Wiki links highlighted
link = { fg = "#7c3aed", underline = true },
link_text = { fg = "#8b5cf6" },
-- Inline code (for tool names, file paths)
code_inline = { fg = "#10b981", bg = "#1f2937" },
-- Frontmatter display
frontmatter = { fg = "#6b7280", italic = true },
},
-- Tool output for file operations
tool_output = {
success = { fg = "#10b981" }, -- Green (file created)
error = { fg = "#ef4444", bold = true },
info = { fg = "#3b82f6" },
},
}
```
**Set as default for vault work:**
```bash
# In your midimaze directory
cd ~/Code/github.com/theslyprofessor/midimaze
opencode config set output_style midimaze-docs
```
### For Coding Projects
**Different styles for different languages:**
```bash
# Auto-switch based on project
# Add to your shell rc (~/.zshrc)
opencode-smart() {
local project_dir=$(pwd)
local style="default"
# Detect project type
if [[ -f "Cargo.toml" ]]; then
style="rust-focused"
elif [[ -f "package.json" ]]; then
style="web-focused"
elif [[ -f "pyproject.toml" ]] || [[ -f "setup.py" ]]; then
style="python-focused"
fi
# Launch with appropriate style
opencode --config output_style=$style "$@"
}
alias oc='opencode-smart'
```
## Next Steps
### Immediate Actions
1. **Test basic syntax highlighting:**
```bash
opencode config set syntax_highlighting true
opencode config set render_ansi true
# Restart Claude Code and test with code blocks
```
2. **Try a built-in theme:**
```
/output-style syntax
# Or
/output-style rich
```
3. **Create your first custom theme:**
- Start with example above
- Adjust colors to your preference
- Enable and test
### This Week
1. **Create theme matching your terminal:**
- Identify your terminal theme (Ghostty config)
- Map colors to Claude Code style
- Test thoroughly
2. **Create project-specific themes:**
- One for vault work (midimaze)
- One for coding (your main languages)
- Document which to use when
3. **Share theme with anyone else using Claude Code:**
- Export final theme
- Add to your dotfiles repo (chezmoi?)
- Document installation
## Related Resources
### Internal
- [[Claude Code 2.0 - Advanced Workflows with Sub-Agents and MCP]] - Using output-style-setup agent
- [[Context Strategies for AI Coding Agents]] - Better prompts for styling
### External
- [Claude Code Output Styling Docs](https://docs.claude.com/en/docs/claude-code/output-styles/)
- [ANSI Escape Codes Reference](https://en.wikipedia.org/wiki/ANSI_escape_code)
- [Terminal Color Schemes](https://github.com/mbadolato/iTerm2-Color-Schemes)
- [Ghostty Configuration](https://ghostty.org/docs/config/reference)
### Color Scheme Galleries
- [Base16 Themes](https://github.com/chriskempson/base16)
- [Dracula Theme](https://draculatheme.com/)
- [Solarized](https://ethanschoonover.com/solarized/)
- [Nord Theme](https://www.nordtheme.com/)
## Conclusion
Customizing Claude Code's output styling transforms the experience from reading blue monochrome text to a richly highlighted, visually hierarchical display. Start with enabling basic syntax highlighting, then progressively customize to match your terminal theme and workflow needs.
The key benefits:
- **Faster comprehension**: Syntax colors help you parse code quickly
- **Better hierarchy**: Headings and structure stand out
- **Reduced eye strain**: Proper contrast and color distribution
- **Consistency**: Match your editor and terminal themes
**Your next step:** Enable syntax highlighting and try one of the example themes above!