Individual skill
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 greenfield idiom advice — it names the paradigm the code betrays and prescribes the deep refactor that collapses it, up to deleting whole layers (single-impl DI traits, Deref inheritance, Manager/Service structs, reflexive builders, Rc<RefCell> webs, clone-until-it-compiles, bool/String state machines, sentinel returns, catch_unwind try/catch, reflexive Box<dyn>, blocking calls inside async, fire-and-forget spawns). Every rule is grounded in the codex-rs production workspace (openai/codex) — the prescriptions are what that codebase actually does and lint-enforces. Applies whenever the work is "make this Rust actually Rust", "flatten this architecture", or a pedantic review of code fighting the language.
skills/.experimental/adversarial-rust/SKILL.md
Source commit cf93c57cac89d6fc3e4194686000411567f5caf3
What was checked
- Matches the observed repository HEAD
- Yes
- Scanner rules are current
- No
- Repository scan complete
- No
- Skill scan complete
- No
- Observed behavior
- Not checked yet
- Last checked
- Nov 5, 2026
These are observations at the recorded commit, not a guarantee of safety. Review the source before running it.
Install this skill
Choose an agent in your Stack or copy a command below. Commands fetch the pinned commit and copy only this skill directory. Existing destinations are refused. Copying a command does not install anything.
An install command is unavailable: current rules, complete repository and skill scans, an eligible behavior level and a permitted license are required.
Repository context
- Repository stars (not skill ratings)
- 222
- Repository last updated
- Aug 15, 2026
- License
- MIT
Observed agent integration: codex
- engineering Derived category
Files and excerpt
File metadata and permitted, redacted excerpts come from the recorded scan. Source links are pinned to that commit.
Browse files
AGENTS.mddoc · 8,959 bytesSKILL.mdcore · 11,365 bytesSKILL.mdcore · 11,365 bytesassets/templates/_template.mddoc · 1,277 bytesmetadata.jsonasset · 3,049 bytesreferences/_sections.mddoc · 5,936 bytesreferences/arch-default-literal-over-builder.mddoc · 1,875 bytesreferences/arch-drop-di-trait-single-impl.mddoc · 2,723 bytesreferences/arch-free-functions-over-manager-struct.mddoc · 2,241 bytesreferences/arch-no-deref-inheritance.mddoc · 2,485 bytesreferences/arch-public-fields-over-getter-ceremony.mddoc · 2,216 bytesreferences/conc-blocking-pool-over-async-cpu-fanout.mddoc · 2,829 bytesreferences/conc-narrow-locks-before-await.mddoc · 2,915 bytesreferences/conc-own-spawned-task-handles.mddoc · 3,256 bytesreferences/conc-spawn-blocking-over-blocking-async.mddoc · 2,814 bytesreferences/dyn-enum-over-box-dyn-closed-set.mddoc · 2,960 bytesreferences/dyn-generics-over-boxed-callbacks.mddoc · 2,796 bytesreferences/flow-no-catch-unwind-try-catch.mddoc · 2,847 bytesreferences/flow-option-over-sentinel-values.mddoc · 2,526 bytesreferences/flow-result-over-unwrap-expected.mddoc · 2,630 bytesreferences/flow-thiserror-library-anyhow-application.mddoc · 2,900 bytesreferences/iter-combinator-over-index-loop.mddoc · 2,660 bytesreferences/iter-stay-lazy-single-collect.mddoc · 2,785 bytesreferences/own-id-map-over-self-referential.mddoc · 2,389 bytesreferences/own-no-rc-refcell-object-graph.mddoc · 2,229 bytesreferences/own-restructure-over-clone.mddoc · 2,727 bytesreferences/type-enum-over-bool-string-state.mddoc · 2,624 bytesreferences/type-newtype-parse-dont-validate.mddoc · 2,628 bytesreferences/type-result-over-parallel-options.mddoc · 2,263 bytesreferences/type-split-option-god-struct.mddoc · 2,818 bytes
Read excerpt
# 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 `Option`s 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