This file is loaded by Claude Code on every session. These rules are MANDATORY.
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-features
cargo build --release --all-features- NO panic-capable unwrapping —
.unwrap(),.expect(), and any shorthand that can panic are BANNED in production code. Use?,unwrap_or,if let, or explicit error returns. - NO dead code — No unused variables, parameters, or imports. Code must compile with zero warnings.
#[allow(dead_code)]is not a fix. - NO incomplete implementations —
todo!(),unimplemented!(), placeholder returns, and empty match arms are BANNED. Every code path must be fully implemented. - Business logic must be verifiable — All code must pass
cargo check. No speculative interfaces, no pseudo-implementations, no "will fix later" stubs. - Validate with
cargo checkandcargo fix— Do NOT usecargo runorcargo buildfor validation during development. Check correctness first. - Explicit API and error handling — Validate all external inputs at boundaries. Never use panic as a substitute for error branches. Return typed errors.
- Minimize allocations and copies — Follow ownership and borrowing best practices. Clone only when necessary (async move, cross-thread). Prefer
&stroverString,Cowover clone,Arcover deep copy.
?with.context("msg")preferred- Never silently swallow errors — log before
.ok()or.unwrap_or() tracing::warn!()when intentionally discarding errors
- Sync:
parking_lot::Mutex(no poison, no unwrap) - Async:
tokio::sync::Mutex(.lock().await) - BANNED:
std::sync::Mutexin production (poisons on panic)
- Parameterized queries only:
sqlx::query("...WHERE id = $1").bind(id) - Validate dynamic identifiers:
^[a-zA-Z_][a-zA-Z0-9_]{0,62}$
- Every
unsafeblock requires// SAFETY:comment - Validate inputs BEFORE the unsafe block
- NEVER log tokens, API keys, passwords, auth headers
- Sanitize URLs before logging
- Prefer
&stroverStringin function params Cow<', str>to avoid unnecessary cloningArc<str>for shared immutable strings
feat(scope): description
fix(scope): description
refactor(scope): description
English only in commits and code comments.