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.
git clone --depth 1 https://github.com/tyrchen/cursor-rust-rulesWrote 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.
[](https://agentmods.dev/rules/tyrchen/cursor-rust-rules/utilities)<a href="https://agentmods.dev/rules/tyrchen/cursor-rust-rules/utilities"><img src="https://agentmods.dev/badge/rules/tyrchen/cursor-rust-rules/utilities/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/tyrchen/cursor-rust-rules/utilities"><img src="https://agentmods.dev/badge/rules/tyrchen/cursor-rust-rules/utilities.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.04796 |
| Opus 5.5 | $0.00000 | $0.01918 |
| Sonnet 5.5 | $0.00000 | $0.00959 |
| Haiku 4.5 | $0.00000 | $0.00480 |
Grade A, and why
utilities 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 1mo 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.
How it starts
The opening of the file, as written. The whole thing — 749 lines — stays where its author put it; the contents beside it link to each section on GitHub.
🛠️ UTILITY LIBRARIES BEST PRACTICES
TL;DR: Essential utility patterns for authentication, CLI tools, data structures, and common development tasks.
🔍 UTILITY LIBRARY SELECTION STRATEGY
graph TD
Start["Utility Requirements"] --> UtilityType{"Utility<br>Category?"}
UtilityType -->|Authentication| AuthUtils["Authentication Utilities"]
UtilityType -->|CLI Tools| CLIUtils["CLI Utilities"]
UtilityType -->|Data Structures| DataUtils["Data Structure Utilities"]
UtilityType -->|Validation| ValidationUtils["Validation Utilities"]
AuthUtils --> JWT["JWT Token Management"]
AuthUtils --> PasswordHash["Password Hashing"]
CLIUtils --> ClapCLI["Clap CLI Framework"]
CLIUtils --> ProgressBars["Progress Indicators"]
DataUtils --> TypedBuilder["TypedBuilder Pattern"]
DataUtils --> EnumDispatch["enum_dispatch"]
ValidationUtils --> SerdeValidation["Serde Validation"]
ValidationUtils --> CustomValidation["Custom Validators"]
JWT --> Security["Security Implementation"]
PasswordHash --> Security
ClapCLI --> UserInterface["User Interface"]
ProgressBars --> UserInterface
TypedBuilder --> CodeGeneration["Code Generation"]
EnumDispatch --> CodeGeneration
SerdeValidation --> DataIntegrity["Data Integrity"]
CustomValidation --> DataIntegrity
Security --> Production["Production Utilities"]
UserInterface --> Production
CodeGeneration --> Production
DataIntegrity --> Production
style Start fill:#4da6ff,stroke:#0066cc,color:white
style AuthUtils fill:#4dbb5f,stroke:#36873f,color:white
style CLIUtils fill:#ffa64d,stroke:#cc7a30,color:white
style DataUtils fill:#d94dbb,stroke:#a3378a,color:white
🔐 AUTHENTICATION AND SECURITY
JWT with jsonwebtoken
# Cargo.toml - JWT configuration
[dependencies]
jsonwebtoken = "9.0"
serde = { version = "1.0", features = ["derive"] }
chrono = { version = "0.4", features = ["serde"] }
use jsonwebtoken::{decode, encode, Algorithm, DecodingKey, EncodingKey, Header, Validation};
use serde::{Deserialize, Serialize};
use chrono::{DateTime, Utc};
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Claims {
pub sub: String, // Subject (user ID)
pub exp: i64, // Expiration time
pub iat: i64, // Issued at
pub user_role: String, // Custom claim
pub session_id: String, // Session identifier
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TokenPair {
pub access_token: String,
pub refresh_token: String,
pub expires_in: i64,
}
pub struct JwtService {
encoding_key: EncodingKey,
decoding_key: DecodingKey,
access_token_expiry: i64, // seconds
refresh_token_expiry: i64, // seconds
}
impl JwtService {
pub fn new(secret: &str) -> Self {
Self {
encoding_key: EncodingKey::from_secret(secret.as_bytes()),
decoding_key: DecodingKey::from_secret(secret.as_bytes()),
access_token_expiry: 3600, // 1 hour
refresh_token_expiry: 604800, // 7 days
}
}
pub fn generate_token_pair(&self, user_id: &str, role: &str) -> Result<TokenPair, JwtError> {
let now = Utc::now().timestamp();
let session_id = uuid::Uuid::new_v4().to_string();
// Access token
let access_claims = Claims {
sub: user_id.to_string(),
exp: now + self.access_token_expiry,
iat: now,
user_role: role.to_string(),
session_id: session_id.clone(),
};
let access_token = encode(&Header::default(), &access_claims, &self.encoding_key)?;
// Refresh token (longer expiry, minimal claims)
let refresh_claims = Claims {
sub: user_id.to_string(),
exp: now + self.refresh_token_expiry,
iat: now,
user_role: "refresh".to_string(),
session_id,
};
let refresh_token = encode(&Header::default(), &refresh_claims, &self.encoding_key)?;
Ok(TokenPair {
access_token,
refresh_token,
expires_in: self.access_token_expiry,
})
}
pub fn validate_token(&self, token: &str) -> Result<Claims, JwtError> {
let validation = Validation::new(Algorithm::HS256);
let token_data = decode::<Claims>(token, &self.decoding_key, &validation)?;
Ok(token_data.claims)
}
pub fn refresh_access_token(&self, refresh_token: &str) -> Result<TokenPair, JwtError> {
let claims = self.validate_token(refresh_token)?;
// Verify it's a refresh token
if claims.user_role != "refresh" {
return Err(JwtError::InvalidTokenType);
}
// Generate new token pair
self.generate_token_pair(&claims.sub, "user") // Default role, should be fetched from DB
}
}
#[derive(thiserror::Error, Debug)]
pub enum JwtError {
#[error("JWT encoding/decoding error: {0}")]
Token(#[from] jsonwebtoken::errors::Error),
#[error("Invalid token type")]
InvalidTokenType,
#[error("Token expired")]
Expired,
}
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.
- 1mo ago First seen · 749 lines · 0 tokens per session scan A de9265de3ff9
utilities is a cursor rule published in the GitHub repository tyrchen/cursor-rust-rules (27 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 4,796 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-30.
Other cursor rules, from other repositories
rust-module-refactor
Use when splitting Rust modules, moving tests, tightening visibility, or preserving facades during refactors.
rust-architect
PoolAI — Rust Architect workflow: runtime stack, MSYS2, target/ disk, pre-push checks, docs sync.
table-of-contents-standard
Standard section ordering and TOC format for Verus source files.
arc-deref-pattern
When implementing parallel (Mt) algorithms in Verus, do NOT assume.
wrap-vs-specify
When to use externaltypespecification vs wrapper struct for Verus specs.
core
Core STT/TTS abstraction layer documentation.