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.
npx agentmods add rules/tyrchen/cursor-rust-rules/utilitiesgit clone --depth 1 https://github.com/tyrchen/cursor-rust-rulesWhat 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 | $0.00000 | $0.04796 |
| Opus 5 | $0.00000 | $0.02398 |
| Sonnet 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 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.
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.
- 2d 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
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
typescript
Changes to these high-fan-out internals can affect every message, delta, element, or rerun. Keep work in them minimal, and benchmark changes with representative stress-test apps.
coolify-ai-docs
Master reference to all Coolify AI documentation in .ai/ directory.
python_lib
Tips and guidelines specific to the development of the Streamlit Python library, not applicable to scripts and e2e tests.
specs
This directory contains product and tech specs for Streamlit features.