-
Notifications
You must be signed in to change notification settings - Fork 969
Add critical instructions and hooks for Claude Code #8715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: unstable
Are you sure you want to change the base?
Conversation
- Add CRITICAL section at top of CLAUDE.md to ensure Claude always runs `cargo fmt --all && make lint-fix` and `cargo check` after code changes - Add .claude/settings.json with post-tool-call hook to remind about formatting and linting after Edit/Write operations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
.claude/settings.json
Outdated
| "post-tool-call": [ | ||
| { | ||
| "matcher": "Edit|Write", | ||
| "command": "echo '\n[Reminder] Run: cargo fmt --all && make lint-fix && cargo check'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find post-tool-call on claude documentation, is this documented somewhere else?
https://code.claude.com/docs/en/hooks#common-json-fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm should be post-tool-use?
|
I thought the plan was to add a commit hook that checks |
Do we want to have git hooks that apply to everyone? |
| ] | ||
| } | ||
| ] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this format until my local claude CLI accepted the format.
Cargo.toml
Outdated
| # 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"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm I'm not sure if it's worth introducing a dependency for this. It's also unmaintained, but I see benefits over native git hooks - without devs having to manually set it up.
Now i feel like it might be better to just include it in the AI file you originally suggested.
With cargo-husky requiring at least a cargo task to trigger, i think there might be a chance that this never gets run, e.g. AI-generated PRs etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add a make command to add it your local dir, and then we expect team members to add it
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "echo '\n[Reminder] Run: cargo fmt --all && make lint-fix && cargo check'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need cargo check if we already run clippy
pawanjay176
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dapplion I'm wondering why we can't have our own local versions of the settings.json. Why does this need to be committed for everyone?
settings.json at project level is good for sharing hooks and tooling across the team. Your .claude/settings.local.json is not committed and overrides the project level settings https://code.claude.com/docs/en/settings |
Summary
.claude/settings.jsonwith post-tool-call hook to remind about formatting and linting after Edit/Write operationsThis helps ensure Claude Code consistently follows the project's code quality requirements.
Test plan
🤖 Generated with Claude Code
(Lion here)
Claude recognizes that it ignored Claude.md most of the time, and recommends this edits to actually lint and format when doing changes.