Generate production-ready Rust Cursor rules for Project Rules (.mdc), AGENTS.md, or legacy .cursorrules. This template encodes stack-specific conventions for projects using Rust. Systems language with ownership, zero-cost abstractions, and fearless concurrency.
The template focuses Cursor AI on concrete Rust practices instead of generic coding advice. Required sections are always included; optional sections can be enabled when they match your project.
Required guidance
- Ownership & Borrowing
- Error Handling
- Modules & Crates
- Idiomatic Patterns
Default style
- Indentation: 4 spaces
- Quotes: double
- Semicolons: enabled
- Naming: snake_case
Example Rust Rules
The generator turns these sections into Project Rules with frontmatter, AGENTS.md, or a single .cursorrules file depending on the output format you choose.
Ownership & Borrowing
- Prefer borrowing (&T, &mut T) over taking ownership when possible.
- Use snake_case for variables, functions, and methods.
- Use PascalCase for types, traits, and enums.
- Use SCREAMING_SNAKE_CASE for constants and statics.
- Clone only when ownership transfer is unavoidable.
- Use references with explicit lifetimes only when the compiler requires them.
Error Handling
- Use Result<T, E> for fallible operations — no exceptions.
- Use the ? operator for error propagation.
- Use thiserror for custom error types with derive macros.
- Use anyhow for application-level error handling.
- Use Option<T> instead of null — never use unwrap() in production code.
- Use expect() with descriptive messages during development only.
Modules & Crates
- Use mod declarations to organize code into modules.
- Use pub to control visibility — keep internals private by default.
- Use use statements for imports at the top of each file.
- Use pub(crate) for internal visibility within the crate.
- Use workspace for multi-crate projects.
- Keep module files focused: one primary concern per module.
Common Searches This Page Helps With
rust cursor rulesrust .cursorrulesrust AGENTS.md
Frequently Asked Questions
What does the Rust Cursor rules template include?
It includes 4 rule sections covering ownership & borrowing, error handling, modules & crates and other Rust development conventions.
Can I generate Rust Project Rules and AGENTS.md from the same template?
Yes. The generator can export the same stack-specific guidance as modern Project Rules (.mdc), AGENTS.md, or a legacy .cursorrules file.
Should I combine Rust with other Cursor rules templates?
Yes. You can combine Rust with related templates such as TypeScript, Tailwind CSS, Docker, or backend frameworks when your project uses multiple technologies.