Skip to content

chore(claude): share team hooks and trim CLAUDE.md - #269

Open
rlorenzo wants to merge 4 commits into
mainfrom
chore/shared-agent-hooks
Open

chore(claude): share team hooks and trim CLAUDE.md#269
rlorenzo wants to merge 4 commits into
mainfrom
chore/shared-agent-hooks

Conversation

@rlorenzo

Copy link
Copy Markdown
Contributor

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:

  • CRLF line endings. The agent's Write/Edit tools emit bare LF, so edits landed as LF inside otherwise-CRLF files. file still reports "CRLF line terminators" when only some lines are LF, so the obvious check misses it. A PostToolUse hook now runs unix2dos on written files.
  • "Never stage files until after code review." A PreToolUse hook now forces a prompt on git add, git stage, and git commit -a. It uses ask rather than deny so 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.json when you open the project. In plain terms, they are:

  • after the agent writes a file, run unix2dos on it
  • before git add, show a confirmation prompt

Both are in the diff. Nothing else under .claude/ is tracked, so your settings.local.json, MCP servers and permissions stay personal.

If the file does not appear

A bare .claude line in .gitignore or .git/info/exclude hides it, and git reports no error when it does. npm install now warns. Fix with:

.claude/*
!.claude/settings.json

Notes

HOOKS.md documents the hooks and two gotchas that cost real time here: jq emits CRLF on stdout on Windows, and git check-ignore -v exits 0 for negated matches (which made the first version of the warning script fire on correctly configured repos).

rlorenzo added 2 commits July 25, 2026 12:51
- 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
Copilot AI review requested due to automatic review settings July 25, 2026 20:09
@codecov-commenter

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov-commenter

codecov-commenter commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.38%. Comparing base (f9ed67b) to head (58420f7).

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           
Flag Coverage Δ
backend 45.42% <ø> (ø)
frontend 44.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .gitignore to track only that shared settings file.
  • Add an install-time warning script (scripts/check-agent-config.js) and run it from prepare.
  • Update README.md and streamline CLAUDE.md wording 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).

Comment thread .claude/settings.json
Comment thread scripts/check-agent-config.js
- 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
Copilot AI review requested due to automatic review settings July 26, 2026 00:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Comment thread scripts/check-agent-config.js Outdated
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.
Copilot AI review requested due to automatic review settings July 26, 2026 05:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Comment thread CLAUDE.md
Comment on lines 33 to +35
- **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)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 execFileSync try/catch blocks (e.g., future refactors) would currently cause a non-zero exit and fail npm install because it runs from prepare. Wrapping main() in a top-level try/catch keeps this check best-effort as intended.
function main() {
    checkSharedSettings()
    checkHookTools()
}

Comment on lines +47 to +54
function canRun(tool) {
try {
execFileSync(tool, ["--version"], { stdio: "ignore" })
return true
} catch {
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants