Skip to content

Fix install.sh hook maintenance gaps - #137

Merged
haacked merged 3 commits into
mainfrom
haacked/bash-errors
Jul 8, 2026
Merged

Fix install.sh hook maintenance gaps#137
haacked merged 3 commits into
mainfrom
haacked/bash-errors

Conversation

@haacked

@haacked haacked commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Two related fixes to how ai/install.sh manages Claude Code hooks.

Every hook install run backs up ~/.claude/settings.json but never removes old backups, so they pile up indefinitely. One machine had accumulated 100 of them going back to July 2025, about 900K of dead weight in ~/.claude. The install step now keeps only the 5 most recent backups after creating a new one.

Separately, rtk's Bash-rewrite hook (registered via rtk hook claude) turns out to be unsafe for two commands several skills rely on. find hard-fails under rtk's reimplementation when passed -not or -exec. Bare git diff (without --stat) inconsistently strips its own diff/index/---/+++ headers depending on output size, sometimes returning a condensed summary instead of the real patch. create-pr, commit, and test-plan all read full diffs verbatim to write descriptions, so this excludes both commands from the hook via rtk's own exclude_commands config, applied idempotently on every install.

Test plan

  • Ran the prune snippet standalone against a directory seeded with 7 backups at distinct mtimes; confirmed it kept the 5 newest and removed the 2 oldest.
  • Ran the rtk-exclusion block against a fake HOME with four scenarios: pristine config, already-configured config, a config with a pre-existing custom exclude_commands value, and a missing config file entirely. Confirmed each behaves correctly (patches, no-ops, warns without clobbering, and bootstraps via rtk config --create, respectively).
  • Verified ai/install.sh still passes sh -n.

Every hook install run backed up ~/.claude/settings.json but never
removed old backups, so they accumulated indefinitely (100 files, ~900K
by the time this was noticed). Now keeps only the 5 most recent.
@haacked
haacked marked this pull request as ready for review July 8, 2026 22:19
@haacked
haacked requested a review from Copilot July 8, 2026 22:19

This comment was marked as outdated.

find hard-fails under rtk's reimplementation when passed -not or -exec,
and bare git diff (without --stat) inconsistently strips its own
diff/index/---/+++ headers depending on output size. Several skills
(create-pr, commit, test-plan) read full diffs verbatim to write
descriptions, so exclude both commands from the hook at the rtk config
level instead of working around it in every skill.
@haacked haacked changed the title Prune old settings.json backups in install.sh Fix install.sh hook maintenance gaps Jul 8, 2026
@haacked
haacked requested a review from Copilot July 8, 2026 22:56

This comment was marked as outdated.

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 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread ai/install.sh
@haacked
haacked merged commit c0ff2b4 into main Jul 8, 2026
1 check passed
@haacked
haacked deleted the haacked/bash-errors branch July 8, 2026 23:05
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.

2 participants