Fix sync-ai-rules not triggering on rule file deletions#89
Open
Kush Agrawal (kush-duolingo) wants to merge 2 commits into
Open
Fix sync-ai-rules not triggering on rule file deletions#89Kush Agrawal (kush-duolingo) wants to merge 2 commits into
Kush Agrawal (kush-duolingo) wants to merge 2 commits into
Conversation
pre-commit gathers staged files with --diff-filter=ACMRTUXB, which excludes D (deleted). When a .cursor/rules/*.mdc file is deleted, it never matches the hook's files pattern, so the hook is silently skipped and the corresponding .claude/rules/generated/*.md output is left orphaned. Switch to always_run: true so the hook runs on every commit. The hook's internal wipe-and-regenerate logic already handles the case where no source rules have changed (it regenerates from whatever .cursor/rules/ files currently exist, deleting outputs for any that are gone). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
There was a problem hiding this comment.
This hook takes 6 seconds on my laptop according to time pre-commit run sync-ai-rules --all-files. That's fine for the relatively rare commit that touches AI rule files but it's a pretty steep price to pay on every commit.
Pre-commit's author recommends the workaround of having the hook run git diff itself and inspect the output to determine whether the hook should no-op
(It's also kinda fishy that this hook takes so long in the first place - see #90)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pre-commit gathers staged files with
--diff-filter=ACMRTUXB(everything exceptD), so deleting a.cursor/rules/*.mdcfile never matches the hook'sfilespattern and the hook is silently skipped. This leaves orphaned outputs in.claude/rules/generated/.Switches to
always_run: trueso the hook runs on every commit. The hook's internal wipe-and-regenerate logic already handles no-ops correctly -- it regenerates from whatever.cursor/rules/files exist, deleting outputs for any that are gone.Discovered while cleaning up duplicate rules in duolingo-android and duolingo-ios, where deleting cursor rules left behind orphaned claude rules that should have been auto-cleaned.