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. Also seen: installed under .agents/ (shared by several agents).

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.5 $0.00018 $0.00301
Sonnet 5.5 $0.00009 $0.00151
Haiku 4.5 $0.00004 $0.00075

Measured 3mo ago against content hash 6077ff0a7f91, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 3mo 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.

.agents/skills/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. 3mo 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.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

rust-anti-patterns compared with skills from other repositories

rust-anti-patterns next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
rust-anti-patternsheyAyushh/staccSkill32mo agoMITA44Claude Code, Codex
rust-best-practicesbgauryy/octocodeSkill977todayMITA47Claude Code, Codex
rust-skillsleonardomso/rust-skillsSkill8019d agoMITA56Claude Code, Codex
cargo-fallowfallow-rs/fallow-skillsSkill146todayMITA104Claude Code, Codex
laravel-rust-best-practicesAsyrafHussin/agent-skillsSkill1182d agoMITA236Claude Code, Codex
rust-for-laravel-developersAsyrafHussin/agent-skillsSkill1182d agoMITA229Claude Code, Codex
laravel-php-to-rustAsyrafHussin/agent-skillsSkill1182d agoMITA185Claude Code, Codex