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/tools-and-configgit 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.04960 |
| Opus 5 | $0.00000 | $0.02480 |
| Sonnet 5 | $0.00000 | $0.00992 |
| Haiku 4.5 | $0.00000 | $0.00496 |
Grade A, and why
tools-and-config 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 โ 722 lines โ stays where its author put it; the contents beside it link to each section on GitHub.
๐ ๏ธ TOOLS AND CONFIGURATION BEST PRACTICES
TL;DR: Essential tools and configuration patterns for modern Rust applications, focusing on logging, configuration management, and templating.
๐ TOOLS & CONFIGURATION STRATEGY
graph TD
Start["Application Setup"] --> ConfigType{"Configuration<br>Complexity?"}
ConfigType -->|Simple| EnvVars["Environment Variables"]
ConfigType -->|Complex| YAMLConfig["YAML Configuration"]
EnvVars --> Logging["Logging Setup"]
YAMLConfig --> ConfigValidation["Configuration Validation"]
ConfigValidation --> Logging
Logging --> StructuredLogging["Structured Logging"]
StructuredLogging --> LogRotation["Log Rotation"]
LogRotation --> Templating{"Template<br>Engine Needed?"}
Templating -->|Yes| MiniJinja["MiniJinja Templates"]
Templating -->|No| DataProcessing["Data Processing"]
MiniJinja --> DataProcessing
DataProcessing --> JSONPath["JSON Path Extraction"]
JSONPath --> Monitoring["Application Monitoring"]
Monitoring --> Production["Production Tools"]
style Start fill:#4da6ff,stroke:#0066cc,color:white
style YAMLConfig fill:#4dbb5f,stroke:#36873f,color:white
style StructuredLogging fill:#ffa64d,stroke:#cc7a30,color:white
style MiniJinja fill:#d94dbb,stroke:#a3378a,color:white
๐ LOGGING AND OBSERVABILITY
Tracing Ecosystem (Not env_logger)
- Always use
tracing- modern structured logging - Combine with
tracing-subscriberfor output formatting - File rotation with
tracing-appenderfor production - Structured logging with spans and events
# Cargo.toml - Tracing configuration
[dependencies]
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
chrono = { version = "0.4", features = ["serde"] }
Structured Logging Setup
use tracing::{info, error, warn, debug, span, Level};
use tracing_subscriber::{
fmt::{self, time::ChronoUtc},
layer::SubscriberExt,
util::SubscriberInitExt,
EnvFilter,
Registry,
};
use tracing_appender::{non_blocking, rolling};
pub fn init_logging(config: &LogConfig) -> Result<(), Box<dyn std::error::Error>> {
// Create file appender with rotation
let file_appender = rolling::daily(&config.log_dir, "app.log");
let (file_writer, _guard) = non_blocking(file_appender);
// Console formatting
let console_layer = fmt::layer()
.with_target(true)
.with_timer(ChronoUtc::rfc_3339())
.with_level(true)
.with_thread_ids(true)
.with_thread_names(true);
// File formatting (JSON for structured logs)
let file_layer = fmt::layer()
.json()
.with_timer(ChronoUtc::rfc_3339())
.with_writer(file_writer);
// Environment filter
let filter = EnvFilter::try_from_default_env()
.unwrap_or_else(|_| EnvFilter::new(&config.level));
Registry::default()
.with(filter)
.with(console_layer)
.with(file_layer)
.init();
Ok(())
}
// Usage in application code
#[tracing::instrument(skip(service), fields(user_id = %user_id))]
pub async fn process_user_registration(
user_id: &str,
service: &UserService,
) -> Result<User, ServiceError> {
let span = span!(Level::INFO, "user_registration", user_id = %user_id);
let _enter = span.enter();
info!("Starting user registration process");
let user = service.create_user(user_id).await.map_err(|e| {
error!("Failed to create user: {}", e);
e
})?;
info!(
user_id = %user.id,
email = %user.email,
"User registration completed successfully"
);
Ok(user)
}
// Contextual logging with structured fields
pub async fn handle_payment_processing(
order_id: &str,
amount: f64,
payment_method: &str,
) -> Result<PaymentResult, PaymentError> {
let span = span!(
Level::INFO,
"payment_processing",
order_id = %order_id,
amount = %amount,
payment_method = %payment_method
);
let _enter = span.enter();
info!("Processing payment");
match process_payment(order_id, amount, payment_method).await {
Ok(result) => {
info!(
transaction_id = %result.transaction_id,
status = %result.status,
"Payment processed successfully"
);
Ok(result)
}
Err(e) => {
error!(
error = %e,
"Payment processing failed"
);
Err(e)
}
}
}
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 ยท 722 lines ยท 0 tokens per session scan A 8ea3b25675de
tools-and-config 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,960 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.
coolify-ai-docs
Master reference to all Coolify AI documentation in .ai/ directory.
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.
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.