skills/pproenca/dot-skills/openai-codex-rust-patterns

openai-codex-rust-patterns

Installation
SKILL.md

OpenAI Codex Rust Best Practices

Distilled from openai/codex codex-rs/ — a 72-crate, 1,418-file Rust workspace that ships the Codex CLI coding agent. Contains 60 rules across 10 categories, each citing the exact file in codex-rs where the pattern lives, so you can write Rust the way its top contributors (Michael Bolin, jif-oai, Ahmed Ibrahim, Eric Traut, Pavel Krymets) actually ship it.

When to Apply

Reference these guidelines when:

  • Writing or reviewing async Rust code that spawns tokio tasks, owns cancellation tokens, or manages long-lived background workers.
  • Designing error enums, Result flows, retry loops, or layer boundaries in a library or service.
  • Building a CLI tool that spawns subprocesses, enforces sandboxing, or runs LLM-generated code safely.
  • Architecting a Cargo workspace with more than ~5 crates, deciding what to split out, and how to manage shared dependencies.
  • Adding tests to a Rust codebase where existing tests are inline mod tests { ... } blocks and scaling is becoming painful.
  • Implementing a JSON-RPC or custom wire protocol with serde — especially one that must evolve without breaking clients.
  • Wiring OpenTelemetry traces, logs, or metrics into a service that has privacy constraints around PII.
  • Building a Ratatui-based TUI that streams LLM output, handles paste bursts, or manages raw-mode terminal state.
  • Hardening a binary against debugger attach, LD_PRELOAD, or environment-variable tampering.
  • Any time you find yourself reaching for .unwrap(), anyhow::Result<()>, or #[cfg(feature = "test")] — this skill explains what codex does instead.

Rule Categories by Priority

Priority Category Impact Prefix
1 Defensive Coding & Panic Discipline CRITICAL defensive-
2 Error Handling & Result Discipline CRITICAL errors-
3 Async, Concurrency & Cancellation HIGH async-
4 Sandboxing & Process Isolation HIGH sandbox-
5 Type Design & Invariants HIGH types-
6 Testing Architecture MEDIUM-HIGH testing-
7 Protocol & Serde Design MEDIUM-HIGH proto-
8 Workspace & Crate Organization MEDIUM workspace-
9 Observability & Tracing MEDIUM otel-
10 TUI (Ratatui) Rendering MEDIUM tui-

Quick Reference

1. Defensive Coding & Panic Discipline (CRITICAL)

2. Error Handling & Result Discipline (CRITICAL)

3. Async, Concurrency & Cancellation (HIGH)

4. Sandboxing & Process Isolation (HIGH)

5. Type Design & Invariants (HIGH)

6. Testing Architecture (MEDIUM-HIGH)

7. Protocol & Serde Design (MEDIUM-HIGH)

8. Workspace & Crate Organization (MEDIUM)

9. Observability & Tracing (MEDIUM)

10. TUI (Ratatui) Rendering (MEDIUM)

How to Use

Read individual reference files for detailed explanations and code examples cited from codex-rs/:

  • Section definitions — Category structure, impact levels, and prefixes
  • AGENTS.md — Auto-generated navigation document compiling every rule

Each rule file contains:

  • Imperative title matching its frontmatter
  • 2–4 sentence explanation of the WHY
  • Incorrect example showing the naive approach
  • Correct example from codex-rs with the file path cited

Reference Files

File Description
AGENTS.md Auto-built TOC document compiling every rule
README.md Skill repository docs — contribution, structure, commands
references/_sections.md Category definitions and ordering
gotchas.md Failure points discovered while applying these rules
metadata.json Version, discipline, references to codex-rs
Weekly Installs
57
GitHub Stars
131
First Seen
1 day ago