Individual skill
openai-codex-rust-patterns
OpenAI Codex Rust coding patterns distilled from the codex-rs workspace. Use this skill whenever writing, reviewing, or refactoring Rust code — especially for async agents, CLI tools, sandboxing, secret handling, Ratatui TUIs, JSON-RPC protocols, tokio-based services, or any codebase that needs defensive panic discipline. Trigger even when the user does not explicitly mention Codex, because the patterns generalize to any production Rust workspace. Covers async cancellation, error enum design, process sandboxing, DNS-rebinding defense, credential hardening (zeroize/mlock/ctor), Cargo workspace architecture, wiremock-based fakes, insta snapshot testing, OpenTelemetry tracing, and Ratatui rendering.
skills/.experimental/openai-codex-rust-patterns/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
- Yes
- 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
- design Derived category
- operations Derived category
- writing Derived category
- testing 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 · 15,869 bytesREADME.mddoc · 4,830 bytesSKILL.mdcore · 14,946 bytesgotchas.mddoc · 2,492 bytesmetadata.jsonasset · 1,070 bytesreferences/_sections.mddoc · 4,166 bytesreferences/async-abort-on-drop-handle.mddoc · 2,230 bytesreferences/async-biased-select-for-cancellation.mddoc · 1,780 bytesreferences/async-bounded-vs-unbounded-channel-split.mddoc · 1,843 bytesreferences/async-child-cancellation-tokens.mddoc · 2,245 bytesreferences/async-graceful-then-forceful-cancel.mddoc · 1,995 bytesreferences/async-shared-boxfuture-joinhandle.mddoc · 1,931 bytesreferences/defensive-banned-interpreter-prefixes.mddoc · 2,085 bytesreferences/defensive-canonicalize-approval-cache-key.mddoc · 2,227 bytesreferences/defensive-debug-assert-with-early-return.mddoc · 1,625 bytesreferences/defensive-deny-unwrap-workspace-wide.mddoc · 1,748 bytesreferences/defensive-fault-isolate-plugin-load.mddoc · 2,284 bytesreferences/defensive-head-tail-output-buffer.mddoc · 2,456 bytesreferences/defensive-io-drain-timeout-grandchildren.mddoc · 2,357 bytesreferences/defensive-recover-poisoned-lock.mddoc · 1,985 bytesreferences/defensive-refuse-to-run-unsandboxed.mddoc · 2,044 bytesreferences/errors-boundary-error-translator.mddoc · 2,649 bytesreferences/errors-carry-retry-delay-in-variant.mddoc · 1,971 bytesreferences/errors-exhaustive-retryable-match.mddoc · 2,118 bytesreferences/errors-io-error-with-context-struct.mddoc · 2,446 bytesreferences/errors-struct-display-payload.mddoc · 2,379 bytesreferences/errors-tool-call-respond-vs-fatal.mddoc · 2,386 bytesreferences/errors-transient-permanent-type-split.mddoc · 1,922 bytesreferences/otel-field-empty-then-record.mddoc · 2,837 bytesreferences/otel-instrument-at-trace-level.mddoc · 2,799 bytesreferences/otel-layered-subscribers-env-filter.mddoc · 2,938 bytesreferences/otel-log-only-vs-trace-safe-targets.mddoc · 2,476 bytesreferences/otel-w3c-traceparent-propagation.mddoc · 3,264 bytesreferences/proto-double-option-tri-state.mddoc · 2,384 bytesreferences/proto-experimental-runtime-gate.mddoc · 2,509 bytesreferences/proto-internal-vs-wire-error-split.mddoc · 3,044 bytesreferences/proto-internally-tagged-rpc-dispatch.mddoc · 2,612 bytesreferences/proto-removed-feature-tombstone.mddoc · 1,904 bytesreferences/proto-rename-alias-wire-migration.mddoc · 1,946 bytesreferences/proto-sse-idle-timeout-terminator.mddoc · 2,467 bytesreferences/sandbox-argv0-multiplex-binary.mddoc · 2,122 bytesreferences/sandbox-dev-null-first-missing-mount.mddoc · 2,358 bytesreferences/sandbox-env-clear-pre-exec.mddoc · 2,270 bytesreferences/sandbox-resolve-before-allow-dns-rebinding.mddoc · 2,175 bytesreferences/sandbox-shared-policy-data-model.mddoc · 2,378 bytesreferences/sandbox-staged-restrictions-re-exec.mddoc · 2,211 bytesreferences/sandbox-three-layer-network-isolation.mddoc · 2,748 bytesreferences/secrets-ctor-pre-main-hardening.mddoc · 2,169 bytesreferences/secrets-manual-debug-elide.mddoc · 1,872 bytesreferences/secrets-read-into-locked-buffer.mddoc · 2,277 bytesreferences/testing-atomic-bool-test-opt-in.mddoc · 2,401 bytesreferences/testing-insta-snapshot-tui-rendering.mddoc · 2,590 bytesreferences/testing-path-attribute-sibling-tests.mddoc · 1,946 bytesreferences/testing-paused-runtime-advance.mddoc · 2,435 bytesreferences/testing-wiremock-sse-fakes.mddoc · 2,320 bytesreferences/tui-drop-guard-panic-hook-chain.mddoc · 2,397 bytesreferences/tui-event-broker-pause-resume.mddoc · 2,512 bytesreferences/tui-paste-burst-state-machine.mddoc · 2,743 bytesreferences/tui-schedule-frame-coalescer.mddoc · 2,647 bytesreferences/tui-two-gear-hysteresis-chunking.mddoc · 2,272 bytesreferences/types-non-exhaustive-public-enums.mddoc · 2,300 bytesreferences/types-thread-local-raii-serde.mddoc · 3,077 bytesreferences/types-try-from-newtype-validation.mddoc · 2,278 bytesreferences/types-unknown-variant-forward-compat.mddoc · 2,368 bytesreferences/workspace-ban-per-crate-features.mddoc · 2,172 bytesreferences/workspace-layered-transport-api-core.mddoc · 2,271 bytesreferences/workspace-lint-config-package.mddoc · 2,343 bytesreferences/workspace-test-support-as-member-crates.mddoc · 2,265 bytesreferences/workspace-utils-microcrate-fanout.mddoc · 2,402 bytes
Read excerpt
# OpenAI Codex Rust Best Practices
Distilled from [`openai/codex`](https://github.com/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.