tools-and-config

tools-and-config is a cursor rule for Cursor from tyrchen/cursor-rust-rules. It costs 0 tokens per session (4,960 once invoked), scanned A, original, MIT.

A set of Rust configuration and tooling guidelines covering environment variables, YAML files, logging, tracing, templates, JSON-path extraction, and monitoring.

In plain words
What is it for?
Use it when choosing configuration formats, setting up structured logs and tracing, rotating logs, processing data, or preparing application monitoring.
Why use it?
It gives developers a consistent way to configure Rust applications and understand what they are doing in production.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when choosing configuration formats, setting up structured logs and tracing, rotating logs, processing data, or preparing application monitoring.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/tyrchen/cursor-rust-rules/tools-and-config
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/tyrchen/cursor-rust-rules

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 tools-and-config

README.md
[![agentmods](https://agentmods.dev/badge/rules/tyrchen/cursor-rust-rules/tools-and-config/github.svg)](https://agentmods.dev/rules/tyrchen/cursor-rust-rules/tools-and-config)
Your own site
<a href="https://agentmods.dev/rules/tyrchen/cursor-rust-rules/tools-and-config"><img src="https://agentmods.dev/badge/rules/tyrchen/cursor-rust-rules/tools-and-config/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.

agentmods 80×15 button for tools-and-config

Your own site · 80×15
<a href="https://agentmods.dev/rules/tyrchen/cursor-rust-rules/tools-and-config"><img src="https://agentmods.dev/badge/rules/tyrchen/cursor-rust-rules/tools-and-config.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 4,960 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.04960
Opus 5.5 $0.00000 $0.01984
Sonnet 5.5 $0.00000 $0.00992
Haiku 4.5 $0.00000 $0.00496

Measured 1mo ago against content hash 8ea3b25675de, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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 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.

.cursor/rules/rust/features/tools-and-config.mdc · 722 lines

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-subscriber for output formatting
  • File rotation with tracing-appender for 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)
        }
    }
}

Read the full file on GitHub · 722 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. 1mo ago First seen · 722 lines · 0 tokens per session scan A 8ea3b25675de

Subscribe to this mod's changes

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.