chore(claude): share team hooks and trim CLAUDE.md - #269
Conversation
- Drop the LINQ and comment-style rules; both are default behavior and only dilute the project-specific rules around them - Reduce the O(n^2) and bug-fix rules to their non-obvious half - Replace all em dashes with sentence-appropriate punctuation
- Track only .claude/settings.json; the rest of .claude stays personal - Hooks normalize agent-written files to CRLF and gate git staging, both of which previously failed silently - Warn at prepare time when a local ignore rule hides the file, since git reports no error when it does
Bundle ReportBundle size has no change ✅ |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #269 +/- ##
=======================================
Coverage 45.38% 45.38%
=======================================
Files 916 916
Lines 52787 52787
Branches 5005 5005
=======================================
Hits 23960 23960
Misses 28199 28199
Partials 628 628
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
Pull request overview
This PR updates the repo’s AI-agent tooling setup by (1) trimming and sharpening CLAUDE.md guidance and (2) sharing team-wide Claude Code hooks via a tracked .claude/settings.json, with install-time detection of local ignore rules that would hide it.
Changes:
- Add shared Claude Code hooks (
.claude/settings.json) and document them (HOOKS.md), plus update.gitignoreto track only that shared settings file. - Add an install-time warning script (
scripts/check-agent-config.js) and run it fromprepare. - Update
README.mdand streamlineCLAUDE.mdwording while preserving project-specific rules.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/check-agent-config.js | New install-time warning if .claude/settings.json is being hidden by local ignore rules. |
| README.md | Document HOOKS.md and explain tracked .claude/settings.json vs. personal .claude/ content. |
| package.json | Run check-agent-config.js during prepare after Husky setup. |
| HOOKS.md | New documentation for the shared hook behaviors and debugging gotchas. |
| CLAUDE.md | Refine instructions and reference HOOKS.md for the CRLF enforcement hook details. |
| .gitignore | Track only .claude/settings.json; ignore the rest of .claude/. |
| .claude/settings.json | Introduce shared PreToolUse/PostToolUse hooks (CRLF normalization and staging confirmation). |
- Check jq and unix2dos at prepare time; the CRLF hook ends in `|| true` so a missing tool would otherwise stop normalizing with no sign - Parse check-ignore output on the tab, not on ":", which a global excludesFile breaks with its drive letter
The text asserted both tools were missing and named a platform, which was wrong when only one is absent. Defer install guidance to HOOKS.md.
| - **Routes**: Absolute `/api/{area}/{controller}` + `ApiController` base. Never `[Area]` on APIs (causes 403) | ||
| - **Frontend API calls**: Service layer + `useFetch()`, never raw `fetch()` (must unwrap `{ result, success }`) | ||
| - **API URL**: `${import.meta.env.VITE_API_URL}` — never hardcode `/api/` (TEST uses `/2/` prefix) | ||
| - **API URL**: `${import.meta.env.VITE_API_URL}`, never hardcode `/api/` (TEST uses `/2/` prefix) |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
scripts/check-agent-config.js:89
- The header comment says this script must never block an install, but an unexpected error outside the existing
execFileSynctry/catch blocks (e.g., future refactors) would currently cause a non-zero exit and failnpm installbecause it runs fromprepare. Wrappingmain()in a top-level try/catch keeps this check best-effort as intended.
function main() {
checkSharedSettings()
checkHookTools()
}
| function canRun(tool) { | ||
| try { | ||
| execFileSync(tool, ["--version"], { stdio: "ignore" }) | ||
| return true | ||
| } catch { | ||
| return false | ||
| } | ||
| } |
What
Two independent changes to the agent configuration, one commit each.
1. Trim CLAUDE.md of rules the model already follows by default (LINQ style, comment style), and reduce two others to their non-obvious half. Prompted by Anthropic cutting 80% of Claude Code's own system prompt: as models improve, generic instructions dilute the project-specific ones rather than adding to them. No project-specific rule was removed.
2. Share the team's Claude Code hooks by tracking
.claude/settings.json. Everything else under.claude/stays personal and gitignored.Why hooks rather than more documentation
Two rules in CLAUDE.md were being violated silently, with no error in either case:
filestill reports "CRLF line terminators" when only some lines are LF, so the obvious check misses it. APostToolUsehook now runsunix2doson written files.PreToolUsehook now forces a prompt ongit add,git stage, andgit commit -a. It usesaskrather thandenyso legitimate post-approval staging still works.What this means for you
Pulling this changes what runs on your machine: Claude Code executes the hooks in
.claude/settings.jsonwhen you open the project. In plain terms, they are:unix2doson itgit add, show a confirmation promptBoth are in the diff. Nothing else under
.claude/is tracked, so yoursettings.local.json, MCP servers and permissions stay personal.If the file does not appear
A bare
.claudeline in.gitignoreor.git/info/excludehides it, and git reports no error when it does.npm installnow warns. Fix with:Notes
HOOKS.mddocuments the hooks and two gotchas that cost real time here:jqemits CRLF on stdout on Windows, andgit check-ignore -vexits 0 for negated matches (which made the first version of the warning script fire on correctly configured repos).