← Projects
crates.io sgr-agent github fortunto2/rust-code

rust-code

Terminal coding agent written in Rust. Ratatui TUI, SGR-driven agent loop with typed tool execution, fuzzy navigation, session persistence, MCP support, and autonomous BigHead mode.

brew install fortunto2/tap/rust-code     # Homebrew (macOS)
cargo install rust-code                  # crates.io
rust-code doctor --fix                   # install deps (tmux, ripgrep)

Why This Exists

An alternative to Claude Code, built for my workflow:

  1. SGR-driven agent loop — prompts are compiled schemas, not markdown files. Structured tool dispatch via typed Rust enums, not string parsing
  2. Background tasks on tmux — sessions you can monitor, detach, reattach. Why doesn’t everyone do this?
  3. Fuzzy search everywhere — git history, file picker, skill browser, all on F1-F10 keys. Everything searchable instantly
  4. Rust — fast compiler, strict types, one binary. What I was forcing with Pydantic in Python is native here
  5. Memory system built-in — no need to install plugins, skills, config files. Everything pre-configured out of the box
  6. Minimal dependencies — but has everything: skills, MCP, tools, sessions

“With agents, the more typed and strict the language, the better. Python is for humans — but IDEs aren’t needed anymore.”

Also contains sgr-agent crate (v0.6.1) — the core library for building any Rust SGR agent. Structured output, function calling, agent loop, 3 agent variants.

Usage

rust-code                                    # interactive TUI
rust-code -p "Find the bug in src/main.rs"   # headless mode
rust-code --resume                           # continue last session
rust-code --resume "refactor"                # fuzzy-search sessions by topic
rust-code -p "build feature X" --loop 5      # autonomous loop (BigHead mode)
rust-code -p "improve yourself" --evolve     # self-evolution mode

Key Features

Architecture

SGR agent loop: Schema-based tool dispatch, not string parsing. Pydantic-style schemas define the loop – structured tool dispatch, validation, fallback chain. Implements all four tool calling layers in Rust.

Providers: Google AI (Gemini), Vertex AI, Anthropic, OpenRouter, Ollama (local). At least one must be configured.

Agent core: Built on sgr-agent, which uses openai-oxide as the LLM transport. Same crate compiles to WASM for browser use.

TUI Shortcuts

Key Action
Enter Send message
Ctrl+P File search
Ctrl+H Session history
Ctrl+G Refresh git sidebar
Tab Focus sidebar
F1 Diff channel
F2 Git history
F6 Project symbols
F7 Background tasks (tmux)
F9 Skills browser

OpenAPI -> Tool

Convert any REST API into a searchable, callable tool – no codegen needed.

MCP (Model Context Protocol)

Add .mcp.json to project or home directory:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@playwright/mcp@latest"]
    }
  }
}

Tools auto-discovered at startup.

AGENTS.md

rust-code works best when the target repo contains an AGENTS.md file with project-specific instructions (stack, architecture, code style, test/build commands). The more concrete, the better the agent performs.

CLI

Commands:
  setup       Interactive provider setup wizard
  doctor      Check system deps and API auth (--fix to auto-install)
  skills      Manage agent skills (add, remove, search, list, catalog)
  sessions    List or search past chat sessions
  mcp         Show MCP server status and tools
  config      Set default provider (show, set, reset)
  task        Manage project tasks (list, show, create, done, update)

Options:
  -p, --prompt <PROMPT>    Headless mode with a prompt
  -r, --resume [TOPIC]     Resume last session or fuzzy-search by topic
      --model <NAME>       Override model name
      --local              Use local Ollama model
      --loop <N>           Autonomous loop (BigHead mode)
      --max-hours <FLOAT>  Time limit for loop/evolve mode
      --evolve             Self-evolution mode

Links

Sources

Related