| name | setup |
| description | Bootstrap the Rust dev environment — verify rustup, toolchain, rust-analyzer, cargo tools, env vars. |
/setup
Bootstrap (or re-verify) the development environment. Idempotent — safe to re-run.
Steps
1. Verify rustup is installed
rustup --version
If missing: stop and tell the user to install rustup from https://rustup.rs/. Do not attempt to install it without asking.
2. Verify the active toolchain
rustup show active-toolchain
If a rust-toolchain.toml file exists in the project root, verify the pinned toolchain is installed:
rustup toolchain list
If the pinned toolchain is missing, install it:
rustup toolchain install "$(grep 'channel' rust-toolchain.toml | cut -d'"' -f2)"
3. Verify rust-analyzer is available
rustup component list --installed | grep rust-analyzer
If not installed, add it:
rustup component add rust-analyzer
Also check that the binary is reachable:
rust-analyzer --version
If rust-analyzer is not found even after rustup component add, warn the user — it may need to be installed as a standalone binary or via their editor's extension.
4. Verify required cargo components
Check for and install if missing:
rustup component list --installed | grep rustfmt || rustup component add rustfmt
rustup component list --installed | grep clippy || rustup component add clippy
cargo llvm-cov --version 2>/dev/null || cargo install cargo-llvm-cov
rustup component list --installed | grep llvm-tools || rustup component add llvm-tools-preview
5. Verify rust-analyzer-mcp is installed
rust-analyzer-mcp is the MCP server that exposes rust-analyzer to Claude Code. Check for it:
rust-analyzer-mcp --version 2>/dev/null || cargo install rust-analyzer-mcp
Then verify .mcp.json exists at the project root and contains the server entry. Read the file if it exists:
cat .mcp.json 2>/dev/null
If .mcp.json is missing or does not contain a rust-analyzer entry under mcpServers, create or merge it:
{
"mcpServers": {
"rust-analyzer": {
"command": "rust-analyzer-mcp"
}
}
}
If .mcp.json already exists with other servers, add the rust-analyzer entry alongside them — do not overwrite the whole file. Use jq if available:
jq '.mcpServers["rust-analyzer"] = {"command": "rust-analyzer-mcp"}' .mcp.json > .mcp.json.tmp \
&& mv .mcp.json.tmp .mcp.json
Note: .mcp.json should be committed to the repo so every contributor and CI run picks up the same MCP servers automatically.
6. Run cargo check
cargo check
This verifies the project compiles without producing build artefacts. If it fails, report the compiler error verbatim — do not attempt to fix compilation errors during setup.
7. Ensure .env exists (if .env-template is present)
test -f .env || (test -f .env-template && cp .env-template .env)
If .env was just created, enumerate the keys the user needs to fill in (read .env-template).
8. Report
Print a short status block:
Setup status
rustup : <version>
toolchain : <active toolchain>
rust-analyzer : <version | missing>
rustfmt : <installed | missing>
clippy : <installed | missing>
cargo-llvm-cov : <version | missing>
rust-analyzer-mcp : <version | missing>
.mcp.json : <present | created | missing rust-analyzer entry>
cargo check : <ok | FAILED>
.env : <present | created from template | not applicable>
RUST_LOG : <set | unset>
Keep it tight — one line per item. If everything is green, end with "Ready." If anything is yellow/red, list the next action explicitly.