rust-optimization

rust-optimization is a skill for Claude Code, Codex from cacr92/WeReply. It costs 191 tokens per session (2,087 once invoked), scanned A, original, MIT.

A guide to making Rust programs run faster, use less memory, and handle calculations concurrently. Rust is a programming language, and concurrency means doing independent work at the same time.

In plain words
What is it for?
Use it to optimize Rust services and numerical programs with caching, parallel processing, fewer allocations, SIMD, asynchronous code, and solver or memory improvements.
Why use it?
It gives concrete approaches for reducing repeated database work, expensive calculations, unnecessary copying, and slow single-threaded processing.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/cacr92/wereply/rust-optimization
Any agent
npx skills add cacr92/WeReply --skill rust-optimization
Clone the repo
git clone --depth 1 https://github.com/cacr92/WeReply

Made for: Claude Code, Codex.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/cacr92/wereply/rust-optimization.svg)](https://agentmods.dev/skills/cacr92/wereply/rust-optimization)
Your own site
<a href="https://agentmods.dev/skills/cacr92/wereply/rust-optimization"><img src="https://agentmods.dev/badge/skills/cacr92/wereply/rust-optimization.svg" alt="Measured on agentmods" height="20"></a>
Per session 191 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,087 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00191 $0.02087
Opus 5 $0.00096 $0.01043
Sonnet 5 $0.00038 $0.00417
Haiku 4.5 $0.00019 $0.00209

Measured 3d ago against content hash 2a804d5c73ce, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

rust-optimization 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 3d 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.

.claude/skills/rust-optimization/SKILL.md · 357 lines

How it starts

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

Rust Optimization Skill

Advanced Rust optimization techniques for high-performance feed formula calculation and linear programming.

Performance Optimization Strategies

1. Caching Strategy (Moka)

Use moka::future::Cache for frequently accessed data:

use moka::future::Cache;
use std::time::Duration;

pub struct MaterialService {
    cache: Cache<String, Material>,
}

impl MaterialService {
    pub fn new() -> Self {
        Self {
            cache: Cache::builder()
                .max_capacity(1000)
                .time_to_live(Duration::from_secs(3600))
                .build(),
        }
    }

    pub async fn get_material(&self, code: &str) -> Result<Material> {
        self.cache
            .try_get_with(code.to_string(), async {
                self.repository.find_by_code(code).await
            })
            .await
    }
}

When to cache:

  • Database query results that don't change often
  • Computed nutrition values
  • Expensive calculation results
  • Reference data (materials, species standards)

2. Parallel Processing (Rayon)

Use rayon for CPU-intensive parallel computations:

use rayon::prelude::*;

pub fn calculate_nutrition_batch(
    materials: &[Material],
    proportions: &[f64],
) -> Vec<NutritionResult> {
    materials
        .par_iter()  // Parallel iterator
        .zip(proportions.par_iter())
        .map(|(material, proportion)| {
            calculate_material_nutrition(material, *proportion)
        })
        .collect()
}

Best practices:

  • Use parallel iterators for embarrassingly parallel problems
  • Benchmark to verify performance gains
  • Avoid parallelizing small operations (overhead costs)
  • Consider memory bandwidth limitations

3. Memory Optimization

Avoid Unnecessary Clones
// ❌ Bad - unnecessary clone
fn process(data: Vec<String>) -> Vec<String> {
    data.clone()
}

// ✅ Good - transfer ownership
fn process(data: Vec<String>) -> Vec<String> {
    data
}
Use References Where Possible
// ❌ Bad - takes ownership
fn calculate(materials: Vec<Material>) -> f64 {
    // ...
}

// ✅ Good - borrows data
fn calculate(materials: &[Material]) -> f64 {
    // ...
}

Read the full file on GitHub · 357 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 3d ago First seen · 357 lines · 191 tokens per session scan A 2a804d5c73ce

Subscribe to this mod's changes

rust-optimization is a skill published in the GitHub repository cacr92/WeReply (6 stars, last pushed 7mo ago), licensed MIT. It adds 191 tokens to every session and 2,087 once invoked, about $0.0010 per session on Opus 5. 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-31.

Related

Other skills, from other repositories

compiler-port

Port a compiler pass from TypeScript to Rust. Gathers context, plans the port, implements in a subagent with test-fix loop, then reviews.

react/react · 35 tokens

rust-code-quality

Run a focused Rust quality review when the user requests one, when reviewing a Rust PR/commit, or when another selected review workflow delegates Rust-specific checks. Do not auto-load for every implementation edit.

rustfs/rustfs · 44 tokens

crate-structure

The Xberg workspace layout — the version source of truth (root Cargo.toml [workspace.package] version), the 19 workspace members and 3 excluded crates, the distribution packages under packages/, the tools/ directory, and the ignore-file allowlists a new workspace member must be added to. Load when navigating the repo…

xberg-io/xberg · 83 tokens

rust-pro

Master modern Rust (2024 edition) with async patterns, advanced type system features, and production-ready systems programming. Expert in the current Rust ecosystem including Tokio, axum, and modern crates. Use PROACTIVELY for Rust development, performance optimization, or systems programming.

vudovn/ag-kit · 58 tokens

switchyard-rust-review

Review Switchyard Rust changes for correctness and maintainability. Use for pull requests or diffs touching crates, PyO3 bindings, async runtime behavior, streaming, protocol types, translation, algorithms, or LLM clients.

NVIDIA-NeMo/Switchyard · 50 tokens

hotpath_init

Configure hotpath profiling in a Rust project. Adds the hotpath dependency with feature-gated setup, instruments main with hotpath::main, functions with measure/measureall, and wraps channels, mutexes, rwlocks, streams, futures, reqwest clients, axum routers and byte-level I/O with hotpath macros. Use when the user…

pawurb/hotpath-rs · 88 tokens