Skip to content

chore(claude): pick up the newer global hook changes - #350

Merged
m2ux merged 1 commit into
mainfrom
chore/vendored-claude-baseline-followup
Jul 29, 2026
Merged

chore(claude): pick up the newer global hook changes#350
m2ux merged 1 commit into
mainfrom
chore/vendored-claude-baseline-followup

Conversation

@m2ux

@m2ux m2ux commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Follow-up to #344. The global Claude config moved again while that PR was open — compound-bash-allow.py, redirect-inline-eval.py, a new compound-bash.json, and several more settings rules. #344 merged before these landed, so they are here.

The interesting part: compound-bash-allow.py is a merge, not a copy

The global copy is on a line of development that never received cd7bf3b, the commit that rewrote keyword handling in this tree. It has since gained subshell and brace-group unwrapping. So each side had something the other lacked:

vendored (here) global
[[ as a safe binary yes no
for headers yes no
done < input, break 2 yes no
subshell ( … ) unwrapping no yes
brace groups { …; } no yes

Copying "latest global" over this file would have regressed the first three rows. What landed instead:

  • Taken from globalstrip_group_wrapper(), _iter_unquoted(), _TRAILING_REDIR, the group branch in is_segment_allowed(), and group-unwrapped in the single-command normalization list.
  • Kept from here — the regex keyword machinery. Beyond covering more cases, it slices the original string rather than doing global's shlex.splitshlex.quote round-trip before rule matching; that requoting can quote a glob (*.txt) that a rule needs to match against.
  • Newly wired — brace groups into the existing regexes: { as a prefix keyword, } as a bare one that may carry redirections ({ …; } > log).

Other changes

scripts/claude/hooks/redirect-inline-eval.py — straight forward port. Now also denies an interpreter reading its program from stdin: python3 - <<'EOF', bare python3 <<'EOF', cat x.py | node, deno run -. Inline eval by another spelling.

scripts/claude/hooks/compound-bash.json — new file; the loader already looked for it. Vendors the generic read-only additions (strings, diff, cmp, od, comm, join, sha256sum, md5sum). Added to the README layout.

examples/cursor-workspace/.claude/settings.template.json — collapse the four git rebase --abort/--continue/--quit/--skip rules into git rebase *; add git tag reads, worktree-remove under the projects root (plain and git -C forms), and docs.rs, which pairs with the cargo block and rust-analyzer plugin the template already ships.

Skipped as personal: docs.polkadot.com, paritytech.github.io, effortLevel.

examples/cursor-workspace/.claude/rules/bash-composition.md — document the stdin-eval denial. The global CLAUDE.md predates that hook change and does not mention it, so the vendored rule would otherwise ship a hook whose behaviour its own docs contradict.

Verification

  • 15 compound-bash-allow.py cases — keyword machinery preserved (for headers incl. the arithmetic form, while, done <, break 2, [[), group unwrapping working (subshell fallback, subshell with trailing redirection, brace groups plain and redirected), deny paths still rejecting (rm -rf / under a keyword, inside a subshell, and chmod in a group body), and compound-bash.json extras taking effect.
  • 10 redirect-inline-eval.py cases — all four stdin spellings denied plus -c; --version/-v probes, file arguments, deno run <file>, and already-sbx-prefixed commands all passing through.
  • Full deploy into a throwaway dir — --dry-run skips the settings render, so it does not exercise the template. Renders valid JSON, no leftover placeholders, all hooks including the new compound-bash.json installed.

Re-ran against current main after rebasing off the merged #344.

Follow-up (not in this PR)

The global compound-bash-allow.py is missing cd7bf3b and this merge. Worth syncing that direction too, or the same divergence recurs on the next pass.

🤖 Generated with Claude Code

#347 landed the same hook merge this branch carried (compound-bash-allow.py,
redirect-inline-eval.py, compound-bash.json, the README line, and the plain
worktree-remove rule), and did the hook better: "}" handled explicitly ahead
of _KW_BARE_RE with the reasoning about why "\b" cannot fire after a non-word
character, _REDIR_TAIL_RE reused instead of a second near-identical regex,
and the config lookup order documented in the docstring. Those are dropped
here in favour of main.

What is left is the part #347 did not cover:

settings.template.json
  collapse the four "git rebase --abort/--continue/--quit/--skip" rules into
  "git rebase *"; add "git tag" reads, the "git -C" worktree-remove forms to
  match the plain one #347 added, and docs.rs, which pairs with the cargo
  block and rust-analyzer plugin the template already ships.

bash-composition.md
  document the stdin-eval denial that redirect-inline-eval.py now enforces.
  The global CLAUDE.md predates that hook change and does not mention it, so
  the vendored rule otherwise ships a hook its own docs contradict.

Skipped as personal: docs.polkadot.com, paritytech.github.io, effortLevel.

Verified: deploy renders valid JSON with every new rule expanded and no
leftover placeholders.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@m2ux
m2ux force-pushed the chore/vendored-claude-baseline-followup branch from 1e7a5df to ad7b9a1 Compare July 29, 2026 14:20
@m2ux
m2ux merged commit 14b0cc2 into main Jul 29, 2026
2 checks passed
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