mcpField
R
rust-cli-agent-style

rust-cli-agent-style

github.com/pproencaDevelopment21857 installsUpdated 11w ago
Repository

About rust-cli-agent-style

A skill that presents Rust coding conventions based on the OpenAI Codex CLI and agent codebase. It is for developers building production Rust CLIs or agent systems, with guidance on errors, workspace structure, async code, naming, and style.

Key features

  1. 01Error-handling conventions
  2. 02Workspace organization
  3. 03Async and trait patterns
  4. 04Naming conventions
  5. 05Code style and lint guidance
  6. 06Cross-crate dependency practices

Use cases

  1. 01Building Rust CLI tools
  2. 02Developing Rust agent systems
  3. 03Structuring a Rust workspace
  4. 04Reviewing production Rust code

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pproenca/dot-skills --skill rust-cli-agent-style

After installing, type/rust-cli-agent-stylein Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

AGENTS.md
README.md
metadata.json
assets/templates/
_template.md
references/
_sections.md
cross-workspace-deps.md
cross-workspace-lints.md
err-anyhow-application.md
err-context-chain.md
err-doc-errors.md
err-from-derive.md
err-io-result.md
err-map-err-conversion.md
err-no-expect.md
err-no-unwrap.md
err-structured-variants.md
err-thiserror-domain.md
err-transparent.md
mod-async-trait-macro.md
mod-builder-pattern.md
mod-derive-order.md
mod-extension-trait-suffix.md
mod-generic-constraints.md
mod-impl-block-order.md
mod-jsonschema-derive.md
mod-newtype-pattern.md
mod-serde-rename.md
mod-struct-visibility.md
mod-trait-bounds.md
mod-type-alias-complex.md

Details

From the project README

OpenAI Codex Rust CLI Agent Best Practices

This skill teaches you to write Rust code in the style of the OpenAI Codex codebase - a production CLI/agent system with 50 crates and 787 Rust files.

Key Characteristics

  • Edition 2024 with strict Clippy configuration
  • Zero unwrap/expect in non-test code (enforced at workspace level)
  • Tokio async runtime with proper Send + Sync bounds
  • thiserror for library errors, anyhow for application code
  • Flat workspace structure with centralized dependencies

When to Apply

Apply this skill when:

  • Building CLI tools or agent systems in Rust
  • Writing async Rust with Tokio
  • Designing Rust workspace organization
  • Implementing error handling patterns
  • Working on production Rust codebases

Quick Reference

Critical Rules (Must Follow)
RuleDescription
err-no-unwrapNever use unwrap() in non-test code
err-no-expectAvoid expect() in library code
err-thiserror-domainUse thiserror for domain errors
err-context-chainAdd context to errors with .context()
Error Handling
RuleDescription
err-anyhow-applicationUse anyhow::Result for entry points
err-from-deriveUse #[from] for error conversion
err-transparentUse #[error(transparent)] for wrapped errors
err-structured-variantsInclude relevant data in error variants
err-io-resultUse std::io::Result for I/O functions
err-map-err-conversionUse map_err for error conversion
err-doc-errorsDocument error conditions
Organization
RuleDescription
org-workspace-flatFlat workspace with utils subdirectory
org-crate-namingkebab-case directories, project prefix
org-module-visibilityUse pub(crate) for internal APIs
org-test-common-crateShared test utilities crate
org-integration-tests-suiteTests in suite directory
org-feature-modulesFeature-based module organization
org-handlers-subdirHandlers in dedicated subdirectory
org-errors-fileErrors in dedicated file
Component Patterns
RuleDescription
mod-derive-orderConsistent derive macro ordering
mod-async-trait-macroUse #[async_trait] for async traits
mod-trait-boundsSend + Sync + 'static for concurrent traits
mod-extension-trait-suffixExt suffix for extension traits
mod-builder-patternBuilder pattern for complex config
mod-type-alias-complexType aliases for complex generics
mod-impl-block-orderConsistent impl block ordering
mod-generic-constraintsWhere clauses for complex bounds
mod-newtype-patternNewtypes for type safety
mod-struct-visibilityPrivate fields with public constructor
mod-serde-renameSerde rename for wire format
mod-jsonschema-deriveJsonSchema for API types
Naming Conventions
RuleDescription
name-async-no-suffixNo _async suffix for async functions
name-try-prefix-fallibletry_ prefix for fallible constructors
name-with-prefix-builderwith_ prefix for builder methods
name-handler-suffixHandler suffix for handlers
name-error-suffixError suffix for error types
name-result-type-aliasCrate-specific Result alias
name-const-env-var_ENV_VAR suffix for env constants
name-request-responseRequest/Response type pairing
name-options-suffixOptions suffix for config bundles
name-info-suffixInfo suffix for read-only data
name-provider-suffixProvider suffix for services
name-client-suffixClient suffix for API clients
name-manager-suffixManager suffix for lifecycle mgmt
name-bool-is-prefixis_/has_/should_ for booleans
name-plural-collectionsPlural names for collections
Style
RuleDescription
style-import-granularityOne item per use statement
style-deny-stdoutDeny stdout/stderr in libraries
style-inline-format-argsInline format arguments
style-module-docsModule-level documentation
style-expect-reason#[expect] with reason for lints
style-cfg-test-moduleUnit tests in mod tests
Cross-Crate
RuleDescription
cross-workspace-lintsWorkspace-level lint config
cross-workspace-depsCentralized dependency versions

Example: Proper Error Handling

use thiserror::Error;
use anyhow::Context;

// Domain error with thiserror
#[derive(Debug, Error)]
pub enum ConfigError {
    #[error("failed to read config file: {path}")]
    ReadFailed {
        path: PathBuf,
        #[source]
        source: std::io::Error,
    },

    #[error(transparent)]
    Parse(#[from] toml::de::Error),
}

// Library function returns domain error
pub fn load_config(path: &Path) -> Result<Config, ConfigError> {
    let content = fs::read_to_string(path)
        .map_err(|source| ConfigError::ReadFailed {
            path: path.to_owned(),
            source,
        })?;
    toml::from_str(&content).map_err(Into::into)
}

// Application code uses anyhow with context
fn main() -> anyhow::Result<()> {
    let config = load_config(Path::new("config.toml"))
        .context("failed to load configuration")?;
    run(config).await
}

Source

Patterns extracted from OpenAI Codex (codex-rs/ subdirectory) - a production Rust codebase with 50 crates and 787 Rust files.

Comments

Markdown supported