mcpField
A
adversarial-rust

adversarial-rust

github.com/pproencaDevelopment21873 installsUpdated 11w ago
Repository

About adversarial-rust

adversarial-rust is a skill for architecture-level review and refactoring of existing Rust code that carries patterns from other programming paradigms. Its rules and examples are grounded in the codex-rs workspace, with guidance across ownership, types, errors, iteration, and concurrency.

Key features

  1. 01Architecture-level Rust review
  2. 02Refactoring guidance for ownership and types
  3. 03Result- and Option-based error flow
  4. 04Iteration and dispatch guidance
  5. 05Async concurrency review rules
  6. 06Examples grounded in codex-rs

Use cases

  1. 01Refactor Java-like patterns in Rust
  2. 02Untangle clone-heavy ownership designs
  3. 03Replace sentinel and unwrap-based error handling
  4. 04Review blocking and lock usage in async code

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pproenca/dot-skills --skill adversarial-rust

After installing, type/adversarial-rustin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

AGENTS.md
metadata.json
assets/templates/
_template.md
references/
_sections.md
arch-default-literal-over-builder.md
arch-drop-di-trait-single-impl.md
arch-free-functions-over-manager-struct.md
arch-no-deref-inheritance.md
arch-public-fields-over-getter-ceremony.md
conc-blocking-pool-over-async-cpu-fanout.md
conc-narrow-locks-before-await.md
conc-own-spawned-task-handles.md
conc-spawn-blocking-over-blocking-async.md
dyn-enum-over-box-dyn-closed-set.md
dyn-generics-over-boxed-callbacks.md
flow-no-catch-unwind-try-catch.md
flow-option-over-sentinel-values.md
flow-result-over-unwrap-expected.md
flow-thiserror-library-anyhow-application.md
iter-combinator-over-index-loop.md
iter-stay-lazy-single-collect.md
own-id-map-over-self-referential.md
own-no-rc-refcell-object-graph.md
own-restructure-over-clone.md
type-enum-over-bool-string-state.md
type-newtype-parse-dont-validate.md
type-result-over-parallel-options.md
type-split-option-god-struct.md

Details

From the project README

Adversarial Rust

An adversarial, architecture-level review-and-refactor pass for Rust. Where a greenfield idiom skill answers "which tool should I reach for now?", this skill takes code that already exists and imported the wrong mental model — objects and interfaces from Java/C#, shared-everything graphs from garbage-collected languages, exceptions, C-style loops and sentinels, detached-promise concurrency — names the paradigm it betrays, and prescribes the refactor that collapses it back to idiomatic Rust.

Every rule is grounded in a single production codebase: the codex-rs workspace (github.com/openai/codex, codex-rs/ at commit f1affbac5e, ~125 crates / ~2,500 Rust files). The Correct side of each rule is what that codebase actually does, the enforcement evidence is its workspace lint config (unwrap_used, redundant_clone, needless_collect, await_holding_lock and ~30 more denied), and the carve-outs are the real exceptions it keeps — so "when NOT to apply" is never hypothetical. There is no rule for things a capable model already gets right.

When to Apply

  • Reviewing or refactoring existing Rust for architecture, not just style — "make this actually idiomatic", "why does this feel like Java in Rust"
  • Flattening ported ceremony — dependency-injection traits with one implementation, Deref-simulated inheritance, stateless *Manager/*Service structs, getter/setter boilerplate, a builder for every struct
  • Untangling fought ownership — .clone() sprinkled until it compiles, Rc<RefCell<T>> object graphs, self-referential struct attempts
  • Fixing anemic data — boolean/string state machines, parallel Option fields, raw primitives carrying domain meaning, god-structs of Options escaping the serde boundary
  • Removing exception-style flow — unwrap on expected failures, sentinel returns, catch_unwind as try/catch, anyhow on library API surfaces
  • Collapsing habitual indirection — Box<dyn Trait> for closed sets, boxed callback parameters, index loops and per-step collect() chains
  • Repairing imported concurrency habits — blocking calls inside async fn, guards held across .await, async task fan-out for CPU-bound work, fire-and-forget tokio::spawn

For greenfield "which pattern, which crate, which discipline" decisions while writing new Rust — async cancellation, error enum design, sandboxing, testing architecture — use openai-codex-rust-patterns instead; this skill is its diagnostic, layer-flattening counterpart drawn from the same codebase.

Rule Categories

#CategoryPrefixThe alien model it rips out
1Enterprise Ceremony & Fake OOarch-DI traits, Deref inheritance, Manager structs, getter ceremony, reflexive builders → concrete types, delegation, module functions, public fields, struct literals
2Ownership Fought, Not Usedown-clone-to-compile, Rc graphs, self-referential structs → designed clones, owning ID-keyed maps, single owners
3Anemic & Stringly Datatype-bool/String states, parallel Options, raw primitives, escaped god-structs → data-carrying enums, newtypes, one wire-to-domain resolve
4Exception-Style Control Flowflow-unwrap-as-handling, sentinels, catch_unwind, opaque library errors → Result + ?, Option, thiserror enums, anyhow at the rim
5Dynamic Dispatch by Habitdyn-Box for closed sets, boxed callback params → tagged enums, generic Fn at the API, channels over listeners
6Imperative Iterationiter-index loops, mut accumulators, collect-per-step → named combinators, one lazy chain, collect into Result
7Concurrency From Another Runtimeconc-blocking in async, guards across await, async CPU fan-out, orphan spawns → spawn_blocking, narrowed locks, bounded thread pools, owned handles

Quick Reference

1. Enterprise Ceremony & Fake OO
2. Ownership Fought, Not Used
3. Anemic & Stringly Data
4. Exception-Style Control Flow
5. Dynamic Dispatch by Habit
6. Imperative Iteration
7. Concurrency From Another Runtime

How to Use

Read a reference file when its smell shows up in the code under review. Each rule names the alien pattern, explains why Rust rejects it, and shows the refactor with real codex-rs names and a permalink into the codebase at the pinned commit. Prefer the deepest refactor the change budget allows — redesigning ownership beats sprinkling clone; deleting the DI trait beats mocking through it. Every example compiles on Rust 1.86 (2021 edition).

Related Skills

  • openai-codex-rust-patterns — the greenfield counterpart distilled from the same codex-rs workspace: which pattern to reach for while writing production Rust (async cancellation, error enum design, sandboxing, testing, workspace layout). Use it for authoring decisions; use this skill for adversarial review and ceremony-flattening refactors. Several rules here hand off to it once the flatten is done (flow-thiserror-library-anyhow-application → its errors- rules, flow-result-over-unwrap-expected → defensive-deny-unwrap-workspace-wide, arch-drop-di-trait-single-impl → its testing seams).

Reference Files

FileDescription
references/_sections.mdCategory definitions and ordering
assets/templates/_template.mdTemplate for new rules
metadata.jsonVersion and source references

Comments

Markdown supported