lea_code
lea_code is a Dart command-line coding assistant powered by Genkit. It runs as an interactive terminal chat and gives the model a set of local workspace tools so it can inspect files, edit code, run commands, ask for approval, and manage lightweight session state while working in your project.
Features
- Interactive CLI chat loop with streamed responses
- A single agent loop, modeled on Claude Code, that keeps the whole conversation (tool calls included) across requests
- A built-in system prompt focused on code quality: read before editing, follow project conventions, keep diffs minimal, and verify with the project's own checks
- Session context in the system prompt: working directory, platform, date, model, and a git status snapshot
- Project instructions loaded from
LEA.md,CLAUDE.md, orAGENTS.mdin the workspace and its parent directories, plus~/.lea/LEA.md - Provider selection for Google, Anthropic, or OpenAI-compatible backends
- Optional custom system prompt, appended after the built-in one
- A terminal UI modeled on Claude Code: a bordered input box with history and slash-command completion, a spinner while the agent works, Markdown-styled responses,
⏺ Tool(argument)blocks with short result summaries, a checkbox task list, and arrow-key menus for approvals and questions - Esc or Ctrl-C interrupts the running request
Requirements
- Dart SDK
^3.11.4 git(optional) for the session git snapshot- API access:
- Google: a Google AI key
- OpenAI: an OpenAI-compatible key (optionally with a custom base URL)
- Anthropic: an Anthropic API key (
--api_key, or theANTHROPIC_API_KEYenvironment variable)
rg(ripgrep) available on your system for thegrepandglobtools- PowerShell is only used on Windows, by the
powershelltool
Install
dart pub global activate lea_code
Run
lea
You can also choose a provider, model, and provide a system prompt:
lea \
--provider openai \
--model gpt-6-luna \
--system_prompt "You are a careful coding assistant."
OpenAI example:
lea \
--provider openai \
--model gpt-6-luna \
--api_key "$OPENAI_API_KEY"
Anthropic example:
lea \
--provider anthropic \
--model claude-sonnet-5-5 \
--api_key "$ANTHROPIC_API_KEY"
OpenAI-compatible base URL example:
lea \
--provider openai \
--model gpt-6-luna \
--base_url "http://localhost:11434/v1" \
--api_key "your-key-if-needed"
You can also control how many model turns are allowed while using tools:
lea --max_turns 100
CLI Options
-p,--provider: Provider to use. One ofgoogle,openai, oranthropic. Defaults togoogle.-m,--model: Model name to use. Defaults togemini-flash-lite-latestforgoogle,gpt-6-lunaforopenai, andclaude-sonnet-5-5foranthropic.-k,--api_key: API key to use (provider-dependent).-b,--base_url: Base URL to use (foropenaiandanthropic).-s,--system_prompt: Extra instructions appended to the built-in system prompt.-t,--max_turns: Maximum number of model turns per request. Defaults to100.-h,--help: Show help.-v,--version: Show version.
Interactive Commands
Type / in the input box to see and complete these:
/clear: clear the conversation and the screen/new: clear the conversation, keeping the screen/tasks: show the session task list/model: show the current model/help: show commands and shortcuts/exit(or/quit): quit the program
Keyboard Shortcuts
- Enter: send the message.
\then Enter, Alt+Enter, or Shift+Enter (in terminals that report it) inserts a newline - ↑ / ↓: move through earlier messages
- Esc: interrupt the running request; press it twice to clear the input
- Ctrl-C: interrupt the running request, or clear the input; press it twice on an empty input to exit
- Ctrl-D on an empty input: exit
- Ctrl-L: clear the screen
- Ctrl-A / Ctrl-E, Ctrl-W, Ctrl-U, Ctrl-K, Alt+←/→: line editing
?on an empty input: show shortcuts
Pastes longer than a few lines are shown as [Pasted text #1 +42 lines] and sent in full. Color is turned off when NO_COLOR is set, and the plain line-based interface is used when input or output is not a terminal.
Project Instructions
At startup Lea Code looks for instruction files and adds them to the system prompt, in this order:
~/.lea/LEA.md(your personal instructions for every project)LEA.md,CLAUDE.md, andAGENTS.mdin each directory from the filesystem root down to the workspace
Later files are more specific, and project instructions take precedence over the built-in guidance. Use them for build and test commands, code style, and anything the agent should always know about the project.
Built-in Tools
read: reads a text file withcat -nstyle line numbers (2000 lines by default,offset/limitfor more)edit: replaces an exact string in a file. The match must be unique unlessreplace_allis set, and the file must have been read and left unchanged sincewrite: creates a file, or overwrites one that was read firstglob: finds files by glob pattern (**/*.dart), newest first, respecting.gitignoregrep: searches file contents with ripgrep, with file filters, context lines, and output modesbash: runs a shell command in the workspace, asking for approval unless every part of the command is recognized as read-onlyask_user_question: asks the user one to three multiple-choice questionstask_create,task_update,task_list: a session task list the agent uses to plan and track multi-step worksleep: waits for something external, such as a server startingpowershell(Windows only): runs a PowerShell command after approvallist_mcp_resources,read_mcp_resource: only available when an MCP adapter is configured
Tool activity is shown in the terminal as lines such as [bash] Run unit tests: dart test. Failed tool calls are shown and returned to the model as Error: ... so it can recover.
edit and write keep paths inside the workspace (after resolving ..). These tools run on your machine, so use Lea Code only in directories and environments you trust.
Project Structure
bin/lea_code.dart: CLI entrypoint and argument parsinglib/lea_code.dart: the terminal app: REPL loop, streaming output, approvals, and questionslib/agent/coding_agent.dart: the agent loop and conversation historylib/prompts/system_prompt.dart: the system promptlib/prompts/session_context.dart: environment, git snapshot, and instruction file discoverylib/tools/: tool definitions, withtool_registry.dartchoosing which tools are exposedlib/tools/runtime/: shared runtime for path resolution, file tracking, tasks, and approvalslib/tools/utils/: the shared tool helper and command safety rules
Libraries
- agent/coding_agent
- lea_code
- prompts/session_context
- prompts/system_prompt
- tools/ask_user_question_tool
- tools/bash_tool
- tools/edit_tool
- tools/glob_tool
- tools/grep_tool
- tools/list_mcp_resources_tool
- tools/models/session_task
- tools/models/tool_runtime_models
- tools/powershell_tool
- tools/read_mcp_resource_tool
- tools/read_tool
- tools/runtime/tool_runtime
- tools/sleep_tool
- tools/task_create_tool
- tools/task_list_tool
- tools/task_update_tool
- tools/tool_registry
- tools/utils/command_safety
- tools/utils/tool_support
- tools/write_tool
- ui/ansi
- ANSI styling, and helpers that measure, truncate and wrap styled text by the number of terminal columns it takes up.
- ui/console
- ui/line_editor
- ui/markdown
- ui/prompt_input
- ui/select_prompt
- ui/terminal
- ui/tool_display