Cómo usar
- Copia el comando y revisa el paquete antes de instalarlo en tu entorno de agente.
- Consulta las herramientas, credenciales y entornos necesarios en el documento original.
- Describe las entradas y el resultado deseado; contrasta la salida con las fuentes.
npx skills add https://github.com/victorzhuk/skills --skill z-rust-coreAntes de empezar
- La instalación no incluye suscripción al modelo, cuota API ni permisos sobre tus archivos.
- Las estrellas e instalaciones reflejan actividad, no una prueba independiente de calidad o seguridad.
Contenido del repositorio de origen con títulos, ejemplos, código, tablas, enlaces e imágenes preservados.
Rust core
Write idiomatic, zero-cost Rust: make ownership and lifetimes explicit, model errors in the type system, keep concurrency safe, and encode invariants at compile time.
Core rules
- Ownership: Prefer borrowing (
&T) over ownership transfer; explain move semantics for non-Copy types - Error Handling: Use
anyhowfor application code,thiserrorfor libraries; always propagate with?; never panic in library code - Async: Preserve the target service's existing executor and lifecycle. Use
tokioAPIs only in Tokio applications or when a new runtime choice is explicitly authorized —tokio::spawnpanics outside a Tokio runtime context; usetokio::select!for racing futures; wrap blocking calls withspawn_blocking - Traits: Use trait bounds with
impl Traitfor simple argument positions; usedyn Traitfor runtime polymorphism; implementFrom/Intofor conversions - Project Layout: For GUI desktop apps ([[z-rust-gtk4]]), split by concern, not by domain/service/handler layers — a workspace with one crate per feature (
core/,subscription/,ui/, ...) or a single crate with modules per concern (api/,app/,platform/,ui/, ...). See [[z-rust-web]] for HTTP-service layout. - Safety: Minimize
unsafe; document all safety invariants when unavoidable; use#[must_use]on types where ignoring the return is a bug; use#[non_exhaustive]on public enums for future compatibility - Tooling: Run
cargo fmtandcargo clippy -- -D warningsin CI.-W clippy::allenables warnings but does not fail on them. Add--nocaptureonly to an already bounded test command when debug output helps. - Testing: Unit tests in
#[cfg(test)]module in the same file; integration tests intests/; useproptest/quickcheckfor property-based tests; usemockallfor mocking traits andmockitoto stub HTTP responses in adapter/client tests.cargo testhas no timeout and spawns one thread per core — run dev suites astimeout 5m cargo test -- --test-threads=4(or via a runner target carrying the same limits); [[z-testing-strategy]] has the per-runner floor
Do not
- Turn on
clippy::pedanticreflexively — it earns its place with a concrete reason, not by default. - Mix
anyhowinto a library's public API — libraries return typedthiserrorerrors so callers can match on variants;anyhowis for application code that only needs to propagate and log.
Edge cases
If lifetime annotations become complex: Simplify by restructuring ownership; consider Arc<T> to eliminate lifetime constraints across thread boundaries.
If Clone appears frequently in GUI event-loop code ([[z-rust-gtk4]]: relm4/iced closures that must own their captures): that's the idiom, not a smell — cheap handle/String clones feeding sender.input() or message closures are expected. Only treat Clone as a smell when it's masking a lifetime fight on a hot path or duplicating something non-trivial to dodge the borrow checker.
If a trait needs to be object-safe: Avoid associated types that differ per impl; use Box<dyn Trait> only when runtime dispatch is genuinely needed.
If an async trait needs to be used as a trait object (Arc<dyn Trait>, &dyn Trait): use #[async_trait] — async fn in traits still isn't dyn-compatible without boxing, regardless of MSRV. This isn't a legacy fallback: it's the live pattern once dynamic dispatch is in play. Skip async-trait only when every call site is static dispatch (impl Trait / <T: Trait>), never boxed.
If build times are slow: Measure compilation and test execution separately. Check existing profile settings and dependency costs before splitting crates or adding a runner.
If FFI boundary is needed: Isolate all unsafe in a dedicated module; wrap in a safe Rust API immediately; document all invariants.
If deadlock is suspected in async code: Avoid holding std::sync::Mutex across .await; use tokio::sync::Mutex for async-aware locking.
Verify
- Use the existing project wrapper for formatting, linting, and tests.
- Confirm
cargo fmt --checkand the project's Clippy policy pass. - Bound the whole test process and parallel workers; use supported per-test limits when the runner provides them. See [[z-testing-strategy]].
- Exercise changed error, cancellation, and ownership boundaries, not only the success path.

