po4yka
Useragent skills for production Rust — unsafe, atomics, FFI/JNI/UniFFI, sanitizers, profiling, supply chain, etc
Categories
Indexed Skills (33)
cargo-workflows
Use when you manage a Rust workspace - add or remove crates, edit workspace dependencies and lints, pin the toolchain, run cargo nextest/audit/deny, configure Cargo profiles and rustflags for cross-compilation to Android or iOS, build cdylib or staticlib FFI artifacts, wire a host build system to cargo, debug Cargo.lock churn or feature-unification surprises, or migrate the crate edition.
ffi-error-progress-cancel
Use when you design or review an FFI boundary for a long-running Rust operation that must report typed errors, stream progress, and cancel cooperatively - import, indexing, preview, render, export, or any job longer than one frame. Covers a closed versioned boundary error taxonomy, UniFFI flat error enums, mapping stable error codes to native UX buckets, redaction so no backtrace or filesystem path crosses the boundary, callback-interface progress listeners carrying job id plus stage and fraction, bridges to Kotlin Flow with callbackFlow and awaitClose and to Swift AsyncThrowingStream with onTermination, and wiring coroutine cancel and Task cancel down to an idempotent non-blocking cancel_job. Triggers on flat_error, callback interface, callbackFlow, awaitClose, trySend, AsyncThrowingStream, CancellationException, CancellationError, cancel_job, job_id, progress event, or "the UI must not show stack traces".
memory-model
Use when you write or review Rust atomic operations, lock-free data structures, or publish/subscribe flags, when you choose between Ordering::Relaxed, Acquire, Release, AcqRel and SeqCst, when you place atomic fences, when you declare or review global state, or when you diagnose a data race that appears only on weakly ordered targets such as ARM64. Covers happens-before reasoning, valid orderings per operation, counter and stop-flag and publish patterns, compare-exchange rules, the choice between const, static, OnceLock, LazyLock and thread_local!, common ordering mistakes, and verification with Miri and loom. Triggers on "global variable", "global state", "static mut", "global static", "OnceLock", "LazyLock", "thread_local", "lazy_static", "once_cell", or any memory ordering question.
rust-android-build
Use when you build, verify, or package a Rust cdylib for Android - install cross-compilation targets, set up the NDK toolchain, write per-ABI rustflags in .cargo/config.toml, enforce 16 KiB page alignment, tune a size-optimized release profile, audit the exported ELF symbol set, hold .so size budgets, or drive the cargo build from a Gradle task that produces jniLibs.
rust-async-internals
Use when you author or review async Rust that can be polled inside tokio::select!, tokio::time::timeout, JoinSet, or FuturesUnordered; when you bridge a foreign thread into a runtime with block_on; when you configure a tokio runtime for a constrained target; when you design CancellationToken parent/child shutdown trees; when you choose between spawn_blocking, block_in_place, and std::thread::spawn; when you poll a future by hand from a synchronous event loop; or when you audit for std::sync::Mutex-across-await deadlocks, broadcast Lagged data loss, !Send futures, and cancel-safety bugs. Triggers on "select", "join", "spawn", "cancellation", "tokio runtime", "block_on", "async fn in traits", "task stall", "shutdown hang", or "async hang".
rust-callback-bounds
Use when you shape a callable in a public signature — a callback bound such as Fn(&T) -> K, a key projection, a visitor, or a struct field that holds a closure. Covers which bound accepts which closure, why for<'a> FnMut(&'a T) -> &'a K compiles today while a free type parameter cannot name the higher-ranked lifetime, HRTB as a no-escape promise, closure signature inference by syntactic position, the E0309 E0621 E0502 cascade that follows from hoisting a lifetime, and the cost table for a generic F field against Box<dyn Fn> and a bare fn pointer field. Triggers on "lifetime may not live long enough" from a closure, "one type is more general than the other", "borrowed data escapes outside of closure", "for<'a>", "hrtb", "sort_by_key", "callback returns a reference", "store a closure in a struct", "Box<dyn Fn>", "fn pointer field", "E0747", "E0562", "Arc<dyn Fn>", "reached the recursion limit while instantiating", or "function item types cannot be named directly".
rust-code-style
Rust source layout and readability rules — module file layout, lib.rs re-export policy, visibility levels, item order inside a file, import grouping, function structure, error-handling crate choice, and naming. Use when you create a module or a crate, add or move a source file, decide what to make pub, order items in a file, clean up imports, or review a diff for structure and readability.
rust-compiler-errors
Use when rustc or cargo reports a numbered error and you need the cause rather than the first fix that compiles. Covers ownership and move errors (E0382, E0505, E0507, E0509), borrow conflicts (E0499, E0502, E0596), lifetime errors (E0597, E0716, E0515, E0521, E0106), trait and type errors (E0038, E0277, E0271, E0308, E0599, E0631, E0275), Drop impl errors (E0184, E0367, E0740), the unnumbered Send error on a future, resolution errors (E0433, E0425, E0603), and layout errors (E0072, E0793). States which reflexive fix hides the bug and which one resolves it. Triggers on any "E0" code that no topic skill owns (E0207 is rust-iterator-impl, E0793 is rust-unsafe, Send and Sync go to rust-send-sync), "borrow checker", "value moved", "does not live long enough", "cannot borrow", "missing lifetime specifier", "trait bound not satisfied", "not dyn compatible", "dyn compatibility", "object safety", "overflow evaluating the requirement", or a paste of a cargo build failure.
rust-copy-on-write
Use when you decide between borrowed and owned data at an API boundary, or when clone cost drives a data-structure choice. Covers Cow in return and argument position and the hit-rate rule that decides it, the to_mut double-allocation trap and its permanent flip to Owned, the lifetime a Cow struct field forces on every caller (E0515, E0521) and the into_static exit, why a Cow-backed &self -> Self API is quadratic instead of persistent, measured build, clone and index costs for Vec against the im, imbl and rpds persistent collections, the rpds !Send default, and the im RustSec advisories. Not for a profile that already names an allocation site. Triggers on "Cow", "copy-on-write", "Cow<str>", "to_mut", "into_owned", "borrowed or owned", "borrow or clone", "clone cost", "persistent collection", "immutable data structure", "structural sharing", "the im crate", "imbl", "rpds", or "zero-copy string parse".
rust-crate-architecture
Use when you add, split, merge, rename, or remove a crate in a Rust workspace, when you define or enforce dependency layers and direction rules, when you decide whether new code belongs in a new crate or an existing module, when you restructure a workspace after a layering violation or a dependency cycle between normal crates, or when you lay out modules inside a crate that grew too large. A cyclic package dependency that involves a proc-macro crate belongs to rust-macros.
rust-debugging
Use when you debug a native Rust crash, panic, or hang across an FFI boundary. Covers host-first reproduction with RUST_BACKTRACE, rust-lldb and rust-gdb, Android logcat filtering, tombstone analysis, symbolication with llvm-addr2line and atos, LLDB attach from Android Studio and Xcode, panic hooks that work without RUST_BACKTRACE, catch_unwind at JNI exports, UniFFI panic and error propagation into Kotlin and Swift, tracing spans routed to logcat, tokio-console for async stalls, and a panic-to-cause triage table. Triggers on "native crash", "tombstone", "addr2line", "RUST_BACKTRACE", "lldb-server", "JNI panic", "UniFFI panic", "rust-gdb pretty-printers", or "debug async Rust".
rust-discipline
Rust code discipline for API design, anti-patterns, error propagation, RAII and Drop, allocation in hot paths, concurrency primitive choice, atomic ordering, unsafe encapsulation, FFI panic containment, and lint non-regression. Use when you author or review pub and pub(crate) signatures, struct definitions, and trait bounds, during code review or pre-merge self-check, and when you tighten existing Rust code.
rust-event-loop-state
Use when you design or review an event loop, tick loop, or handler registry whose handlers all need &mut to one shared mutable state - a game loop, a TUI loop, or any god object every handler writes to. Covers the decision table that picks the structure from the shape of the handler set, why the loop must own the handler set and the state separately (E0499, E0502), state as a trait generic parameter instead of an associated type (E0207), capability bounds plus one Vec<Box<dyn Handler<App>>>, the blanket-impl one-way door (E0119), why DerefMut on a context wrapper destroys disjoint-field borrows, when an ECS-shaped dynamic world earns its run-time conflict panic, and why async fn(&mut State) and nightly coroutine resume arguments cannot express a suspendable routine over shared state. Triggers on "event loop", "tick loop", "handler registry", "shared mutable state", "god object", "ECS", "system and world", "Rc<RefCell> between handlers", "E0499 in my dispatch loop", or "coroutine resume".
rust-hot-path
Use after a profiler names a hotspot, when you must decide what to change in the code rather than which tool to run. Covers allocation rate (Vec growth, with_capacity, reserve_exact, clone_from, workhorse buffers, format! in a loop), type size (print-type-sizes, the memcpy boundary, boxing a large enum variant, Box<[T]> and ThinVec, repr(C) padding), hasher choice with the HashDoS gate, iterators and size_hint, bounds check removal, inline attributes and cold paths, and buffered I/O. Also covers pinning the win with a const size assert and a dhat allocation test. Triggers on "reduce allocations", "too many allocations", "this type is too big", "large_enum_variant", "which hasher", "FxHashMap", "bounds check", "inline always", "cold path", "BufWriter", "clone_from", "SmallVec", "swap_remove", or any question about what to change once a hot path is known.
rust-iterator-impl
Use when you write the producing side of iteration for your own type, including a hand-written Iterator impl, the three IntoIterator impls for a container, FromIterator, Extend, size_hint, and an adapter chain that fails on a trait bound. Covers the unconditional_recursion stack overflow from self.into_iter(), why a Deref newtype still gets no for loop and no collect, E0207 on a lending iterator that borrows from itself, the ExactSizeIterator len panic, why enumerate().rev() needs ExactSizeIterator while rev().enumerate() renumbers the indices, and std::iter::from_fn in place of nightly gen blocks. Triggers on "implement Iterator", "custom iterator", "IntoIterator", "into_iter", "FromIterator", "Extend", "size_hint", "ExactSizeIterator", "DoubleEndedIterator", "next_back", "lending iterator", "iter::from_fn", "gen block", "enumerate().rev()", "E0207", or "unconditional_recursion".
rust-jni
Use when you export a Rust function to the JVM with the jni crate, write or change Kotlin external fun bindings, choose between raw JNI and UniFFI, or triage a JNI linkage error or a native crash on Android. Covers Java_package_class_method symbol naming, no_mangle plus extern system, panic containment at every export, AttachCurrentThread and DetachCurrentThread discipline for worker threads, 16-slot local-reference frames and with_local_frame, why JNIEnv must never cross an await point, JByteArray copies versus DirectByteBuffer and file-descriptor handoff on hot paths, Kotlin and Rust type mapping, Java exception throwing and exception_check, session-handle lifecycle contracts, and a triage table for UnsatisfiedLinkError, JNI DETECTED ERROR, and local-reference-table overflow. Triggers on JNI, external fun, no_mangle, JNIEnv, AttachCurrentThread, local ref, GlobalRef, UnsatisfiedLinkError, or native crash on Android.
rust-lints
Canonical workspace-level Rust lint configuration - workspace.lints, clippy.toml, rustfmt.toml and deny.toml - together with the workflows to add a crate that inherits them, tighten a lint safely, justify a suppression, and triage a lint or supply-chain failure. Use when you edit workspace lint sections, add a new crate, choose the level for a clippy or rustc lint, review an allow or expect attribute, or debug why clippy, rustfmt or cargo-deny fails.
rust-macros
Use when you write or debug a Rust macro — a macro_rules! declarative macro, a derive macro, an attribute macro, or the crate split that ships one. Covers textual scope, macro_use and macro_export, $crate, macro hygiene, fragment specifiers and follow-set restrictions, the recursion limit, format strings from concat! and stringify!, proc-macro crate rules, compile_error! instead of a panic, helper attributes, the two-crate facade and derive split, absolute paths, and narrow generic bounds. Triggers on "macro_rules", "declarative macro", "write a derive macro", "proc macro", "procedural macro", "attribute macro", "macro hygiene", "fragment specifier", "cannot find macro in this scope", "recursion limit reached while expanding", "proc-macro derive panicked", "cyclic package dependency", "cargo expand", "token stream", "quote!", or "syn".
rust-observability
Instrument, review, and debug Rust diagnostics built on tracing — spans and events, a redacting visitor over a closed field vocabulary, one process-wide dispatcher shared by every FFI boundary, control-plane versus data-plane logging, bounded event queues with drop accounting, relaxed atomic counters, snapshot polling instead of per-event host callbacks, and deterministic emission ordering. Use when you add a log field, wire a host or embedded log sink, keep a hot path free of tracing macros, design a telemetry snapshot for a foreign caller, diagnose a library that emits nothing, or review whether a diagnostic can leak sensitive data.
rust-panic-safety
Panic policy for Rust — pick unwind or abort, stop panics at any FFI boundary that must not unwind with catch_unwind, convert them into typed errors and foreign status codes or exceptions, audit unwrap and expect, and keep data valid when a panic passes through. Use when you add or review an extern "C", extern "system", JNI, or UniFFI entry point, set the panic strategy in a Cargo profile, install a panic hook, replace unwrap or expect with typed errors, choose between thiserror and anyhow, debug an abort with no Rust backtrace, or handle a panic in an async task, a spawned thread, or a Drop implementation.
rust-performance
Profile and optimize Rust code and native libraries. Covers host flamegraphs with cargo-flamegraph and perf, Android on-device profiling with simpleperf, Perfetto, HWASan and ndk-stack symbolication, iOS profiling with Instruments, os_signpost and MetricKit, binary size analysis with cargo-bloat, monomorphization bloat with cargo-llvm-lines, Criterion microbenchmarks and baselines, heap profiling with heaptrack and DHAT, data-parallel work with rayon, and build-time tuning with cargo --timings, sccache, LTO, codegen-units and linker choice. Use when a workload is slow, a binary or app bundle grew, a benchmark regressed, a flamegraph needs reading, a native crash needs symbolication, or a cross-compilation build is slow. Triggers on "flamegraph", "simpleperf", "Perfetto", "Instruments", "cargo-bloat", "binary size", "build time", "LTO", "monomorphization", or any performance question.
rust-pin-projection
Use when you put Pin in a signature, write a self-referential struct, or project a pinned reference into a field. Covers the gate that Pin enforces nothing when the target is Unpin, why Unpin does not mean movable and a PhantomPinned value still moves in safe code, the choice between std::pin::pin!, Box::pin and Pin::new_unchecked and the stack escape that compiles with zero warnings and is undefined behaviour, why a hand-rolled shadowing pin macro is broken, the four structural pinning obligations with their diagnostics, Drop taking &mut self on a pinned value, repr(packed) as incompatible with pinning, and the Unpin rule the projection macros change under you. Triggers on "pin projection", "structural pinning", "pin-project", "pin-project-lite", "PhantomPinned", "Pin::new_unchecked", "self-referential struct", "Unpin", "Box::pin", "std::pin::pin!", "PinnedDrop", "address-sensitive", "E0596", or "cannot borrow data in dereference of".
rust-sanitizers-miri
Use when you run AddressSanitizer, ThreadSanitizer or MemorySanitizer on Rust code, when you run UBSan on a C or C++ dependency of a Rust crate, when you configure Miri to find undefined behaviour in unsafe Rust (Stacked Borrows or Tree Borrows), when you stub an FFI dependency that Miri cannot execute, when you enable HWASan on Android or MTE on Android 14+, when you enable ASan or TSan on iOS through Xcode, when you read a tombstone tagged SEGV_MTEAERR or SEGV_MTESERR, or when you wire any of these tools into CI. Triggers on "sanitizer", "miri", "ASan", "TSan", "MSan", "HWASan", "MTE", "undefined behavior", "stacked borrows", "tree borrows", or memory-safety validation questions.
rust-security
Use when you audit Rust dependencies with cargo-audit, configure or change a cargo-deny policy in deny.toml, triage a RUSTSEC advisory, evaluate a new crate for typosquat and supply-chain risk before you add it to Cargo.toml, respond to a published CVE on a pinned dependency, decide whether an advisory ignore entry is acceptable, or harden a Rust parser that reads untrusted files. Triggers on "cargo audit", "cargo deny", "deny.toml", "RUSTSEC", "advisory", "supply chain", "typosquat", "malicious crate", "yanked", new-dependency-addition reviews, and archive, backup, or binary-format parser hardening.
rust-send-sync
Use when you decide whether a type is Send, Sync, both, or neither, and when the compiler rejects a value at a thread boundary. Covers the one rule that generates the rest, that &T is Send exactly when T is Sync. Covers the Send error whose help line names Sync, and the auto trait table for &T, &mut T, Box, Arc, Rc and raw pointers. Covers why Mutex<T> Sync needs only T Send while RwLock<T> Sync needs T Send + Sync, so the swap is not drop-in. Covers why MutexGuard is not Send but is Sync, so a scoped thread reads through a reference to the guard. Covers the four PhantomData markers and their variance side effect, auto trait leakage out of impl Trait and async fn, and E0321 on an unsafe impl for a reference type. Triggers on "Send", "Sync", "auto trait", "cannot be sent between threads safely", "cannot be shared between threads safely", "future cannot be sent between threads safely", "E0321", "PhantomData", "thread::scope", "Arc vs Rc", "MutexGuard is not Send", or "is not Send".
rust-serde
Use when you derive Serialize or Deserialize on a type whose encoded form is a contract - a config file, an on-disk record, a cached payload, a message another process or an older build reads. Covers deny_unknown_fields and the rename_all migration trap, the four enum representations and what each puts on the wire, why untagged destroys error messages, flatten and its interaction with deny_unknown_fields and non-self-describing formats, validation at the boundary with try_from, and the default plus alias pair that keeps old and new payloads both readable. Triggers on serde, Serialize, Deserialize, serde_json, deny_unknown_fields, rename_all, serde(tag), untagged, serde(flatten), skip_serializing_if, serde(default), serde(alias), serde(try_from), "unknown field", "did not match any variant", or any wire-compatibility question.
rust-tdd
Test-first workflow for Rust — a rigid red-green-refactor-lint cycle with cargo and cargo-nextest for new features, bug fixes, and refactors. Covers running one test at a time, test placement from unit to integration to end-to-end, hand-written fakes instead of mocking crates, a fault-injection queue for error paths, async test structure with tokio, golden-contract tests with a safe bless procedure, and a subagent split that keeps test design free of implementation bias. Use when you start a behavior change in Rust, reproduce a reported bug, refactor code that must keep its behavior, or review whether a test suite was really written test-first.
rust-test-tools
Dynamic check toolkit beyond cargo test — cargo-nextest as the baseline runner, cargo-careful (hardened std where Miri cannot run), loom (concurrency model checker), proptest (property tests), cargo-fuzz (libFuzzer), cargo-mutants with survived-mutant triage, and golden tests for deterministic output. Use when you write or review tests for unsafe code, hand-rolled atomics and lock-free primitives, parsers and decoders that read untrusted bytes, FFI boundaries, deterministic export pipelines, or before you promote an AI-generated module past basic test coverage.
rust-type-erasure
Use when you store values in a type-keyed map or erase a type at run time — Box<dyn Any>, TypeId, downcast_ref, a request-extension map, a resource registry, or an ECS-style world — and above all when the values are not 'static. Covers why Any is bound to 'static and how that bound surfaces as E0597 at the caller instead of at the map, why type_name is not a type key, a three-rung ladder from a lifetime-parameterized enum through a plain Box<dyn Any> type map to the GAT owner/element bijection that keys borrowed data on a 'static tag, the E0271 and lifetime-mismatch collisions the compiler rejects for you, the for<'x> bound a generic helper needs, the use-after-free an extractor layer reintroduces when it detaches the lifetime, and the E0117 orphan limit on shipping the pattern as a library. Triggers on "TypeId", "dyn Any", "downcast_ref", "type erasure", "anymap", "type map", "extensions map", "type_name", "non-static Any", "GAT bijection", "resource registry", "system param", or "E0117".
rust-unsafe
Use when you add or review any unsafe Rust block, FFI boundary (JNI, UniFFI, or hand-rolled extern "C"), raw-pointer arithmetic, transmute, ManuallyDrop, mem::zeroed, ioctl or syscall wrapper, union access, manual unsafe impl Send/Sync, Box::leak, zero-copy buffer or mmap handoff, or any change that removes the crate-level forbid(unsafe_code) attribute from a previously safe crate. Covers the lint floor for unsafe crates, SAFETY comment discipline, panic safety at FFI boundaries, unaligned reads from untrusted bytes, Drop and double-panic hazards, symbol collision in cdylib crates, Miri and Tree Borrows verification, and a review checklist. Triggers on "unsafe", "FFI", "extern", "raw pointer", "transmute", "*mut/*const", "SAFETY comment", "undefined behavior", "no_mangle", "zero-copy", "mmap", "repr(packed)", "alignment", "E0793", "improper_ctypes", "opaque handle", "OwnedFd", or any soundness question.
rust-variance
Use when a lifetime coercion is refused and you must decide whether a type constructor is covariant, contravariant, or invariant, or when you add a lifetime parameter to a public type. Covers the three one-line probes that settle any variance question in one rustc run, the variance of &T, &mut T, *const T, *mut T, Box, Vec, fn(T), fn() -> T, Cell, Mutex, dyn Trait and every PhantomData form, why traits match their parameters and associated types by equality so a fn item returning &'static str fails resize_with with E0597, the three fixes for a producer whose output lives too long, unbounded lifetimes from a raw-pointer deref, and why adding interior mutability to a published struct is a breaking change. Triggers on "variance", "covariant", "contravariant", "subtyping", "lifetime may not live long enough" on a coercion, "is invariant over the parameter", "borrowed for 'static", "resize_with", "unbounded lifetime", "phantomdata variance", "dyn fn lifetime", "&mut is invariant", or "sender is invariant".
uniffi-boundary
Use when you author, change, or review a UniFFI cross-language boundary crate that generates Kotlin and Swift bindings from Rust. Covers proc-macro-first scaffolding versus UDL, the Record/Object/Enum/Error derives, the Record-versus-Object decision, Send + Sync requirements on exported interfaces, Arc-based ownership and object identity across the boundary, callback interfaces and foreign traits, custom types and newtype converters, versioned payloads that cross as JSON strings, coarse-boundary and large-data rules, built-in type mapping to Kotlin and Swift, async export rules, codegen failure triage, and a review checklist. Triggers on uniffi, uniffi::export, uniffi::constructor, derive Record/Object/Enum/Error, setup_scaffolding, uniffi-bindgen, UDL, callback_interface, with_foreign, custom_newtype, foreign trait, or any question about what may cross an FFI boundary.
uniffi-packaging-versioning
Use when you package a Rust UniFFI core as native artifacts for mobile consumers - per-ABI Android cdylib .so files, an iOS XCFramework assembled from staticlib slices, and generated Kotlin and Swift bindings - or when you version the FFI surface - pin the uniffi runtime against uniffi-bindgen, classify an exported API change as additive or breaking, keep checked-in bindings in step with the library, or debug a load-time checksum mismatch, a RustBuffer deserialization panic, or a missing native library.
Bio shown is the top-scored skill's repo description as a fallback — real GitHub bios land in a future update.