home / skills / dicklesworthstone / meta_skill / rust-complete

rust-complete skill

/skills/examples/rust-complete

This skill guides Rust developers through error handling, testing, and logging patterns, demonstrated via includes composition and practical CLI examples.

npx playbooks add skill dicklesworthstone/meta_skill --skill rust-complete

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.1 KB
---
id: rust-complete
name: Complete Rust Development
description: >-
  A comprehensive skill for Rust development that combines error handling,
  testing, and logging patterns. Demonstrates the 'includes' composition
  feature by merging content from multiple standalone skills.
tags: [rust, complete, example]
includes:
  - skill: rust-error-handling
    into: rules
  - skill: testing-patterns
    into: checklist
  - skill: logging-patterns
    into: rules
    prefix: "[Logging] "
---

# Complete Rust Development

A comprehensive Rust development skill that combines error handling, testing,
and logging patterns through composition.

This skill demonstrates the `includes` feature:
- Error handling rules from `rust-error-handling` are merged into Rules
- Testing checklist from `testing-patterns` is merged into Checklist
- Logging rules from `logging-patterns` are merged into Rules with a prefix

## Rules

- Follow Rust idioms and conventions
- Use `clippy` for linting: `cargo clippy -- -D warnings`
- Format code with `rustfmt`: `cargo fmt`
- Keep unsafe blocks minimal and well-documented

## Examples

```rust
// Idiomatic Rust with proper error handling, logging, and tests
use anyhow::{Context, Result};
use tracing::{info, instrument};

#[instrument]
pub fn process_data(input: &str) -> Result<Output> {
    info!("processing data");

    let parsed = parse_input(input)
        .context("failed to parse input")?;

    let result = transform(parsed)
        .context("transformation failed")?;

    info!(output_size = result.len(), "processing complete");
    Ok(result)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_process_data_happy_path() {
        let input = "valid input";
        let result = process_data(input);
        assert!(result.is_ok());
    }

    #[test]
    fn test_process_data_invalid_input() {
        let input = "";
        let result = process_data(input);
        assert!(result.is_err());
    }
}
```

## Checklist

- [ ] Code passes `cargo clippy -- -D warnings`
- [ ] Code is formatted with `cargo fmt`
- [ ] No `unsafe` blocks (or they are justified and documented)
- [ ] Dependencies are minimal and audited

Overview

This skill provides a comprehensive Rust development checklist and rule set that unites error handling, testing, and logging patterns. It enforces idiomatic Rust, linting, formatting, and minimal unsafe usage while demonstrating composition by merging patterns from standalone modules. The outcome is higher code quality, consistent tooling, and reusable guidance for Rust CLI and library projects.

How this skill works

The skill inspects project code and workflow against a curated ruleset: Rust idioms, clippy lint enforcement, rustfmt formatting, error handling patterns, logging conventions, and a testing checklist. It merges rules and checklists from focused sub-skills so you get a single cohesive guidance set rather than fragmented advice. Use it as a gate or pre-commit checklist, developer reference, or CI step to validate code quality and consistency.

When to use it

  • Bootstrapping a new Rust CLI or library to establish standards
  • Before merging feature branches to enforce linting and formatting
  • Setting up CI checks for clippy, rustfmt, and test coverage
  • Auditing code for unsafe usages and dependency bloat
  • Training newcomers on consistent error handling, logging, and testing patterns

Best practices

  • Run cargo clippy -- -D warnings and cargo fmt as part of CI and local pre-commit hooks
  • Prefer anyhow/thiserror for ergonomic error propagation and add Context where helpful
  • Use tracing for structured logging and instrument functions for observability
  • Keep unsafe blocks minimal, review them explicitly, and document safety invariants
  • Write unit tests for happy and unhappy paths; include edge cases and ensure repeatability

Example use cases

  • Integrate as a CI job that fails on clippy or formatting regressions
  • Use the checklist as a code review template to confirm error handling and logging are present
  • Apply the merged rules to standardize logging prefixes and error contexts across microcommands
  • Embed the testing checklist in new project templates to ensure baseline test coverage
  • Audit a legacy crate: run lints, format, and identify unsafe blocks to plan remediation

FAQ

Does this skill modify code automatically?

No. It recommends checks and patterns. It can be wired into CI or tooling that runs cargo fmt or clippy to apply fixes, but the skill itself provides guidance and validations.

Which logging and error libraries does it assume?

It aligns with common, ergonomic choices: tracing for structured logs and anyhow/thiserror for error handling, but the rules are adaptable to other libraries with similar patterns.

How do composed rules work?

Rules from focused modules (error handling, logging, testing) are merged into a single ruleset and checklist so you get consolidated guidance without switching contexts.