Skip to content

tooling(claude): the clang-format edit hook formats with pre-commit's pinned clang-format, as CI does (#3022) - #3023

Merged
mgradwohl merged 1 commit into
mainfrom
tooling/format-hook-pinned-3022
Oct 26, 2026
Merged

mgradwohl merged 1 commit into
mainfrom
tooling/format-hook-pinned-3022

Conversation

@mgradwohl

Copy link
Copy Markdown
Owner

Description

Fixes #3022

Claude Code's PostToolUse format hook ran whatever clang-format is on PATH. CI's Format C++ code uses the mirrors-clang-format rev pinned in .pre-commit-config.yaml. #2947 passed the hook locally (Ubuntu's 22.1.2) and failed CI (v22.1.8). The same skew #916 fixed for tools/check-format.sh.

The hook now:

  • with pre-commit installed: runs pre-commit run clang-format --files "$f" from the file's repository root, so the edit gets exactly CI's formatter. That command exits 1 when it changed the file, which is ignored.
  • without pre-commit: falls back to clang-format -i from PATH, warning that it may differ from CI.

It stays quiet and non-blocking otherwise, and still skips non-C++ files.

PR Size

✅ Small (one command in .claude/settings.json).

Type of Change

  • Build/CI improvement (agent tooling)

Checklist

  • I have read the CONTRIBUTING guidelines
  • I have run pre-commit run --all-files or installed pre-commit hooks

Testing

I piped the hook a synthetic Edit payload for a badly formatted .cpp. int main( ) {return 0;} came out formatted by pre-commit's pinned clang-format, and the scratch file was removed afterwards.

Additional Notes

This is checked-in agent configuration, so it's for the maintainer's look.

🤖 Generated with Claude Code

… pinned clang-format, as CI does (#3022)

It used the PATH clang-format, which can differ from the mirrors-clang-format
rev CI pins (#2947 passed it locally with 22.1.2 and failed CI's 22.1.8). With
pre-commit installed the hook now runs its clang-format hook on the file;
without it, it falls back to the PATH binary and says so.

Fixes #3022

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mgradwohl mgradwohl added this to the v0.10.0 milestone Oct 26, 2026
@mgradwohl mgradwohl added tooling Developer tooling, CI, editor config, and automation agent:WSL Owned by the Linux/WSL Claude session (bug-fix conveyor) labels Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@mgradwohl
mgradwohl merged commit a86373b into main Oct 26, 2026
27 checks passed
@mgradwohl
mgradwohl deleted the tooling/format-hook-pinned-3022 branch October 26, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:WSL Owned by the Linux/WSL Claude session (bug-fix conveyor) tooling Developer tooling, CI, editor config, and automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tooling] Claude Code's clang-format edit hook uses the PATH clang-format, not CI's pinned pre-commit version

1 participant