elite-rust

Rust Elite Standards (Edition 2024, Safe & Robust)

16 stars

Best use case

elite-rust is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Rust Elite Standards (Edition 2024, Safe & Robust)

Teams using elite-rust should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/elite-rust/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/elite-rust/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/elite-rust/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How elite-rust Compares

Feature / Agentelite-rustStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Rust Elite Standards (Edition 2024, Safe & Robust)

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Rust Elite Standards (Edition 2024)

## Architecture
- **Edition**: Must use Rust Edition 2024.
- **Dependencies**: Use Standard Polars `0.52.x` (ensure patch version compatibility).

## Safety & Error Handling
- **No Panic Policy**: Strictly forbid `unwrap()` and `expect()` in business logic.
- **Typed Errors**: Use `thiserror` for library errors and `anyhow` for application-level errors.
- **Async**: Use `tokio` for async runtime unless specified otherwise.

## Testing & Quality (Atomic Simulator VAS)
- **TDD Requirement**: "No Test, No Commit". Every feature must have a "Red Phase" failing test before logic implementation.
- **Performance Benchmarks**: Core operations (e.g., Ledger queries) must meet sub-100ms targets for 1000 rows.
- **Verification**: Every Mission must conclude with a `walkthrough.md` documenting test results.

## Interoperability (Tauri/TS)
- **Data Contract**: All event payloads between Rust and TypeScript MUST use `camelCase`. Use `#[serde(rename_all = "camelCase")]` on structs.
- **Glass Panel Philosophy**: UI is strictly a "Glass Panel". Zero business logic, zero state inferencing, and zero data modification allowed in the Frontend. UI ONLY renders what the Core (Rust) dictates.
- **IPC Safety**: Use `#[tauri::arg(rename = "camelCase")]` or `#[allow(non_snake_case)]` to reconcile Rust's `snake_case` with Frontend's `camelCase` without breaking convention.

## Observability
- **Traceability**: Every result-bearing function must be traced or logged using the `tracing` crate. Use `#[tracing::instrument]` on core logic.

## Extraction (Unified Orchestrator)
- **Architecture**: Use the "Unified Extraction Orchestrator" pattern. Orchestrators must be stateless, purely gaging capability and dispatching to lanes.
- **Stability & Isolation**: Heavy FFI tasks (PDF/Office) MUST be isolated in sub-processes via `WorkerManager`.
- **Fate-sharing**: Workers must monitor `stdin`. If parent drops, worker must exit immediately to avoid "ghost processes".
- **Resource Governor**: Limit maximum concurrent workers using a `Semaphore`. Cap based on CPU core count or memory availability.
- **Contract Enforcement**: All lanes must speak the `ExtractionProduct` JSON protocol.

## Interoperability (IPC Protocol)
- **JSON Stream**: Communication between Main (Rust) and Worker (Python) must be conducted via JSON over `stdin/stdout`.
- **CamelCase Alignment**: All IPC payloads MUST be `camelCase`.
- **Timeout Policy**: Every worker task must have a hard timeout to prevent blocking the dispatcher.
- **Zero-Lag IPC**: Round-trip time (RTT) for IPC MUST NOT exceed 20ms. Use persistent worker pools to avoid cold-start overhead. Any refactoring that degrades IPC performance beyond this threshold MUST be rejected.

## Polars Integration (Mission 018+)

- **Version Lock**: Use Polars `0.52.x` for stability and API consistency.
- **DataFrame Construction**: 
  - Use `DataFrame::new(Vec<Column>)` (not `Vec<Series>`)
  - Convert `Series` → `Column` via `.into_column()` or `Column::from(series)`
- **Type Safety**: 
  - Column names must use `.into()` for `PlSmallStr` compatibility
  - Example: `Series::new((&col_name).into(), &values)`
  - Avoid `.unwrap()` on DataFrame operations — use `Result` propagation
- **Testing**: 
  - Every Polars operation must have a unit test with known input/output
  - Benchmark DataFrame creation < 50ms per table (per `LATENCY_BUDGET.md`)
- **Documentation**: 
  - Always check Polars docs for current version before implementation
  - Polars API changes frequently between minor versions

## Lessons Learned (Mission 018)

### ❌ What Went Wrong
1. **Ignored Skill Standards**: Used Polars `0.45` instead of `0.52.x` specified in skill
2. **No TDD**: Wrote implementation before tests, leading to trial-and-error debugging
3. **API Assumptions**: Guessed Polars API instead of reading docs, wasted time on type mismatches
4. **Missing Observability**: No `#[tracing::instrument]` on core functions

### ✅ What Was Fixed
1. **Version Alignment**: Upgraded to Polars `0.52` — clean build with no breaking changes
2. **Type Corrections**: 
   - `Vec<Series>` → `Vec<Column>` for DataFrame construction
   - Added `.into()` for `PlSmallStr` column names
3. **Dependency Management**: Added missing `chrono` for timestamp handling

### 📋 Process Improvements
- **Read Skill First**: Always check skill requirements before choosing dependencies
- **TDD Discipline**: Write failing test → implement → verify (Red-Green-Refactor)
- **Version Lock Early**: Pin exact versions in `Cargo.toml` to avoid API drift
- **Document Assumptions**: If deviating from skill, document why in commit message

## Refactor & Safety Audit (Elite Mandatory)

- **Unsafe Policy**
  - `unsafe` blocks are forbidden by default.
  - If unavoidable:
    - Must be isolated in a single module.
    - Must include SAFETY comments explaining invariants.
    - Must be reviewed and traced.

- **Refactor Discipline**
  - Eliminate all `unwrap()` / `expect()` (including tests & examples).
  - Replace with `Result<T, E>` and `?`.
  - No silent fallback.

- **Public API Contract**
  - Any public function that can fail MUST return `Result`.
  - Error types must be explicit at library boundaries.

- **Refactor Workflow**
  1. Analyze module responsibilities.
  2. Identify unsafe / panic / implicit failure.
  3. Propose refactor plan **before applying major logic changes**.
  4. Refactor module-by-module under `src/`.
  5. Update call sites, tests, examples, and documentation.
## Data Purity Protocol (The Janitor's Decree)

- **Architectural Separation**: Data cleaning (Janitor) is STRICTLY separated from data validation (TableTruth). 
- **Stateless & Pure**: The Janitor layer must be a pure transformer. It does not hold state or infer business logic.
- **Reporting Hierarchy**: `JanitorReport` is non-authoritative. It is an audit trail for the Dashboard, but MUST NEVER be used by the `Truth` layer to determine validity.
- **I/O Boundary Enforcement (Encoding)**: All external text (e.g., from PythonWorkers) must pass through an `EncodingGatekeeper` for UTF-8 and Mojibake validation *before* reaching the Janitor.
- **Ghost Rules**: 
    - Ejection of "Ghost Columns" is preferred for structural hallucinations.
    - Row ejection is only allowed for 100% empty rows with no semantic significance (e.g., header rows, spacer rows).
- **SIMD Usage**: Prefer standard library optimizations (Regex, Arrow) for SIMD. Avoid manual intrinsics unless explicitly authorized for a specific Mission.
- **Syntactic Cleaning Only**: Janitor cleans characters and formats (1.250,50 -> 1250.5). It NEVER performs semantic conversion (m3 -> liters). Parse failures are left "as-is" to be rejected by Truth.

## Iron Truth Contract & Clean Hands Doctrine (Mission 024-027)

- **LAW-07 (Fail Safe & Human-Gated)**: Systems MUST detect and reject anomalies (Mojibake, structural rot) but MUST NEVER attempt autonomous repair. All repairs are human-gated.
- **Clean Hands Doctrine**: The Truth Engine (`TableTruth`) must remain pure. It only validates data. Any repair logic resides in the `Adapter/Engine` layer and results must be re-submitted for validation. "The Judge does not write the Law, and the Janitor does not argue with the Truth."
- **Iron Truth Contract V1.0**:
  - `TableTruth` is the singular source of truth for structural validity.
  - `ProjectTruth` is the derived authority for cross-source reconciliation.
  - Any conflict between Reality and Truth results in `Rejected` status by default.
- **Global Singletons**: Use `std::sync::OnceLock` for global, thread-safe singletons (e.g., `EncodingNormalizer`). Avoid `lazy_static` unless complex macro execution is required.
- **UI Architecture**:
  - **4-Panel Arbiter Layout**: Mandatory for data-dense forensic tools.
  - **Virtualization**: Mandatory for tables > 100 rows to maintain sub-1s interactivity. Row height fixed at 32px for precision.
  - **Forbidden Patterns**: Non-deterministic loaders (spinners), softening of rejection language ("Check again" -> "TỪ CHỐI"), and autonomous "Fix" buttons are strictly forbidden.
  
## Project Intelligence & Lineage Protocol (Mission 030)

- **Truth Lineage**: Every aggregated metric (e.g., `total_cost`) MUST carry a `LineageMap`.
- **Shadow Columns**: Use a `_lineage_` prefix for forensic metadata columns in Polars. These columns are for sideboat metadata only and MUST NOT participate in primary business logic (sort/filter/calc).
- **Deterministic GlobalId**: `GlobalId` for any entity (cell, row, table) must be deterministic and hash-based: `hash(v1_id, v2_id...)`. Never use random UUIDs for forensic data.
- **Backward Compatibility**: When adding new fields to core data contracts (e.g., `TableCell`), use `#[serde(default)]` to ensure compatibility with existing serialized mocks and project files.
- **Polars String Handling (0.52)**: To check if a column name exists in `df.get_column_names()`, convert to a `Vec<String>` first or handle `PlSmallStr` types carefully to avoid `&str` vs `&&str` type mismatches in `.contains()`.
- **Forensic State Persistence**: Tauri backend `ForensicState` must act as the primary cache for derived truths (like `ProjectTruth`) to ensure consistency across independent IPC commands (Drill-down, Export).

## Tauri v2 & Serde Interop Protocol (RC-1 Legacy)

- **Trait Scoping (Emitter)**: 
  - To use `.emit()` on an AppHandle in Tauri v2, you MUST import the trait: `use tauri::Emitter;`. The `Manager` trait is no longer sufficient for event emission.
- **Serialization Mismatches ("The Camel Trap")**:
  - **Rule**: Tauri v2 often defaults to `camelCase` for serialized output.
  - **Risk**: Rust structs with `snake_case` fields (e.g., `cell_id`) may arrive at Frontend as `cellId` or `cell_id`, leading to `undefined` errors.
  - **Prescription**: 
    - Explicitly explicitly decorate structs with `#[serde(rename = "your_field_name")]` if the frontend expects a specific casing.
    - Or use `#[serde(rename_all = "camelCase")]` for the entire struct.
    - **Frontend Defense**: Always use optional chaining (e.g., `payload?.cell_id?.split(...)`) and verify field existence before operations.
- **Clean Hands Compilation**:
  - **Zero Tolerance**: `cargo check` warnings (unused imports, dead fields) are unacceptable in Release Candidates.
  - **Prefixing**: Unused fields in structs (required for FFI compatibility but not logic) MUST be prefixed with `_` (e.g., `_ctx`, `_start_time`).
  - **Comment Out**: If a function or import is truly unused, comment it out or remove it. Do not suppress warnings with `#[allow(...)]` unless it is a temporary bridge.

Related Skills

Elite Full-Stack Web Developer

16
from diegosouzapw/awesome-omni-skill

A top-tier full-stack developer persona focused on implementing pixel-perfect, lightning-fast, and highly interactive landing pages for the Azores project.

awesome-copilot-root-rust-mcp-expert

16
from diegosouzapw/awesome-omni-skill

Expert assistant for Rust MCP server development using the rmcp SDK with tokio async runtime Use when: the task directly matches rust mcp expert responsibilities within plugin awesome-copilot-root. Do not use when: a more specific framework or task-focused skill is clearly a better match.

analyze-rust-optimizations

16
from diegosouzapw/awesome-omni-skill

This skill performs thorough analysis of Rust libraries to find optimization opportunities. It should be used when reviewing Rust code for performance improvements, memory efficiency, or when profiling indicates bottlenecks. Focuses on runtime performance and memory usage through dynamic profiling tools and static code analysis.

agent-rust-engineer

16
from diegosouzapw/awesome-omni-skill

Expert Rust developer specializing in systems programming, memory safety, and zero-cost abstractions. Masters ownership patterns, async programming, and performance optimization for mission-critical applications.

nerdzao-elite

16
from diegosouzapw/awesome-omni-skill

Senior Elite Software Engineer (15+) and Senior Product Designer. Full workflow with planning, architecture, TDD, clean code, and pixel-perfect UX validation.

nerdzao-elite-gemini-high

16
from diegosouzapw/awesome-omni-skill

Modo Elite Coder + UX Pixel-Perfect otimizado especificamente para Gemini 3.1 Pro High. Workflow completo com foco em qualidade máxima e eficiência de tokens.

rust-unsafe

16
from diegosouzapw/awesome-omni-skill

不安全代码与 FFI 专家。处理 unsafe, raw pointer, FFI, extern, transmute, *mut, *const, union, #[repr(C)], libc, MaybeUninit, NonNull, SAFETY comment, soundness, undefined behavior, UB, 安全抽象, 裸指针, 外部函数接口, 内存布局, 未定义行为

rust-anti-pattern

16
from diegosouzapw/awesome-omni-skill

Rust 反模式与常见错误。处理代码审查、clone、unwrap、String 用法、迭代器等问题。触发词:anti-pattern, common mistake, clone, unwrap, code review, 代码异味, 常见错误, 代码审查, refactor, 重构

moai-foundation-trust

16
from diegosouzapw/awesome-omni-skill

Complete TRUST 4 principles guide covering Test First, Readable, Unified, Secured. Validation methods, enterprise quality gates, metrics, and November 2025 standards. Enterprise v4.0 with 50+ software quality standards references.

crustdata-automation

16
from diegosouzapw/awesome-omni-skill

Automate Crustdata tasks via Rube MCP (Composio). Always search tools first for current schemas.

scode-dist-rust-setup

16
from diegosouzapw/awesome-omni-skill

Set up or standardize a Rust repository with cargo-dist release automation, Linux-focused CI with macOS release-plan tag gates, git-cliff changelog generation, Conventional Commit PR title enforcement, and Homebrew publishing to scode/homebrew-dist-tap. Use when creating a new Rust release pipeline or migrating an existing repo to this exact distribution model.

rust-skill

16
from diegosouzapw/awesome-omni-skill

Rust 编程专家技能。处理所有 Rust 相关问题:编译错误、所有权、生命周期、并发、async/await、性能优化等。触发词:Rust, cargo, 编译错误, ownership, borrow, lifetime, async, tokio, Send, Sync, Result, Error