From 0451a98f1456fd89df0f6db05ad76aa0799a157f Mon Sep 17 00:00:00 2001 From: James Date: Tue, 17 Feb 2026 12:25:35 -0500 Subject: [PATCH] chore: add CLAUDE.md for code quality conventions Adds a condensed CLAUDE.md to standardize Claude Code behavior across init4 Rust repos per ENG-1765. Co-Authored-By: Claude Opus 4.6 --- CLAUDE.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..37595a0 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,33 @@ +# Trevm + +## Commands + +- `cargo +nightly fmt` - format +- `cargo clippy --all-features --all-targets` - lint with features +- `cargo clippy --no-default-features --all-targets` - lint without +- `cargo t --all-features` - test with all features +- `cargo t --no-default-features` - test without features + +Pre-commit: clippy (both feature sets) + fmt. Never use `cargo check/build`. + +## Style + +- Functional combinators over imperative control flow +- `let else` for early returns, avoid nesting +- No glob imports; group imports from same crate; no blank lines between imports +- Private by default, `pub(crate)` for internal, `pub` for API only; never `pub(super)` +- `thiserror` for library errors, never `anyhow` or `eyre` in library code +- `tracing` for instrumentation: instrument work items not long-lived tasks; `skip(self)` on methods +- Builders for structs with >4 fields or multiple same-type fields +- Tests: fail fast with `unwrap()`, never return `Result`; unit tests in `mod tests` +- Rustdoc on all public items with usage examples; hide scaffolding with `#` +- `// SAFETY:` comments on all unsafe blocks +- Minimize generics in user-facing API; provide concrete types where possible + +## Crate Notes + +- Single library crate using the **typestate pattern** to enforce correct EVM usage at compile time +- State flow: `EvmNeedsCfg` -> `EvmNeedsBlock` -> `EvmNeedsTx` -> `EvmReady` -> `EvmTransacted` +- Extensive feature flags: test with both `--all-features` and `--no-default-features` +- Key features: `call`, `concurrent-db`, `estimate_gas`, `tracing-inspectors`, `alloy-db`, `test-utils` +- Uses `#[cfg_attr(docsrs, doc(cfg(...)))]` for feature-gated documentation