Robust Rust patterns for file-backed data, parsing, persistence, FFI boundaries, and system integration. Use when writing Rust that handles file formats, subprocess integration, PID/process management, Serde serialization, or UniFFI boundaries. Covers UTF-8 safety, atomic writes, state machines, and defensive error handling.
View on GitHubpetekp/agent-skills
explainer
January 25, 2026
Select agents to install to:
npx add-skill https://github.com/petekp/agent-skills/blob/main/skills/rust/SKILL.md -a claude-code --skill rustInstallation paths:
.claude/skills/rust/# Rust Engineering Guide Patterns for building reliable Rust systems that handle file-backed data, external process integration, and cross-language boundaries. ## Core Philosophy **Conservative by Default**: Inputs from files, subprocesses, and external systems are untrusted. - Prefer false negatives over false positives - Same input → same output (deterministic) - Never panic on user machines due to bad input **Canonical Model Ownership**: When Rust is the source of truth, maintain separate representations: | Layer | Purpose | Characteristics | |-------|---------|-----------------| | Internal domain | Business logic | Expressive enums, rich types | | FFI DTOs | Cross-language boundary | Flat, stable, `String`-heavy | | File format | Persistence | Versioned, round-trippable | | External input | Validation boundary | Strictly validated, never trusted | **Safe Rust Only**: None of these patterns require `unsafe`. Use ecosystem crates for safe abstractions. --- ## Reference Guides Load the relevant reference when working in that domain: | Domain | Reference | When to Load | |--------|-----------|--------------| | **Data Modeling** | [references/data-modeling.md](references/data-modeling.md) | Serde patterns, UniFFI, strong types, versioned schemas | | **File I/O** | [references/file-io.md](references/file-io.md) | Atomic writes, concurrency control, file watching | | **Process Integration** | [references/process-integration.md](references/process-integration.md) | PID verification, subprocess handling, timestamps | | **Text & Parsing** | [references/text-and-parsing.md](references/text-and-parsing.md) | UTF-8 safety, path normalization, state machines | | **Testing** | [references/testing.md](references/testing.md) | Round-trip tests, fuzz testing, Clippy lints | --- ## Error Handling ### Library vs Application Errors **Libraries** (public API): Use `thiserror` with granular error types per operation: ```rust // File operations have their own error type