How to Use These Rules
Import Strategies
Section titled “Import Strategies”Option A — Git Submodule (recommended)
Section titled “Option A — Git Submodule (recommended)”Add the library as a git submodule inside .claude/. The path becomes stable and relative
across all machines, and you get explicit version pinning per project.
git submodule add https://github.com/dohrm/claude-rules .claude/claude-rulesThen reference rules with a relative path:
@.claude/claude-rules/rules/rust/code-style.mdUpdate to latest when needed:
git submodule update --remote .claude/claude-rulesOption B — Direct @-import
Section titled “Option B — Direct @-import”Reference an absolute path on the local machine. Simpler to set up, but path varies per machine.
@/path/to/claude-rules/rules/rust/code-style.mdOption C — Copy into project
Section titled “Option C — Copy into project”Copy relevant files into .claude/rules/. Use when you need project-specific overrides
or want no external dependency.
Rust — Single Crate
Section titled “Rust — Single Crate”Minimal setup for a standalone Rust service.
my-service/├── CLAUDE.md├── README.md└── .claude/ └── rules/ ├── code-style.md → @/path/to/claude-rules/rules/rust/code-style.md ├── error-handling.md → @/path/to/claude-rules/rules/rust/error-handling.md ├── logging.md → @/path/to/claude-rules/rules/rust/logging.md └── quality-gates.md → @/path/to/claude-rules/rules/rust/quality-gates.mdCLAUDE.md:
# My Service
@README.md
## Stack- Rust 2024, tokio, axumRust — Multi-Crate Workspace with Hexagonal Architecture
Section titled “Rust — Multi-Crate Workspace with Hexagonal Architecture”my-app/├── CLAUDE.md├── README.md├── .claude/│ └── rules/│ ├── code-style.md → @/path/to/claude-rules/rules/rust/code-style.md│ ├── error-handling.md → @/path/to/claude-rules/rules/rust/error-handling.md│ ├── logging.md → @/path/to/claude-rules/rules/rust/logging.md│ ├── quality-gates.md → @/path/to/claude-rules/rules/rust/quality-gates.md│ └── hexagonal.md → @/path/to/claude-rules/rules/rust/hexagonal.md└── crates/ ├── domain/ ├── infrastructure/ └── api/CLAUDE.md:
# My App
@README.md
## Stack- Rust 2024 edition, tokio, axum, MongoDB- Hexagonal architecture — see .claude/rules/hexagonal.mdRust — Multi-Crate Workspace with CQRS + Leptos Portal
Section titled “Rust — Multi-Crate Workspace with CQRS + Leptos Portal”The most common full-stack setup. Generic Rust rules at workspace root, Leptos-specific rules scoped to the portal crate via subdirectory CLAUDE.md (loaded on demand).
my-app/├── CLAUDE.md├── README.md├── .claude/│ └── rules/│ ├── code-style.md → @/path/to/claude-rules/rules/rust/code-style.md│ ├── error-handling.md → @/path/to/claude-rules/rules/rust/error-handling.md│ ├── logging.md → @/path/to/claude-rules/rules/rust/logging.md│ ├── quality-gates.md → @/path/to/claude-rules/rules/rust/quality-gates.md│ ├── hexagonal.md → @/path/to/claude-rules/rules/rust/hexagonal.md│ └── cqrs.md → @/path/to/claude-rules/rules/rust/cqrs.md└── crates/ ├── domain/ ├── infrastructure/ ├── api/ └── portal/ # Leptos SSR frontend crate └── CLAUDE.md # loaded on demand — only when working in portal/crates/portal/CLAUDE.md:
# Portal — Leptos SSR frontend
This crate is the user-facing UI. It uses Leptos 0.8 with SSR + WASM hydration.Server functions are SSR-only — do not introduce WASM-incompatible dependencies.
@/path/to/claude-rules/rules/leptos/patterns.md@/path/to/claude-rules/rules/leptos/gotchas.mdWhy subdirectory CLAUDE.md for portal? Leptos rules are only relevant when working inside
portal/. Using a subdirectory CLAUDE.md ensures they load on demand — no token cost when working elsewhere in the workspace. See loading mechanics.
Go — Hexagonal Service
Section titled “Go — Hexagonal Service”my-go-service/├── CLAUDE.md├── README.md└── .claude/ └── rules/ ├── quality-gates.md → @/path/to/claude-rules/rules/go/quality-gates.md └── hexagonal-packaging.md → @/path/to/claude-rules/rules/go/hexagonal-packaging.mdCLAUDE.md:
# My Go Service
@README.md
## Stack- Go 1.23+, chi, MongoDB- Hexagonal packaging — see .claude/rules/hexagonal-packaging.mdLanguage Rule
Section titled “Language Rule”Always add the language rule — either project-specific (if you want to enforce a specific communication language) or from the library (generic):
@/path/to/claude-rules/rules/language.mdOr override directly for the project:
# Language- All written artifacts must be in **English**.- Communicate with the user in **French**.Rule Precedence
Section titled “Rule Precedence”When a project rule conflicts with an imported library rule, the project rule wins.
Place project-specific overrides after the @-import in the same file:
@/path/to/claude-rules/rules/rust/code-style.md
## Project Overrides- Function size hard limit: 80 lines (stricter than library default)