mcpField
S
solid-rust

solid-rust

github.com/fusengineDevelopment3441 installsUpdated 2w ago
Repository

About solid-rust

solid-rust is a skill for applying modular architecture and SOLID principles to Rust 2024 projects. It defines module locations, file-size and documentation rules, and requires checking for reusable code before implementation.

Key features

  1. 01Feature-based modules under src/modules/
  2. 02Shared code in src/core/
  3. 03Trait placement and generic-bound rules
  4. 04thiserror and rustdoc requirements
  5. 05DRY checks before implementation

Use cases

  1. 01Structure a new Rust feature module
  2. 02Review code against SOLID architecture rules
  3. 03Scaffold services, traits, handlers, and tests

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/fusengine/agents --skill solid-rust

After installing, type/solid-rustin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
architecture-patterns.md
dependency-inversion.md
interface-segregation.md
liskov-substitution.md
open-closed.md
single-responsibility.md
solid-principles.md
references/templates/
error.md
handler.md
module.md
service.md
test.md
trait-def.md

Details

From the project README
SOLID Rust enforces a modular architecture for Rust 2024 edition: every feature lives under `src/modules/[feature]/` (handlers.rs, services.rs, repository.rs, traits.rs, models.rs) with shared code in `src/core/`, traits live only in `traits.rs` or `src/core/traits/`, generics use trait bounds instead of concrete types, `thiserror` handles custom errors, and every public item carries a rustdoc `///` comment.

Before writing any new code it requires a DRY check against src/core/services and src/core/traits. See solid-principles.md for the overview, the per-principle references for SRP/OCP/LSP/ISP/DIP detail, and the templates for module/service/trait/handler/error/test scaffolding.

SOLID Rust - Modular Architecture

Agent Workflow (MANDATORY)

Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:

  1. fuse-ai-pilot:explore-codebase - Analyze existing architecture
  2. fuse-ai-pilot:research-expert - Verify Rust docs via Context7
  3. fuse-ai-pilot:sniper - Post-implementation validation

DRY - Reuse Before Creating (MANDATORY)

Before writing ANY new code:

  1. Grep the codebase for similar traits, services, or logic
  2. Check shared locations: src/core/services/, src/core/traits/
  3. If similar code exists -> extend/reuse instead of duplicate
  4. If code will be used by 2+ features -> create it in src/core/

Architecture (Modules MANDATORY)

LayerLocationMax Lines
Handlerssrc/modules/[feature]/handlers.rs50
Servicessrc/modules/[feature]/services.rs100
Repositoriessrc/modules/[feature]/repository.rs100
Traitssrc/modules/[feature]/traits.rs30
Modelssrc/modules/[feature]/models.rs50
Sharedsrc/core/{services,traits,models}/-

NEVER use flat src/ structure - always src/modules/[feature]/


Critical Rules (MANDATORY)

RuleValue
File limit100 lines (split at 90)
Handlers< 50 lines, delegate to services
Traitstraits.rs or src/core/traits/ ONLY
Rustdoc/// on every public item
Error handlingUse thiserror for custom errors
GenericsUse trait bounds, not concrete types

Reference Guide

Concepts
TopicReferenceWhen to consult
SOLID Overviewsolid-principles.mdQuick reference
SRPsingle-responsibility.mdFat structs
OCPopen-closed.mdAdding impls
LSPliskov-substitution.mdTrait contracts
ISPinterface-segregation.mdFat traits
DIPdependency-inversion.mdGenerics/DI
Architecturearchitecture-patterns.mdModular crate
Templates
TemplateWhen to use
module.mdFeature module structure
service.mdBusiness logic service
trait-def.mdTrait definition
handler.mdHTTP handler (Axum)
error.mdCustom errors (thiserror)
test.mdUnit + integration tests

Forbidden

Anti-PatternFix
Files > 100 linesSplit at 90
Traits in impl filesMove to traits.rs
Box<dyn Any>Use proper trait bounds
Flat src/ structureUse src/modules/[feature]/
Unwrap in library codeUse Result<T, E>

Comments

Markdown supported