Skip to content

Carry the hook improvements that were only on one machine - #21

Closed
sneg55 wants to merge 1 commit into
mainfrom
fix/carry-installed-hook-improvements
Closed

sneg55 wants to merge 1 commit into
mainfrom
fix/carry-installed-hook-improvements

Conversation

@sneg55

@sneg55 sneg55 commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Three changes had been made to the installed copies in ~/.claude/hooks and never made it back here. Since install.sh copies hooks/*.sh over the installed ones unconditionally, running it would have reverted all three without saying anything.

check-file-size.sh: per-project thresholds

Reads WARN_THRESHOLD / BLOCK_THRESHOLD from <repo>/.harness/file-size.conf when present, falling back to the built-in defaults.

The motivating case: one project's own rules said to consider splitting above ~300 lines, while the hook warned at 200. Of 585 warns in that project's ledger, 98% were for files the project had already decided were fine, across 95 distinct files. A guardrail that fires on things you have chosen to accept trains you to ignore it.

Three details are deliberate:

  • The config is located from the edited file's git root, matching how lib/log-event.sh places the ledger. It is found whatever directory the session runs from, and sits next to the ledger by construction.
  • The two numbers are read by pattern, not by sourcing. A config file inside a repo that gets sourced is arbitrary shell running on every edit.
  • If the file is in no git repo, there is no project and no config is consulted. An earlier draft fell back to $PWD, which handed files edited outside any repo the thresholds of whatever project the shell happened to be in.

Verified across four paths: outside a repo, 230 lines still warns at the default 200; in a project configured to 260, 283 warns and 256 is silent; 310 still blocks at 300.

Also picks up a .daml case (300/450) that was sitting uncommitted in a local checkout.

lint-on-edit.sh: log which rule failed

The ledger detail was the constant string "lint or typecheck failed", which makes it uncountable: you cannot tell one rule breaking 200 times from 200 rules breaking once. It was the largest single cluster in one project's ledger and the only one that could not be analyzed.

Now takes the rule ids out of the output, handling both ESLint stylish (id last on the line) and Biome (lint/suspicious/noExplicitAny), capped at three and deduplicated. Falls back to unclassified rather than dropping the event.

This immediately paid for itself: with real ids, the largest remaining cluster turned out to be no-unused-vars + jsx-no-undef, which is the signature of a declaration and its use landing in two separate edits, and that became a project rule.

check-silent-errors.sh: skip scratchpad and temp paths

A throwaway diagnostic in the session scratchpad gets deleted with the session. Holding it to the re-raise-or-log-with-context contract is noise, not safety.

Testing

All three ran continuously for a week on a large TypeScript monorepo before this PR (~1,700 ledger events). The file-size thresholds were verified against the four boundary cases above.

Three changes that had been made to the installed copies in ~/.claude/hooks
and never made it back here, so install.sh would have reverted them.

check-file-size: per-project thresholds from <repo>/.harness/file-size.conf,
located from the edited file's git root and read by pattern rather than
sourced, since a config file in a repo that gets sourced is arbitrary shell
running on every edit. Falls back to the built-in defaults outside a repo.
Also keeps the .daml case that was sitting uncommitted here.

lint-on-edit: log which rules failed instead of the constant string "lint or
typecheck failed". A constant detail makes the ledger uncountable, and it was
the single largest unanalyzable cluster in one project's signal.

check-silent-errors: skip scratchpad and temp paths. A throwaway diagnostic
that gets deleted with the session does not owe anyone a re-raise.
@sneg55

sneg55 commented Sep 12, 2026

Copy link
Copy Markdown
Owner Author

Superseded by 2b04e99, which carries all three changes (per-project thresholds read by pattern, rule ids in the lint ledger, scratchpad skip). Every conflict resolves to main. Dropped: the .daml tier (no consumer anywhere) and the /tmp skip (main excludes it deliberately, see hooks/README.md).

@sneg55 sneg55 closed this Sep 12, 2026
@sneg55
sneg55 deleted the fix/carry-installed-hook-improvements branch September 12, 2026 10:57
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.

1 participant