claude.symlink/skills/rust/SKILL.md
Write idiomatic Rust with ownership, lifetimes, and traits. Use for Rust development, memory safety, or systems programming.
npx skillsauth add htlin222/dotfiles rustInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Write safe, performant Rust code.
// Immutable borrow
fn print_length(s: &str) {
println!("Length: {}", s.len());
}
// Mutable borrow
fn append_greeting(s: &mut String) {
s.push_str(", world!");
}
// Ownership transfer
fn consume(s: String) -> String {
format!("Consumed: {}", s)
}
// Explicit lifetime annotation
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
if x.len() > y.len() { x } else { y }
}
// Struct with lifetime
struct Parser<'a> {
input: &'a str,
position: usize,
}
use thiserror::Error;
#[derive(Error, Debug)]
pub enum AppError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Parse error at line {line}")]
Parse { line: usize },
#[error("Not found: {0}")]
NotFound(String),
}
// Using Result
fn read_config(path: &Path) -> Result<Config, AppError> {
let content = std::fs::read_to_string(path)?;
parse_config(&content).map_err(|e| AppError::Parse { line: e.line })
}
// Define trait
trait Summary {
fn summarize(&self) -> String;
// Default implementation
fn preview(&self) -> String {
format!("{}...", &self.summarize()[..50])
}
}
// Implement for type
impl Summary for Article {
fn summarize(&self) -> String {
format!("{} by {}", self.title, self.author)
}
}
// Generic with trait bounds
fn notify<T: Summary + Display>(item: &T) {
println!("Breaking: {}", item.summarize());
}
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let response = fetch_data().await?;
process(response).await
}
async fn fetch_data() -> Result<Data, Error> {
let client = reqwest::Client::new();
let resp = client.get(URL).send().await?.json().await?;
Ok(resp)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_parse_valid() {
let result = parse("valid input");
assert!(result.is_ok());
assert_eq!(result.unwrap(), expected);
}
#[test]
#[should_panic(expected = "empty input")]
fn test_parse_empty() {
parse("");
}
}
Input: "Fix lifetime error" Action: Analyze borrow checker message, adjust lifetimes or ownership
Input: "Make this async" Action: Add async/await, use tokio runtime, handle async errors
testing
Converts narrative medical text into Pocket Medicine bullet-style notes with proper abbreviations, then modularizes sections exceeding 20 lines into linked standalone files.
devops
Use when deploying Docker services on the local VM (hostname: vm, Pop!_OS) with Traefik reverse proxy and Homepage dashboard. Covers crane image workflow, Traefik file-provider registration, Homepage services.yaml entries, and compose templates on the traefik-proxy network.
development
Use when reviewing a data visualization or figure for clarity, checking if a graph communicates its message without additional context, or iterating on R/Python plot scripts until a naive reader can fully understand the figure.
development
Runs Vale prose linter on markdown/text files and auto-fixes issues. Use when the user asks to lint, proofread, or improve writing quality of markdown or text files.