Use files: to limit hooks to relevant directories. This is the #1 perf lever.
- id: clang-format
files: ^(src|include)/.*\.(cpp|cc|cxx|h|hpp)$# Exclude generated code
files: ^src/(?!generated/|proto/).*\.(cpp|hpp)$
# Library (public headers + private src)
files: ^(include|src)/.*\.(cpp|cc|cxx|h|hpp|hxx)$
# Application (no public headers)
files: ^src/.*\.(cpp|cc|cxx|h|hpp)$
# Qt (skip moc_)
files: ^src/(?!moc_|ui_).*\.(cpp|h)$
# CUDA
files: ^src/.*\.(cpp|cc|cxx|cu|cuh|h|hpp)$
# Embedded / bare-metal C
files: \.(c|h|s|S)$- Don't lint headers directly with
clang-tidy— they're processed when a.cppincludes them. Restrict tofiles: ^src/.*\.cpp$. - Use
--jobs=Nforclang-tidy— start withN=2, go up to CPU core count. --dry-runforclang-formatin CI — fail with a readable diff instead of auto-committing formatting.