rust-compiler-diagnostics
$
npx mdskill add mkurman/zorai/rust-compiler-diagnosticsDiagnose Rust compilation errors and Clippy lints systematically.
- Resolve ownership, lifetime, and type issues without guessing.
- Integrates with cargo check, rustc, and Clippy tools.
- Prioritizes primary errors and inspects definition sites first.
- Re-runs verification commands after each proposed fix.
SKILL.md
.github/skills/rust-compiler-diagnosticsView on GitHub ↗
---
name: rust-compiler-diagnostics
description: Use when Rust code fails to compile, Clippy reports lints, borrow checker errors appear, lifetimes are unclear, or cargo diagnostics need systematic triage.
license: MIT
tags: [development, rust-compiler-diagnostics, rust]
metadata:
source_references:
- https://github.com/udapy/rust-agentic-skills
- https://doc.rust-lang.org/rustc/
- https://doc.rust-lang.org/clippy/
---
# Rust Compiler Diagnostics
Use this skill to resolve Rust compiler and Clippy diagnostics without guessing.
## Workflow
1. Run the narrowest command that reproduces the diagnostic, usually `cargo check -p <crate>` or a focused test.
2. Read the first real compiler error before secondary errors; later diagnostics are often consequences.
3. Identify the ownership, lifetime, type, trait, macro, feature, or lint category involved.
4. Inspect the definition site and the nearest caller before editing.
5. Prefer changing API shape only when the current contract is the real cause.
6. Re-run the same command after each fix, then broaden verification when the focused command is clean.
## Borrow Checker Triage
- Find who owns the value, who borrows it, and how long each borrow actually needs to live.
- Reduce borrow scope with blocks, local variables, or earlier extraction before adding clones.
- Split immutable data from mutable state when one large struct borrow blocks independent access.
- Move expensive or fallible work outside lock guards and mutable borrows.
- Use owned values for spawned tasks and cross-thread work; references rarely fit those lifetimes.
## Diagnostic Repair Examples
### End A Borrow Before Mutation
```rust
// Avoid: `self.items` is immutably borrowed while mutating `self`.
if let Some(item) = self.items.get(id) {
self.record_access(item.name());
}
// Prefer: extract the needed owned value, ending the borrow.
let name = self.items.get(id).map(|item| item.name().to_owned());
if let Some(name) = name {
self.record_access(&name);
}
```
### Move Out Of A Field Safely
```rust
if let Some(task) = self.pending_task.take() {
task.cancel().await;
}
```
Use `Option::take` when a field must be moved out while leaving the struct in a valid state.
### Fix Escaping Borrow In Spawned Tasks
```rust
// Avoid: `&self` cannot be moved into a 'static task.
tokio::spawn(async move {
self.refresh().await;
});
// Prefer: clone the owned handle needed by the task.
let client = self.client.clone();
tokio::spawn(async move {
client.refresh().await;
});
```
## Clippy Triage
- Treat Clippy as design feedback, not only style feedback.
- Accept Clippy suggestions when they preserve readability and behavior.
- Add `#[allow(...)]` only near the smallest scope and include a short reason when the lint is intentionally violated.
- Do not silence `unwrap_used`, `expect_used`, `panic`, or lossy conversion lints in production paths without confirming the project policy.
### Prefer Targeted Allows
```rust
#[allow(clippy::too_many_arguments, reason = "constructor mirrors the wire protocol fields")]
pub fn from_wire(/* fields */) -> Self {
// ...
}
```
## References
Read `references/error-triage.md` for common diagnostic families and repair patterns.
More from mkurman/zorai
- account-management>
- agile-scrum>
- albumentationsFast image augmentation library (Albumentations). 70+ transforms for classification, segmentation, object detection, keypoints, and pose estimation. Optimized OpenCV-based pipeline with unified API across all CV tasks. Supports images, masks, bounding boxes, and keypoints simultaneously. Note: classic Albumentations (MIT) is no longer maintained; successor AlbumentationsX uses AGPL-3.0. For torchvision-native augmentations, use torchvision.transforms.v2.
- aml-complianceAnti-Money Laundering (AML) and Know Your Customer (KYC) compliance workflow. Sanctions screening, PEP detection, transaction monitoring, suspicious activity reporting (SAR), and OFAC compliance.
- anki-connectThis skill is for interacting with Anki through AnkiConnect, and should be used whenever a user asks to interact with Anki, including to read or modify decks, notes, cards, models, media, or sync operations.
- approval-checkpoint-long-taskCanonical long-task pack for daemon-managed work with deliberate approval checkpoints, status summaries, rollback notes, and mobile-safe governance-aware updates.
- auditing-goal-artifactsUse when reviewing recent zorai goal run outputs, closure markers, ledgers, or evidence bundles to judge whether completion is credible or to identify remaining uncertainty.
- autogenAutoGen (Microsoft) — multi-agent conversation framework. Agent-to-agent chat, code generation & execution, tool use, group chat, and human-in-the-loop. Build collaborative AI systems with specialized agents.
- backtraderPython backtesting framework for trading strategies. Data feeds, brokers, analyzers, and live trading support. Strategy development with commission models, slippage, and signal-based execution.
- beautiful-mermaidRender Mermaid diagrams as SVG and PNG using the Beautiful Mermaid library. Use when the user asks to render a Mermaid diagram.