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…
от pproenca★ 231 звезда на GitHubОб этом скилле
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/*Servicestructs, 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
Optionfields, raw primitives carrying domain meaning, god-structs ofOptions escaping the serde boundary - Removing exception-style flow —
unwrapon expected failures, sentinel returns,catch_unwindas try/catch,anyhowon library API surfaces - Collapsing habitual indirection —
Box<dyn Trait>for closed sets, boxed callback parameters, index loops and per-stepcollect()chains - Repairing imported concurrency habits — blocking calls inside
async fn, guards held across.await, async task fan-out for CPU-bound work, fire-and-forgettokio::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
| # | Category | Prefix | The alien model it rips out |
|---|---|---|---|
| 1 | Enterprise Ceremony & Fake OO | arch- |
DI traits, Deref inheritance, Manager structs, getter ceremony, reflexive builders → concrete types, delegation, module functions, public fields, struct literals |
| 2 | Ownership Fought, Not Used | own- |
clone-to-compile, Rc |
| 3 | Anemic & Stringly Data | type- |
bool/String states, parallel Options, raw primitives, escaped god-structs → data-carrying enums, newtypes, one wire-to-domain resolve |
| 4 | Exception-Style Control Flow | flow- |
unwrap-as-handling, sentinels, catch_unwind, opaque library errors → Result + ?, Option, thiserror enums, anyhow at the rim |
| 5 | Dynamic Dispatch by Habit | dyn- |
Box |
| 6 | Imperative Iteration | iter- |
index loops, mut accumulators, collect-per-step → named combinators, one lazy chain, collect into Result |
| 7 | Concurrency From Another Runtime | conc- |
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
arch-drop-di-trait-single-impl— delete the DI trait with one implementation; codex-rs shipsModelClientandSessionconcretearch-no-deref-inheritance— all 18 codex-rsDerefimpls are newtypes or smart pointers; zero simulate a hierarchyarch-free-functions-over-manager-struct— stateless capability = module functions (git-utils,apply-patch); a*Managerearns its name by owning statearch-public-fields-over-getter-ceremony—Configand every protocol type are all-pub; accessors exist only where an invariant livesarch-default-literal-over-builder— 1,787 struct literals with..Default::default()vs 16 builders; a builder needs staged construction to earn itself
2. Ownership Fought, Not Used
- [
own-restructure-over-clone](references/own-r
Установить adversarial-rust в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл 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.
Как установить скилл adversarial-rust?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл adversarial-rust запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic