Rust Core Engineering
Rust core engineering guidance for production services, language-level code, and reusable libraries, including testing, persistence, ownership, traits, iterators, concurrency, async, unsafe, FFI, security, deployment, SQLx, observability, benchmarking, feature flags, rustdoc, and crate publishing.
Included Skills
Use when adding, changing, testing, or debugging Rust HTTP APIs and services, especially when Codex needs black-box integration tests, random-port app startup, real database test isolation, external HTTP mocks, or CI-ready cargo verification for Actix, Axum, Warp, Rocket, or similar Rust web frameworks.
Design and review Rust async code around task ownership, suspension points, cancellation, blocking work, and runtime boundaries. Use when writing, refactoring, or reviewing futures, async functions, Tokio tasks, spawn, JoinHandle, Send futures, async traits, cancellation, or mutexes across await points.
Design and review thread-based Rust concurrency with explicit ownership, sharing, and synchronization choices. Use when writing, refactoring, or reviewing threads, scoped threads, channels, Arc, Mutex, RwLock, Condvar, atomics, OnceLock, LazyLock, Send, Sync, deadlocks, or shared state.
Prepare Rust crates for publishing with Cargo metadata, versioning, README and license checks, package dry-runs, feature verification, docs.rs readiness, examples, changelog notes, and secret-safe release gates. Use before cargo publish, crate release PRs, or sharing a reusable Rust library.
Use when preparing, containerizing, configuring, testing, or reviewing Rust services for deployment, especially Docker multi-stage builds, runtime configuration, environment overrides, secrets, health checks, SQLx offline builds, release profiles, image-size reduction, or production startup validation.
Use when modeling, validating, refactoring, or reviewing Rust service domain boundaries, especially when replacing primitive String fields with newtypes, parse-don't-validate constructors, private invariants, TryFrom/FromStr parsers, request DTO boundaries, or property tests.
Use when adding, changing, debugging, or reviewing Rust service error handling and observability, especially when separating domain errors from HTTP responses, adding thiserror/anyhow, implementing ResponseError or IntoResponse, adding tracing spans, redacting secrets, or diagnosing async failures.
Design and review Rust FFI boundaries that keep raw declarations isolated behind safe ownership, lifetime, error, and cleanup wrappers. Use when writing, refactoring, or reviewing unsafe extern blocks, C ABI wrappers, repr(C) types, CString, CStr, raw handles, Drop cleanup, bindgen, cbindgen, or panic-safe foreign boundaries.
Use when designing, implementing, testing, or debugging Rust service workflows that must be safe under retries, duplicate requests, crashes, concurrent submissions, background workers, queues, email/payment/notification side effects, idempotency keys, transaction isolation, or save-and-replay API behavior.
Design and review Rust iterator pipelines and collection code for clear ownership, allocation, ordering, and error behavior. Use when writing, refactoring, or reviewing iterators, HashMap Entry usage, collect, FromIterator, Extend, custom iterators, or allocation-heavy loops.
Optimize Rust libraries with criterion benchmarks, feature-flag matrices, cargo bench workflows, dependency gating, regression baselines, and evidence-driven API performance tradeoffs. Use when adding or reviewing Rust library benchmarks, cargo features, optional dependencies, or performance claims before publishing.
Design and review Rust ownership, borrowing, lifetimes, and interior mutability so data flow matches the domain model. Use when writing, refactoring, or reviewing Rust code that hits move, borrow checker, aliasing, Clone, Copy, Rc, Arc, RefCell, or lifetime problems.
Use when adding, changing, testing, or reviewing security-sensitive Rust web service behavior, especially login flows, password hashing, credential checks, session cookies, flash messages, admin route protection, auth middleware, user enumeration defenses, or moving CPU-heavy password work off async executors.
Use when adding, changing, testing, or reviewing Postgres persistence in Rust services that use sqlx, especially when designing migrations, query! or query_as! calls, PgPool injection, transactions, compile-time checked SQL, SQLx offline mode, repository boundaries, or database-backed integration tests.
Design and review Rust trait APIs, generic bounds, dispatch models, and conversion contracts for clear public interfaces. Use when designing, refactoring, or reviewing traits, generics, trait objects, associated types, impl Trait, From/TryFrom, AsRef, Borrow, or crate APIs.
Isolate and review unsafe Rust behind small, documented, testable boundaries with explicit invariants. Use when writing, refactoring, or reviewing unsafe code, raw pointers, unsafe functions, unsafe traits, MaybeUninit, pointer aliasing, panic safety, Miri checks, or safe abstractions over unsafe internals.
Write and review Rust library documentation with rustdoc module docs, public API examples, doctests, examples directories, missing-docs gates, docs.rs readiness, and user-first crate narratives. Use when documenting a Rust crate, improving docs before publishing, or turning examples into tested rustdoc.