[BUG] Hookify truncates regex patterns containing triple dashes

Status Open
Maintainer reply None cached
Activity 3 comments · opened Sep 9, 2026

What's wrong?

Hookify splits frontmatter with content.split('---', 2). This treats --- inside a regex value as the closing delimiter, truncating the pattern and moving the rest of the frontmatter into the rule message.

For example, pattern: ^---$ is parsed as ^, so the rule silently matches the wrong text.

Expected behavior

Only a standalone, unindented --- line should close frontmatter. Dashes inside values should remain unchanged.

Steps to reproduce

from hookify.core.config_loader import extract_frontmatter

frontmatter, message = extract_frontmatter("""---
name: markdown-rule
event: file
pattern: ^---$
---
Detect Markdown separators.
""")

assert frontmatter["pattern"] == "^---$"
assert message == "Detect Markdown separators."

On current main (347b38e), the first assertion fails because the parsed pattern is ^.

Additional information

I searched existing issues and PRs for this case. PR #54873 also changes the hand-written parser, but it retains split('---', 2), so this delimiter bug remains there as well.

Environment: macOS, Python 3.14.2. The Claude CLI version is not involved; this reproduces directly against the Hookify plugin source.

View original on GitHub ↗

3 Comments

zjncs · 1 month ago

I have a focused patch with four regression tests ready at zjncs/anthropics-claude-code@dba5dea:

https://github.com/zjncs/anthropics-claude-code/compare/main...fix-hookify-delimiter

The tests fail twice on current main (^---$ and foo---bar) and pass 4/4 with the fix. compileall and git diff --check also pass.

GitHub currently rejects creating the upstream PR with zjncs does not have the correct permissions to execute CreatePullRequest. If external PRs for this repository require approval, please let me know the supported path.

Kaushik2210 · 24 days ago

I have a fix for this: extract_frontmatter now treats only a line that is exactly --- as the opening/closing marker, so pattern: ^---$ parses intact. Checked with your repro, CRLF input, a body containing ---, empty/unclosed frontmatter, and all shipped example rules (fails on main, passes on the branch).

Branch: https://github.com/Kaushik2210/claude-code/tree/fix/hookify-frontmatter-triple-dash
Compare: https://github.com/anthropics/claude-code/compare/main...Kaushik2210:claude-code:fix/hookify-frontmatter-triple-dash

I tried to open a PR but GitHub rejects CreatePullRequest for non-member accounts on this repo right now, so the fix is on my fork in case a maintainer wants to cherry-pick it or open the PR.

Faizankhan17623 · 10 days ago

A fix is in https://github.com/Faizankhan17623/claude-code/commit/ed29abf432b84499e9ce830849947aabcec272e0 (the repo takes PRs from collaborators only, so I can't open one). extract_frontmatter in plugins/hookify/core/config_loader.py now ends the frontmatter at the first line that is exactly --- instead of splitting on the first --- anywhere, so a pattern such as echo --- loads whole. Tested with that rule: echo --- hi is denied, echo hello passes.