rust-code CLAUDE.md

Technical instructions for rust-code, an AI coding agent written in Rust. They describe its asynchronous runtime, terminal interface, model integrations, code tools, MCP support, and main crates.

In plain words
What is it for?
Use them when changing the agent core, terminal interface, model clients, session handling, code tools, MCP client, or code-intelligence server.
Why use it?
They help agents understand how the Rust workspace is divided and which libraries and components belong in each part.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/fortunto2/rust-code/claude-md
Clone the repo
git clone --depth 1 https://github.com/fortunto2/rust-code
Per session 3,350 This file is loaded in full into every session.
When invoked 3,350 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.03350 $0.03350
Opus 5 $0.01675 $0.01675
Sonnet 5 $0.00670 $0.00670
Haiku 4.5 $0.00335 $0.00335

Measured 2d ago against content hash 722e5d0257a3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

rust-code CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 190 lines

How it starts

The opening of the file, as written. The whole thing — 190 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md — rust-code

AI-powered terminal coding agent written in Rust.

Stack

  • Rust (Edition 2024), Tokio async runtime
  • Ratatui + Crossterm (TUI), tui-textarea (input)
  • sgr-agent (LLM client + agent framework + session + tools + providers)
  • Nucleo (fuzzy search, from Helix editor)
  • rmcp (MCP client — Model Context Protocol)
  • tmux (background task execution)

Architecture

  • crates/sgr-agent-core/ — minimal core: Tool trait, FileBackend trait, AgentContext (typed store), ToolError (5 variants), schema (6 deps)
  • crates/sgr-agent-tools/ — 14 tools + LocalFs + MockFs, generic over FileBackend trait (shell, apply_patch, indentation read, eval)
  • crates/sgr-agent/ — LLM client + agent framework + session/memory/providers/OpenAPI (re-exports core + tools)
  • crates/rc-cli/ — main binary: TUI (app.rs), headless mode (main.rs), agent loop (agent.rs), 27 tools (backend.rs + tools/)
  • crates/sgr-agent-tui/ — shared TUI shell: chat panel, streaming, agent loop integration, fuzzy picker
  • crates/solograph/ — MCP server for code intelligence
  • crates/genai/ — local fork of rust-genai (multi-provider LLM client: Gemini, OpenAI, Anthropic, Ollama, etc.)

Crate dependency graph

sgr-agent-core 0.2      <- Tool, FileBackend, AgentContext (typed store), ToolError (6 deps)
    ^              ^
sgr-agent-tools    sgr-agent 0.7
0.4                LLM framework + parallel tool execution
14 tools +         re-exports core + optional tools
LocalFs + MockFs        ^
                   rc-cli, agent-bit, souffleur, video-analyzer

Agent loop: user message → Agent::decide() → model returns Decision { situation, task, tool_calls } → execute tools → feed result back → repeat until finish_task or completion.

sgr-agent Framework

  • Core (sgr-agent-core): Tool trait, ToolOutput, ToolError, AgentContext, ToolDef, json_schema_for
  • Tools (sgr-agent-tools, or sgr-agent feature "tools"): 14 file-system tools generic over FileBackend:
    • Core: ReadTool (+ indentation mode), WriteTool (JSON repair), DeleteTool (batch), SearchTool (smart), ListTool, TreeTool, ReadAllTool
    • Deferred: MkDirTool, MoveTool, FindTool
    • Optional: EvalTool ("eval"), ShellTool ("shell"), ApplyPatchTool ("patch" — Codex-compatible diff DSL)
    • All-in-one: "tools-all" enables eval + shell + patch
  • LLM Client: GeminiClient, OpenAIClient — structured output + function calling + flexible parse
  • Agent framework (feature = "agent"):
    • Tool trait → ToolRegistry (builder, case-insensitive lookup, fuzzy resolve)
    • Agent trait → Decision { situation, task, tool_calls, completed }
    • 6 variants: SgrAgent (structured output), ToolCallingAgent (native FC), FlexibleAgent (text parse), HybridAgent (2-phase), Clarification, Planning
    • run_loop() — generic agent loop with 4-tier loop detection
    • ToolFilter — progressive discovery (keyword + fuzzy scoring)
  • Session (feature = "session"): Session, LoopDetector (4-tier), MemoryContext, hints, tasks, intent guard
  • App tools (feature = "app-tools"): bash, fs, git, apply_patch
  • OpenAPI (always available): parse any OpenAPI 3.x spec → fuzzy search endpoints → HTTP call
    • ApiRegistry — load multiple APIs, search across all, call by endpoint name
    • 10 popular APIs pre-configured: github, stripe, openai, supabase, posthog, slack, linear, cloudflare, vercel, sentry
    • APIs.guru fallback — 2800+ APIs searchable by name
    • Auto-cache specs to ~/.sgr-agent/openapi-cache/, auto-detect auth from env vars
    • $ref resolution for parameters and schemas, path-level param inheritance
  • Providers (feature = "providers"): TOML config, auth, CLI proxy, Codex proxy
  • Telemetry (feature = "telemetry"): OTEL file telemetry
  • Llm (feature = "genai"): provider-agnostic LLM facade — LlmConfig::auto("gpt-4o") / LlmConfig::endpoint(key, url, model)
  • Demo: cargo run -p sgr-agent --features agent --example agent_demo
  • Tests: cargo test -p sgr-agent --all-features — 510+ tests (sgr-agent), 82 tests (sgr-agent-tools), 15 tests (sgr-agent-core)

Read the full file on GitHub · 190 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 190 lines · 3,350 tokens per session scan A 722e5d0257a3

Subscribe to this mod's changes

rust-code CLAUDE.md is an instructions file published in the GitHub repository fortunto2/rust-code (41 stars, last pushed 10d ago), licensed MIT. It adds 3,350 tokens to every session, about $0.0168 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.