Rust developer

From cladam/tbdflow · View interactive version

Rust developer is an AI agent skill from the GitHub repository cladam/tbdflow. Lead Rust developer guidance for Rust 2021+, Clap CLI applications, error handling with anyhow/thiserror, and idiomatic patterns.

How to use this skill

Skill file

Rust Developer Skill

Overview

Use this skill when acting as a Lead Rust Developer on the tbdflow codebase. It targets Rust 2021 edition, Clap 4.x for

CLI argument parsing, anyhow/thiserror for error handling, and serde for serialization. The goal is to ensure idiomatic

Rust, safe and ergonomic APIs, and pragmatic application code that stays aligned with the TBD workflow.

When to Use

When Not to Use

Instructions

General Guidance

Preferred Practices

Patterns to Follow

```rust

// Library error with thiserror

#[derive(Error, Debug)]

pub enum GitError {

#[error("Git command failed: {0}")]

CommandFailed(String),

#[error("Branch '{0}' not found")]

BranchNotFound(String),

}

// Application code with anyhow

fn main() -> anyhow::Result<()> {

let config = load_config().context("Failed to load configuration")?;

Ok(())

}

```

```rust

#[derive(Debug, Clone, Serialize, Deserialize, Default)]

pub struct Config {

pub name: String,

#[serde(default)]

pub enabled: bool,

}

```

```rust

// Preferred

let name = config.name.as_ref().map(|s| s.trim()).unwrap_or("default");

// Also good with ?

let value = some_option.ok_or_else(|| anyhow!("Missing value"))?;

```

```rust

#[derive(Parser)]

#[command(name = "mytool", about = "Does useful things")]

struct Cli {

#[command(subcommand)]

command: Commands,

#[arg(long, global = true)]

verbose: bool,

}

```

```rust

#[cfg(test)]

mod tests {

use super::*;

#[test]

fn parse_config_with_defaults() {

let config: Config = serde_yaml::from_str("name: test").unwrap();

assert!(!config.enabled);

}

}

```

Patterns to Avoid

Tooling & Dependency Checks

Output Expectations

Module Organization (tbdflow example)

src/
├── lib.rs          # Public module exports
├── main.rs         # CLI entry point, command dispatch
├── cli.rs          # Clap definitions (Commands enum)
├── config.rs       # Configuration structs and loading
├── git.rs          # Git operations (shell out to git)
├── commit.rs       # Commit workflow logic
├── branch.rs       # Branch management
├── review.rs       # Review feature
└── wizard.rs       # Interactive prompts

Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.