rust-general

rust-general is a cursor rule for Cursor from PatrickJS/awesome-cursorrules. It costs 0 tokens per session (466 once invoked), scanned A, original, CC0-1.0.

A set of general rules for writing Rust applications and libraries. Rust is a programming language that checks memory ownership and error handling while compiling.

In plain words
What is it for?
Use it when structuring Rust crates, designing types and public APIs, handling errors, or writing concurrent and asynchronous Rust code.
Why use it?
It helps prevent common crashes and data-access mistakes while keeping Rust projects easier to understand and maintain. It also provides guidance for APIs, errors, concurrency, and asynchronous code.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when structuring Rust crates, designing types and public APIs, handling errors, or writing concurrent and asynchronous Rust code.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/patrickjs/awesome-cursorrules/rust-general
About the project

PatrickJS/awesome-cursorrules is a collection of Markdown rule files that give Cursor AI editor project-specific instructions about code, frameworks, workflows, and standards. Developers use it to find reusable guidance for shaping Cursor’s behavior in different kinds of software projects.

PatrickJS/awesome-cursorrules · 40,734 stars · on GitHub

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.

Clone the repo
git clone --depth 1 https://github.com/PatrickJS/awesome-cursorrules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rust-general

README.md
[![agentmods](https://agentmods.dev/badge/rules/patrickjs/awesome-cursorrules/rust-general.svg)](https://agentmods.dev/rules/patrickjs/awesome-cursorrules/rust-general)
Your own site
<a href="https://agentmods.dev/rules/patrickjs/awesome-cursorrules/rust-general"><img src="https://agentmods.dev/badge/rules/patrickjs/awesome-cursorrules/rust-general.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 466 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.00466
Opus 5 $0.00000 $0.00233
Sonnet 5 $0.00000 $0.00093
Haiku 4.5 $0.00000 $0.00047

Measured 4d ago against content hash 1d9815d7def6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

rust-general 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 4d 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.

rules/rust-general.mdc · 53 lines

How it starts

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

Rust General Rules

Project Structure

  • Keep crates focused and name modules by domain responsibility.
  • Put reusable library code in src/lib.rs and binary entry points in src/main.rs or src/bin/.
  • Keep public APIs small and documented.
  • Use feature flags deliberately and document non-default features.
  • Commit Cargo.lock for applications; follow the project convention for libraries.

Ownership and Types

  • Prefer borrowing over cloning when ownership is not needed.
  • Use owned values at API boundaries when the callee must store data.
  • Model domain states with enums and structs instead of strings or booleans.
  • Use Option<T> for absence and Result<T, E> for fallible operations.
  • Avoid unwrap() and expect() outside tests, examples, and process-startup invariants.

Error Handling

  • Use thiserror or project-standard custom errors for libraries.
  • Use anyhow or project-standard context-rich errors for applications.
  • Add context when crossing IO, network, database, or parsing boundaries.
  • Do not discard errors with _ unless explicitly documented.

Concurrency and Async

  • Use Send and Sync boundaries intentionally.
  • Prefer message passing or owned task inputs for async work.
  • Do not hold blocking locks across .await.
  • Use tokio::task::spawn_blocking or equivalent for blocking CPU or IO in async applications.
  • Propagate cancellation through futures rather than hiding it in detached tasks.

Testing and Quality

  • Run cargo fmt and cargo clippy before delivery.
  • Add unit tests for pure logic and integration tests for public behavior.
  • Use property tests for parsers, serializers, and state machines when useful.
  • Use benchmarks only after identifying a real performance question.

Common Mistakes

  • Do not fight the borrow checker by adding unnecessary Arc<Mutex<_>>.
  • Do not expose internal module structure through public APIs by accident.
  • Do not allocate in hot loops without measuring.
  • Do not use unsafe code unless the invariant is documented and tested.

Read the full file on GitHub · 53 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. 4d ago First seen · 53 lines · 0 tokens per session scan A 1d9815d7def6

Subscribe to this mod's changes

rust-general is a cursor rule published in the GitHub repository PatrickJS/awesome-cursorrules (40,734 stars, last pushed 3mo ago), licensed CC0-1.0. It costs nothing until one of its globs matches a file; then it loads 466 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-09-03.