cli-architecture
БесплатноБез исполняемых скриптовНе проверенCLI tool design and architecture best practices inspired by Biome, OxcLint, and other modern Rust tools. Use when designing new features, refactoring…
от ryo-ebata★ 26 звёзд на GitHubОб этом скилле
CLI Architecture Best Practices
Reference tools: Biome, OxcLint, ripgrep, fd
Core Design Principles
1. Zero-Config by Default
User experience priority:
1. Works out of the box with sensible defaults
2. Configuration is optional enhancement
3. Explicit overrides when needed
// BAD: Requires configuration to work
let config = Config::load("config.yaml")?; // Fails if missing
// GOOD: Sensible defaults, optional config
let config = Config::load_or_default("config.yaml");
2. Modular Composability (Oxc Pattern)
Each component works independently or together:
┌─────────────────────────────────────────────┐
│ CLI │
├─────────────────────────────────────────────┤
│ ┌─────────┐ ┌─────────┐ ┌─────────────┐ │
│ │ Scanner │ │ Reporter│ │ Config │ │
│ └────┬────┘ └────┬────┘ └──────┬──────┘ │
│ │ │ │ │
├───────┴───────────┴─────────────┴───────────┤
│ Core Engine │
├─────────────────────────────────────────────┤
│ ┌────────┐ ┌────────┐ ┌────────┐ │
│ │ Parser │ │ Rules │ │ Types │ │
│ └────────┘ └────────┘ └────────┘ │
└─────────────────────────────────────────────┘
3. Performance First
- Parallel by default: Use
rayonfor file processing - Streaming output: Don't buffer entire results
- Lazy evaluation: Load resources on demand
- Memory efficiency: Process files without loading all into memory
Crate Organization (Workspace Pattern)
Recommended Structure
my-tool/
├── Cargo.toml # Workspace root
├── crates/
│ ├── my_tool/ # Main library (pub API)
│ ├── my_tool_cli/ # CLI binary (thin wrapper)
│ ├── my_tool_parser/ # Parser implementation
│ ├── my_tool_rules/ # Rule definitions
│ ├── my_tool_config/ # Configuration handling
│ └── my_tool_reporter/ # Output formatters
├── xtask/ # Development tasks
└── tests/ # Integration tests
Workspace Cargo.toml
[workspace]
resolver = "2"
members = ["crates/*", "xtask"]
[workspace.package]
version = "1.0.0"
edition = "2024"
rust-version = "1.85"
license = "MIT"
repository = "https://github.com/org/my-tool"
[workspace.dependencies]
# Share versions across crates
clap = { version = "4", features = ["derive"] }
serde = { version = "1", features = ["derive"] }
thiserror = "2"
rayon = "1"
Crate Dependencies (Layered)
cli → lib → [parser, rules, config, reporter]
↓
core types
# crates/my_tool_cli/Cargo.toml
[dependencies]
my_tool = { workspace = true }
clap = { workspace = true }
# crates/my_tool/Cargo.toml (main lib)
[dependencies]
my_tool_parser = { workspace = true }
my_tool_rules = { workspace = true }
my_tool_config = { workspace = true }
my_tool_reporter = { workspace = true }
CLI Design (clap)
Subcommand Pattern
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(name = "my-tool")]
#[command(version, about, long_about = None)]
#[command(propagate_version = true)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
/// Files or directories to process
#[arg(default_value = ".")]
pub paths: Vec<PathBuf>,
/// Output format
#[arg(long, short, default_value = "text")]
pub format: OutputFormat,
/// Configuration file
#[arg(long, short)]
pub config: Option<PathBuf>,
/// Verbose output
#[arg(long, short, action = clap::ArgAction::Count)]
pub verbose: u8,
}
#[derive(Subcommand)]
pub enum Commands {
/// Check files (default)
Check(CheckArgs),
/// Initialize configuration
Init(InitArgs),
/// Explain a rule
Explain { rule: String },
}
Exit Codes (Consistent Convention)
pub enum ExitCode {
Success = 0,
LintError = 1, // Findings detected
ConfigError = 2, // Invalid configuration
IoError = 3, // File system error
InternalError = 101, // Bug in tool
}
fn main() -> ExitCode {
match run() {
Ok(result) if result.has_errors() => ExitCode::LintError,
Ok(_) => ExitCode::Success,
Err(e) => e.into(),
}
}
Configuration System (Biome Pattern)
Layered Configuration
Priority (highest to lowest):
1. CLI arguments
2. Environment variables
3. Project config (.my-tool.yaml)
4. User config (~/.config/my-tool/config.yaml)
5. Default values
pub struct Config {
// Merged from all sources
}
impl Config {
pub fn load(cli: &Cli) -> Result<Self, ConfigError> {
let mut config = Self::default();
// Layer 5: Defaults (already set)
// Layer 4: User config
if let Some(user_config) = Self::load_user_config()? {
config.merge(user_config);
}
// Layer 3: Project config
if let Some(project
Установить cli-architecture в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл cli-architecture?
CLI tool design and architecture best practices inspired by Biome, OxcLint, and other modern Rust tools. Use when designing new features, refactoring architecture, or reviewing structural decisions.
Как установить скилл cli-architecture?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cli-architecture запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic