一键导入
rust-developer
Lead Rust developer guidance for Rust 2021+, Clap CLI applications, error handling with anyhow/thiserror, and idiomatic patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Lead Rust developer guidance for Rust 2021+, Clap CLI applications, error handling with anyhow/thiserror, and idiomatic patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Manage Trunk-Based Development workflows using the tbdflow CLI. Use this skill to create short-lived branches, make standardised commits, sync with trunk, merge completed work, generate changelogs, log intent notes, run non-blocking reviews, recover WIP snapshots, and emit machine-readable JSON output.
Code quality analysis skill for tbdflow, covering smells, maintainability, and refactoring guidance.
| name | rust-developer |
| description | Lead Rust developer guidance for Rust 2021+, Clap CLI applications, error handling with anyhow/thiserror, and idiomatic patterns. |
| version | 1.0.0 |
| author | Claes Adamsson |
| tags | ["rust","cli","systems","error-handling","architecture"] |
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.
tbdflow workflow) already governs the process.Cargo.toml before suggesting dependencies or versions.let) and leverage the type system for safety..unwrap() and .expect() in library code; use ? operator and proper error propagation.Result<T, E> over panics; reserve panics for truly unrecoverable states.tests/.mod.rs or inline modules, clear public API boundaries..map(), .filter(), .collect()) over manual loops.cargo clippy and cargo fmt for linting and formatting.Error Handling: Use thiserror for custom error types in libraries, anyhow for applications.
// 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(())
}
Structs & Enums: Use #[derive] liberally for common traits.
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Config {
pub name: String,
#[serde(default)]
pub enabled: bool,
}
Option/Result Handling: Prefer combinators and ? over explicit matching.
// 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"))?;
CLI Structure: Use Clap derive with clear subcommands and help text.
#[derive(Parser)]
#[command(name = "mytool", about = "Does useful things")]
struct Cli {
#[command(subcommand)]
command: Commands,
#[arg(long, global = true)]
verbose: bool,
}
Testing: Use #[cfg(test)] modules and descriptive test names.
#[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);
}
}
.unwrap() except in tests or when invariants are proven..clone() to satisfy the borrow checker without understanding why.spawn_blocking.Cargo.toml and Cargo.lock before adding dependencies.cargo test for unit/integration tests; cargo test --doc for doc tests.cargo clippy -- -W clippy::pedantic periodically for deeper analysis.cargo audit to check for security vulnerabilities in dependencies.///) focusing on usage and rationale.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
main.rs thin: parse args, load config, dispatch to handlers.commit.rs, branch.rs).misc.rs or a utils/ submodule.tbdflow Git workflow skill—use both where applicable.