rust-anti-patterns

rust-anti-patterns is a skill for Claude Code, Codex from heyAyushh/stacc. It costs 44 tokens per session (753 once invoked), scanned A, original, MIT.

A code-review guide to common Rust mistakes, such as unnecessary cloning, unsafe convenience code, unchecked unwrapping, and awkward ownership patterns.

In plain words
What is it for?
Use it to review Rust code and replace beginner anti-patterns with references, iterators, clearer ownership, and safer error handling.
Why use it?
It helps find code that may hide design problems, waste resources, cause panics, or make the program harder to maintain.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to review Rust code and replace beginner anti-patterns with references, iterators, clearer ownership, and safer error handling.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/heyayushh/stacc/anti-patterns
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.

Any agent
npx skills add heyAyushh/stacc --skill anti-patterns
Clone the repo
git clone --depth 1 https://github.com/heyAyushh/stacc

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-anti-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/heyayushh/stacc/anti-patterns/github.svg)](https://agentmods.dev/skills/heyayushh/stacc/anti-patterns)
Your own site
<a href="https://agentmods.dev/skills/heyayushh/stacc/anti-patterns"><img src="https://agentmods.dev/badge/skills/heyayushh/stacc/anti-patterns/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 rust-anti-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/heyayushh/stacc/anti-patterns"><img src="https://agentmods.dev/badge/skills/heyayushh/stacc/anti-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 753 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.00044 $0.00753
Opus 5 $0.00022 $0.00377
Sonnet 5 $0.00009 $0.00151
Haiku 4.5 $0.00004 $0.00075

Measured 9d ago against content hash 6077ff0a7f91, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

rust-anti-patterns 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 9d 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.

configs/stacks/rust/anti-patterns/SKILL.md · 96 lines

How it starts

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

Anti-Patterns

Layer 2: Design Choices

Core Question

Is this pattern hiding a design problem?

When reviewing code:

  • Is this solving the symptom or the cause?
  • Is there a more idiomatic approach?
  • Does this fight or flow with Rust?

Top 5 Beginner Mistakes

Rank Mistake Fix
1 Clone to escape borrow checker Use references
2 Unwrap in production Propagate with ?
3 String for everything Use &str
4 Index loops Use iterators
5 Fighting lifetimes Restructure to own data

Anti-Pattern Reference

Anti-Pattern Why Bad Better
.clone() everywhere Hides ownership issues Proper references or ownership
.unwrap() in production Runtime panics ?, expect, or matching
Rc when single owner Unnecessary overhead Simple ownership
unsafe for convenience UB risk Find safe pattern
OOP via Deref Misleading API Composition, traits
Giant match arms Unmaintainable Extract to methods
String everywhere Allocation waste &str, Cow<str>
Ignoring #[must_use] Lost errors Handle or let _ =

Code Smell → Refactoring

Smell Indicates Refactoring
Many .clone() Ownership unclear Clarify data flow
Many .unwrap() Error handling missing Add proper handling
Many pub fields Encapsulation broken Private + accessors
Deep nesting Complex logic Extract methods
Long functions Multiple responsibilities Split
Giant enums Missing abstraction Trait + types

Quick Review Checklist

  • No .clone() without justification
  • No .unwrap() in library code
  • No pub fields with invariants
  • No index loops when iterator works
  • No String where &str suffices
  • No ignored #[must_use] warnings
  • No unsafe without // SAFETY: comment
  • No giant functions (>50 lines)

Read the full file on GitHub · 96 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. 9d ago First seen · 96 lines · 44 tokens per session scan A 6077ff0a7f91

Subscribe to this mod's changes

rust-anti-patterns is a skill published in the GitHub repository heyAyushh/stacc (3 stars, last pushed 2mo ago), licensed MIT. It adds 44 tokens to every session and 753 once invoked, about $0.0002 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-09-03.

Related

Other skills, from other repositories

architecture-audit

Systematic architecture audit and refactoring methodology for Rust + TypeScript codebases. Use when performing refactoring, cleanup, unification, code review, dead code removal, module reorganization, or tech debt elimination. Ensures no naming confusion, semantic overloading, hidden defaults, duplicate logic, or…

org2AI/ORG2 · 70 tokens

rust-review

A Rust code-review skill for services, checking for crashes, unsafe SQL construction, exposed credentials, ignored errors, and unfinished code.

liuyanghejerry/Clausura · 25 tokens

rust-skills

Comprehensive Rust coding guidelines with 265 rules across 26 categories. Use when writing, reviewing, or refactoring Rust code. Covers ownership, error handling, async patterns, concurrency, unsafe code, API design, memory optimization, performance, numeric safety, conversions, serde, pattern matching, macros…

leonardomso/rust-skills · 84 tokens

writing-rust

Idiomatic Rust development. Use when writing Rust code, Cargo crates/workspaces, Rust tests, or rustfmt/clippy/cargo workflows. Emphasizes ownership, Result errors, small APIs, stdlib-first dependencies, fast cargo feedback, and behavior tests. NOT for Go, Python, TypeScript, shell scripts, or infra-only work.

alexei-led/cc-thingz · 73 tokens

adversarial-rust

Use this skill when reviewing or refactoring existing Rust code that carries an alien mental model — OO/enterprise ceremony from Java/C#, garbage-collected object graphs, exception-style control flow, or imperative loops ported onto the borrow checker. It is the adversarial, architecture-level counterpart to…

pproenca/dot-skills · 223 tokens

m15-anti-pattern

Use when reviewing code for anti-patterns. Keywords: anti-pattern, common mistake, pitfall, code smell, bad practice, code review, is this an anti-pattern, better way to do this, common mistake to avoid, why is this bad, idiomatic way, beginner mistake, fighting borrow checker, clone everywhere, unwrap in production…

moeru-ai/auv · 101 tokens