rust-analyzer-cli
Compiler-accurate Rust codebase navigation powered by rust-analyzer LSP and an embedded HTTP daemon.
rust-analyzer-cli is dual-structured as both a CLI tool and a Rust Library (rust_analyzer_cli), enabling AI Agents, developer tools, and Rust programs to perform fast, compiler-accurate symbol search, document outline extraction, definition lookup, call hierarchy analysis, and compilation checks.
Features
- 🚀 Background Daemon & Persistent LSP Session: Spawns
rust-analyzervia JSON-RPC stdio and serves an embedded Axum HTTP REST server (default port60094). - 🔍 Workspace Symbol Search: Search for structs, enums, functions, traits, and variables across the entire workspace.
- 📜 Document Outline: Extract hierarchical document symbol outlines for any
.rsfile. - 🎯 Go to Definition: Jump directly to exact symbol definitions by file, line, and column.
- 📞 Call Hierarchy & References: Query incoming/outgoing call chains and symbol reference locations.
- 🧬 Type Hierarchy: Traverse supertypes and subtypes.
- 🛠 Cargo Check Integration: Run
cargo checkand parse structured compiler diagnostics. - 🤖 AI Agent Friendly: Supports human-readable CLI outputs and
--jsonstructured formatting.
Installation
As a CLI Tool
Prerequisite: Ensure rust-analyzer is installed and available in your system PATH.
As a Rust Library
Add rust_analyzer_cli to your project's Cargo.toml:
[]
= "0.2.0"
Usage Guide
1. Start the Background Daemon
Before running queries, start the daemon from your workspace root:
To check daemon & LSP indexing status:
To refresh/restart the rust-analyzer session:
2. Core Commands
Search Workspace Symbols
# Example:
Extract File Outline
# Example:
Go to Definition
# Example:
References & Call Hierarchy
# Example:
Type Hierarchy
Cargo Check Verification
Using as a Rust Library
You can embed the HTTP server or interact with data types directly in your Rust applications:
use start_daemon_server;
use *;
use PathBuf;
async
AI Agent Integration
An agent skill definition is included in SKILL.md. AI coding agents (such as Google Antigravity or Agentic Assistants) can read SKILL.md to navigate Rust codebases.
License
Dual-licensed under MIT or Apache-2.0.