diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 00000000000..373a85844c2 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,15 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "command": "echo '\n[Reminder] Run: cargo fmt --all && make lint-fix && cargo check'" + } + ] + } + ] + } +} diff --git a/CLAUDE.md b/CLAUDE.md index 3e9ab169f3c..e7109e30176 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,6 +2,12 @@ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. +## CRITICAL - Always Follow + +After completing ANY code changes: +1. **MUST** run `cargo fmt --all && make lint-fix` to format and fix linting issues +2. **MUST** run `cargo check` to verify compilation before considering task complete + ## Development Commands **Important**: Always branch from `unstable` and target `unstable` when creating pull requests. diff --git a/Cargo.lock b/Cargo.lock index e12c180f279..d46829d3a0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1665,6 +1665,12 @@ dependencies = [ "serde_core", ] +[[package]] +name = "cargo-husky" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b02b629252fe8ef6460461409564e2c21d0c8e77e0944f3d189ff06c4e932ad" + [[package]] name = "cargo-platform" version = "0.1.9" @@ -5328,6 +5334,7 @@ dependencies = [ "beacon_processor", "bls", "boot_node", + "cargo-husky", "clap", "clap_utils", "console-subscriber", diff --git a/Cargo.toml b/Cargo.toml index fd7ca381e1b..8717333e0a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -120,6 +120,7 @@ bytes = "1.11.1" # Turn off c-kzg's default features which include `blst/portable`. We can turn on blst's portable # feature ourselves when desired. c-kzg = { version = "2.1", default-features = false } +cargo-husky = { version = "1", default-features = false, features = ["precommit-hook", "run-cargo-fmt"] } cargo_metadata = "0.19" clap = { version = "4.5.4", features = ["derive", "cargo", "wrap_help"] } clap_utils = { path = "common/clap_utils" } diff --git a/lighthouse/Cargo.toml b/lighthouse/Cargo.toml index 000c6fd0da4..814677233bb 100644 --- a/lighthouse/Cargo.toml +++ b/lighthouse/Cargo.toml @@ -10,6 +10,7 @@ rust-version = "1.88.0" # to assert properties of the compilation target. [package.metadata.cargo-udeps.ignore] normal = ["target_check"] +development = ["cargo-husky"] [features] default = ["slasher-lmdb", "beacon-node-leveldb"] @@ -84,6 +85,7 @@ malloc_utils = { workspace = true, features = [] } beacon_node = { workspace = true, features = ["testing"] } beacon_node_fallback = { workspace = true } beacon_processor = { workspace = true } +cargo-husky = { workspace = true } eth2 = { workspace = true } initialized_validators = { workspace = true } lighthouse_network = { workspace = true }