rust-development

A set of Rust development rules covering ownership, lifetimes, error handling, asynchronous code, and Cargo, Rust's project and dependency tool.

In plain words
What is it for?
Use it when creating, modifying, or reviewing Rust projects, including checking the toolchain, reading Cargo.toml, managing dependencies, and following async and error-handling patterns.
Why use it?
It imposes checks and workflows intended to catch setup and design mistakes before Rust code is written or changed.

Cursor rule for Cursor

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 rules/madebyaris/rakitui-ai/rust-development
Clone the repo
git clone --depth 1 https://github.com/madebyaris/rakitui-ai

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 3,716 The whole file, excluding the scripts and references it only reads on demand.
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.00000 $0.03716
Opus 5 $0.00000 $0.01858
Sonnet 5 $0.00000 $0.00743
Haiku 4.5 $0.00000 $0.00372

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

Security

Grade A, and why

rust-development 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.

.cursor/rules/rust-development.mdc · 688 lines

How it starts

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

Rust Development Patterns

Idiomatic Rust patterns focusing on ownership, safety, and performance.

CRITICAL: Agentic-First Rust Development

Pre-Development Verification (MANDATORY)

Before writing ANY Rust code:

1. CHECK RUST INSTALLATION
   → run_terminal_cmd("rustc --version")
   → run_terminal_cmd("cargo --version")
   
2. VERIFY CURRENT VERSIONS (use web_search)
   → web_search("Rust stable version December 2024")
   → web_search("Rust edition 2024 features")
   
3. CHECK EXISTING PROJECT
   → Does Cargo.toml exist? Read it first!
   → What Rust edition is specified?
   → What dependencies are already present?
   
4. FOR NEW PROJECTS - USE cargo new
   → NEVER manually create Cargo.toml from scratch
   → run_terminal_cmd("cargo new my_project")
   → run_terminal_cmd("cargo new --lib my_library")

CLI-First Rust Development

ALWAYS use Cargo CLI:

# Project creation (NEVER manually create Cargo.toml)
cargo new my_project
cargo new --lib my_library
cargo init  # In existing directory

# Add dependencies (NEVER manually edit Cargo.toml for deps)
cargo add tokio --features full
cargo add serde --features derive
cargo add thiserror
cargo add anyhow

# Development dependencies
cargo add --dev tokio-test
cargo add --dev mockall

# Build and verify
cargo build
cargo check  # Faster than build, just checks
cargo clippy  # Linting
cargo fmt  # Format code

# Test
cargo test
cargo test -- --nocapture  # See println output

Post-Edit Verification

After ANY Rust code changes, ALWAYS run:

# Check compilation
cargo check

# Lint for issues
cargo clippy -- -D warnings

# Run tests
cargo test

# Format code
cargo fmt --check

Common Rust Syntax Traps (Avoid These!)

// WRONG: Using unwrap in production code
let value = some_option.unwrap();  // Panics on None!
let data = result.unwrap();  // Panics on Err!

// CORRECT: Handle errors properly
let value = some_option.ok_or(MyError::NotFound)?;
let data = result.map_err(|e| MyError::from(e))?;

// WRONG: Borrowing across await points
async fn bad_example(data: &mut Data) {
    let reference = &data.field;
    async_operation().await;  // reference held across await!
    use_reference(reference);
}

// CORRECT: Clone or restructure
async fn good_example(data: &mut Data) {
    let value = data.field.clone();
    async_operation().await;
    use_value(value);
}

// WRONG: Missing Send bound for async traits
trait MyAsyncTrait {
    async fn do_work(&self);  // Won't compile in multi-threaded!
}

// CORRECT: Add Send bound when needed
trait MyAsyncTrait: Send + Sync {
    fn do_work(&self) -> impl Future<Output = ()> + Send;
}

// WRONG: String vs &str confusion
fn greet(name: String) { }  // Takes ownership unnecessarily
greet("hello".to_string());  // Wasteful allocation

// CORRECT: Accept borrowed when possible
fn greet(name: &str) { }  // Borrows, no allocation needed
greet("hello");  // Works directly with string literal

Read the full file on GitHub · 688 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 · 688 lines · 0 tokens per session scan A ec06f1b5df5a

Subscribe to this mod's changes

rust-development is a cursor rule published in the GitHub repository madebyaris/rakitui-ai (5 stars, last pushed 7mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,716 tokens. 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-31.