Configuration
LeanCTL stores its configuration in ~/.leanctl/config.toml. The init wizard creates this file — all settings below are optional.
Config File
View your current configuration:
leanctl config The config file lives at ~/.leanctl/config.toml and has the following sections:
Full example
# ~/.leanctl/config.toml
# Default provider (used when starting leanctl)
default_provider = "murat"
# Provider registry — add as many as you need
[[providers]]
name = "murat"
type = "ollama"
model = "qwen3.5:27b"
base_url = "http://murat.local:11434"
[[providers]]
name = "claude"
type = "anthropic"
model = "claude-sonnet-4-20250514"
api_key_env = "ANTHROPIC_API_KEY"
[[providers]]
name = "gpt"
type = "openai"
model = "gpt-4.1"
api_key_env = "OPENAI_API_KEY"
[[providers]]
name = "local"
type = "ollama"
model = "gemma4:e2b"
# Thinking configuration
[thinking]
mode = "auto" # auto | always | never | manual
# Behavior settings
[behavior]
auto_preload = true # auto-load project context
context_budget = 8000 # max tokens for context
confirm_edits = true # ask before editing files
confirm_commands = true # ask before running commands
auto_compact = true # compress context automatically
# Display settings
[display]
show_thinking_budget = true
show_token_savings = true
show_cost = true
compact = false
# Theme
theme = "default"
# Task routing — use different models per task type
[routing]
explore = "local" # fast local model for exploration
generate = "claude" # strong model for code generation
casual = "local" # local model for casual chat
# MCP servers (external tool integration)
[mcp.my-server]
command = "my-mcp-server"
args = ["--port", "3000"]
# Gateway (Pro features)
gateway_url = "https://api.leanctl.com"
gateway_key = "lctl_..."
tier = "pro" Provider Registry
The [[providers]] array is the primary way to configure AI providers. Each entry defines a named provider with its type, model, and credentials.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique name for this provider (used in /connect and routing) |
type | string | Yes | Provider type: anthropic, openai, ollama, lmstudio, deepseek, groq, openrouter |
model | string | Yes | Model identifier (e.g. claude-sonnet-4-20250514) |
api_key | string | No | API key (stored in config — use api_key_env for safer storage) |
api_key_env | string | No | Environment variable name containing the API key |
base_url | string | No | Custom endpoint URL (required for self-hosted, Ollama, LM Studio) |
context_window | number | No | Context window size in tokens |
cost_per_1k_input | number | No | Cost per 1K input tokens (for cost tracking) |
cost_per_1k_output | number | No | Cost per 1K output tokens (for cost tracking) |
local | boolean | No | Mark as local to bypass Pro tier check (for self-hosted LLMs) |
See Providers for detailed setup instructions per provider.
Thinking Configuration
Controls how LeanCTL manages AI reasoning tokens. See Thinking Steering for the full guide.
| Mode | Description |
|---|---|
auto | Automatically adjusts thinking based on task complexity (default) |
always | Always enables maximum thinking |
never | Disables thinking to save tokens |
manual | You control thinking via the /thinking command |
Behavior Settings
| Key | Default | Description |
|---|---|---|
auto_preload | true | Automatically load project context (LEANCTL.md, key files) at session start |
context_budget | 8000 | Maximum tokens to use for preloaded context |
confirm_edits | true | Ask for confirmation before editing files |
confirm_commands | true | Ask for confirmation before running shell commands |
auto_compact | true | Automatically compress conversation when context grows too large |
leanctl --yolo or the /yolo command to skip all confirmation prompts. Useful for trusted tasks.
Display Settings
| Key | Default | Description |
|---|---|---|
show_thinking_budget | true | Show thinking token budget in status bar |
show_token_savings | true | Show token compression statistics |
show_cost | true | Show API cost estimates |
compact | false | Compact display mode (less visual chrome) |
Task Routing
Route different task types to different providers. This lets you use a fast local model for exploration and a powerful cloud model for code generation.
[routing]
explore = "local" # file reads, searches, navigation
generate = "claude" # code generation, refactoring
casual = "local" # casual conversation
fallback = ["gpt"] # fallback if primary fails Provider names must match entries in your [[providers]] registry.
MCP Servers
Extend LeanCTL with external MCP (Model Context Protocol) servers:
[mcp.my-server]
command = "my-mcp-binary"
args = ["--port", "3000"]
[mcp.my-server.env]
API_KEY = "..." Manage MCP servers in the TUI with /mcp, /mcp add, and /mcp reload.
Permissions
Control which tools require confirmation with a per-project .leanctl/permissions.toml:
# .leanctl/permissions.toml
write_file = "allow" # auto-approve file writes
run_command = "deny" # always block shell commands
git_commit = "allow" # auto-approve commits
* = "allow" # allow everything (same as --yolo) Pattern matching supports wildcards (*) and prefix patterns (git_*). More specific patterns take precedence.
Environment Variables
| Variable | Description |
|---|---|
ANTHROPIC_API_KEY | Anthropic API key (auto-detected) |
OPENAI_API_KEY | OpenAI API key (auto-detected) |
DEEPSEEK_API_KEY | DeepSeek API key |
GROQ_API_KEY | Groq API key |
LeanCTL also loads .env files from your project root automatically.
Project Configuration
Instruction files
LeanCTL reads project-specific instructions from any of these files (checked in order, all merged):
| File | Description |
|---|---|
LEANCTL.md | Primary instruction file (created by /init) |
.leanctl.md | Hidden alternative |
.leanctl/instructions.md | Instructions in config directory |
AGENTS.md | Cross-tool agent instructions |
CLAUDE.md | Claude Code compatibility |
.cursorrules | Cursor compatibility |
opencode.md | OpenCode compatibility |
CRUSH.md | Crush compatibility |
Instructions are truncated to 2,000 characters in the system prompt.
Skills discovery
LeanCTL discovers skill files from these paths and makes them available to the AI:
SKILL.md— project root.leanctl/SKILL.md— project config.leanctl/skills/*.md— skill directory (recursive).cursor/skills/*.md— Cursor skills compatibility
Custom commands
Create custom slash commands by adding markdown files to .leanctl/commands/ or ~/.leanctl/commands/:
# .leanctl/commands/review.md
Review the following code for security issues,
performance problems, and best practices.
Focus on: $ARGUMENTS Usage in the TUI: /review src/auth.ts — the $ARGUMENTS placeholder is replaced with whatever follows the command name.
Lab Parameters
The /lab command in the TUI lets you tune LeanCTX compression parameters at runtime:
| Parameter | Default | Description |
|---|---|---|
LEAN_CTX_CRP_MODE | tdd | Compact Response Protocol mode (tdd, compact, off) |
LEAN_CTX_CACHE_TTL | 300 | Cache time-to-live in seconds |
LEAN_CTX_AUTONOMY | true | Enable autonomous intelligence (auto-preload, auto-dedup) |
LEAN_CTX_CHECKPOINT_INTERVAL | 15 | Auto-checkpoint every N tool calls |
LEAN_CTX_LITM_PROFILE | auto | Lost-in-the-Middle optimization profile |
LEAN_CTX_DEDUP_THRESHOLD | 8.0 | Minimum savings % to trigger auto-dedup |
LEAN_CTX_CACHE_MAX_TOKENS | 500000 | Maximum tokens in session cache |
/lab # show all current values
/lab LEAN_CTX_CRP_MODE compact # set CRP mode to compact
/lab LEAN_CTX_CACHE_TTL 600 # extend cache to 10 minutes Themes
LeanCTL includes built-in theme presets. Switch in the TUI:
/theme # open theme picker
/theme neon # switch to neon theme Create a custom theme file at ~/.leanctl/theme.toml to override colors.
Storage Locations
| Path | Content |
|---|---|
~/.leanctl/config.toml | Main configuration file |
~/.leanctl/sessions/sessions.db | SQLite database for chat sessions |
~/.leanctl/history.txt | REPL input history (max 1,000 entries) |
~/.leanctl/logs/ | Daily rotating log files |
~/.leanctl/theme.toml | Custom theme (optional) |
~/.leanctl/commands/ | Global custom commands |
.leanctl/ | Per-project config (permissions, commands, skills) |