Scripts: Run the clang-tidy Claude Code hook in the background on C++ files libeigen/eigen!3422 Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
diff --git a/.agents/ci.md b/.agents/ci.md index d37c30a..98fb81d 100644 --- a/.agents/ci.md +++ b/.agents/ci.md
@@ -208,8 +208,11 @@ `ci/scripts/run-clang-tidy.sh` does for merge requests. It skips silently when clang-tidy is not installed, and shows the user a non-blocking notice when a file's translation unit does not compile. -Claude Code sessions run both automatically through the hooks registered in `.claude/settings.json`. After changing -either script, run their unit tests, [`scripts/test_check_style.py`](../scripts/test_check_style.py) and +Claude Code sessions run both automatically through the hooks registered in `.claude/settings.json`. `check_style.py` +runs after every Edit or Write. `clang_tidy_hook.py` runs only for `.h`, `.cpp`, `.cu` and `.inc` files, in the +background, because parsing a module takes 10–30 s. Its findings arrive as a reminder after the edit has returned, and +they name the file they apply to. After changing either script, run their unit tests, +[`scripts/test_check_style.py`](../scripts/test_check_style.py) and [`scripts/test_clang_tidy_hook.py`](../scripts/test_clang_tidy_hook.py); `checkformat:lint` runs them too. The whole-tree codespell invocation used by CI can expose pre-existing findings. Do not modify unrelated files merely to
diff --git a/.claude/settings.json b/.claude/settings.json index e4add86..bc81c8a 100644 --- a/.claude/settings.json +++ b/.claude/settings.json
@@ -10,6 +10,58 @@ }, { "type": "command", + "if": "Edit(**/*.h)", + "asyncRewake": true, + "timeout": 300, + "command": "python3 \"$CLAUDE_PROJECT_DIR/scripts/clang_tidy_hook.py\" --claude-hook" + }, + { + "type": "command", + "if": "Write(**/*.h)", + "asyncRewake": true, + "timeout": 300, + "command": "python3 \"$CLAUDE_PROJECT_DIR/scripts/clang_tidy_hook.py\" --claude-hook" + }, + { + "type": "command", + "if": "Edit(**/*.cpp)", + "asyncRewake": true, + "timeout": 300, + "command": "python3 \"$CLAUDE_PROJECT_DIR/scripts/clang_tidy_hook.py\" --claude-hook" + }, + { + "type": "command", + "if": "Write(**/*.cpp)", + "asyncRewake": true, + "timeout": 300, + "command": "python3 \"$CLAUDE_PROJECT_DIR/scripts/clang_tidy_hook.py\" --claude-hook" + }, + { + "type": "command", + "if": "Edit(**/*.cu)", + "asyncRewake": true, + "timeout": 300, + "command": "python3 \"$CLAUDE_PROJECT_DIR/scripts/clang_tidy_hook.py\" --claude-hook" + }, + { + "type": "command", + "if": "Write(**/*.cu)", + "asyncRewake": true, + "timeout": 300, + "command": "python3 \"$CLAUDE_PROJECT_DIR/scripts/clang_tidy_hook.py\" --claude-hook" + }, + { + "type": "command", + "if": "Edit(**/*.inc)", + "asyncRewake": true, + "timeout": 300, + "command": "python3 \"$CLAUDE_PROJECT_DIR/scripts/clang_tidy_hook.py\" --claude-hook" + }, + { + "type": "command", + "if": "Write(**/*.inc)", + "asyncRewake": true, + "timeout": 300, "command": "python3 \"$CLAUDE_PROJECT_DIR/scripts/clang_tidy_hook.py\" --claude-hook" } ]