adversarial-rust

Installation
SKILL.md

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

Installs
16
GitHub Stars
191
First Seen
Jul 13, 2026
adversarial-rust — pproenca/dot-skills