mcpField
O
openai-codex-rust-patterns

openai-codex-rust-patterns

github.com/pproencaDevelopment218209 installsUpdated 11w ago
Repository

About openai-codex-rust-patterns

A reference skill distilling Rust engineering patterns from OpenAI Codex’s codex-rs workspace. It helps Rust developers design and review async systems, CLIs, protocols, and larger workspaces using cited rules and examples.

Key features

  1. 0163 rules across 11 categories
  2. 02Citations to codex-rs source files
  3. 03Guidance on async and cancellation
  4. 04Sandboxing and secret-handling patterns
  5. 05Protocol, testing, and workspace design
  6. 06Ratatui TUI and tracing practices

Use cases

  1. 01Reviewing async Rust task and cancellation design
  2. 02Hardening CLI subprocesses and sandbox policies
  3. 03Designing evolvable serde-based protocols
  4. 04Organizing multi-crate Cargo workspaces

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pproenca/dot-skills --skill openai-codex-rust-patterns

After installing, type/openai-codex-rust-patternsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

AGENTS.md
gotchas.md
metadata.json
README.md
references/
_sections.md
async-abort-on-drop-handle.md
async-biased-select-for-cancellation.md
async-bounded-vs-unbounded-channel-split.md
async-child-cancellation-tokens.md
async-graceful-then-forceful-cancel.md
async-shared-boxfuture-joinhandle.md
defensive-banned-interpreter-prefixes.md
defensive-canonicalize-approval-cache-key.md
defensive-debug-assert-with-early-return.md
defensive-deny-unwrap-workspace-wide.md
defensive-fault-isolate-plugin-load.md
defensive-head-tail-output-buffer.md
defensive-io-drain-timeout-grandchildren.md
defensive-recover-poisoned-lock.md
defensive-refuse-to-run-unsandboxed.md
errors-boundary-error-translator.md
errors-carry-retry-delay-in-variant.md
errors-exhaustive-retryable-match.md
errors-io-error-with-context-struct.md
errors-struct-display-payload.md
errors-tool-call-respond-vs-fatal.md
errors-transient-permanent-type-split.md
otel-field-empty-then-record.md
otel-instrument-at-trace-level.md
otel-layered-subscribers-env-filter.md

Details

From the project README

OpenAI Codex Rust Best Practices

Distilled from openai/codex codex-rs/ — a 119-crate, 2,008-file Rust workspace that ships the Codex CLI coding agent. Contains 63 rules across 11 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. Citations were refreshed against main at commit 8a94430 (2026-05-25).

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.
  • Reading API keys or other secrets into memory, or hardening a binary that handles credentials against core dumps, debugger attach, and LD_PRELOAD.
  • Enforcing a network egress allowlist that must survive DNS rebinding, or loading untrusted plugins/extensions.
  • 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.
  • Any time you find yourself reaching for .unwrap(), .lock().unwrap(), anyhow::Result<()>, or #[cfg(feature = "test")] — this skill explains what codex does instead.

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Defensive Coding & Panic DisciplineCRITICALdefensive-
2Error Handling & Result DisciplineCRITICALerrors-
3Async, Concurrency & CancellationHIGHasync-
4Sandboxing & Process IsolationHIGHsandbox-
5Secrets & Process HardeningHIGHsecrets-
6Type Design & InvariantsHIGHtypes-
7Testing ArchitectureMEDIUM-HIGHtesting-
8Protocol & Serde DesignMEDIUM-HIGHproto-
9Workspace & Crate OrganizationMEDIUMworkspace-
10Observability & TracingMEDIUMotel-
11TUI (Ratatui) RenderingMEDIUMtui-

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. Secrets & Process Hardening (HIGH)
6. Type Design & Invariants (HIGH)
7. Testing Architecture (MEDIUM-HIGH)
8. Protocol & Serde Design (MEDIUM-HIGH)
9. Workspace & Crate Organization (MEDIUM)
10. Observability & Tracing (MEDIUM)
11. 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

FileDescription
AGENTS.mdAuto-built TOC document compiling every rule
README.mdSkill repository docs — contribution, structure, commands
references/_sections.mdCategory definitions and ordering
gotchas.mdFailure points discovered while applying these rules
metadata.jsonVersion, discipline, references to codex-rs

Comments

Markdown supported