feat(just-recipes): enforce recipes via PreToolUse hook - #58
Draft
drewdrewthis wants to merge 1 commit into
Draft
Conversation
- hooks/enforce-just.sh denies raw Bash where a justfile resolves; allows just commands, read-only allowlist, kill switch (JUST_RECIPES_ENFORCE=off), missing just/justfile; any internal error fails open (exit 0) - hooks/hooks.json wires it on PreToolUse matcher Bash - SKILL.md: enforcement model, escape hatch, habit loop, flat-recipe convention - version 0.2.0; register in release-please config + manifest seeded at 0.2.0 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Reviewer cockpit
set -e,bash -nverified, garbage/empty-stdin tested, and a kill switch (JUST_RECIPES_ENFORCE=off|0) that short-circuits before any parsing.plugins/just-recipes/hooks/enforce-just.sh(55 lines), thenhooks/hooks.json.Why
v0.1 of just-recipes only advises preferring recipes; nothing enforces it. This PR closes the loop: where a justfile resolves, raw bash is denied with a pointer to
just --list, thejust wrap "<cmd>"escape hatch, and the recipe-authoring habit loop.What changed
just --summaryin$CLAUDE_PROJECT_DIR→ alternative: walk parents looking for a justfile filename → consequence: honors just's own resolution (fallback, modules) with zero path logic.cd pwd echo ls cat command -v which) → alternative: none → consequence: avoids nuisance denials on trivial inspection.plugins/just-recipeswithbump-minor-pre-major+bump-patch-for-minor-pre-major, manifest seeded at 0.2.0 → consequence: first release PR does not jump to 1.0.0. (marketplace.json carries no per-plugin version field — nothing to bump there.)$CODEX_ROOT/state/wrap.log, habit loop /just wrap-report, flat-recipe convention, kill switch; v0.1 discovery/safety content retained.Human verification
touch xBash call is denied with the recipe-pointer message.just <recipe>and repos without a justfile pass through untouched.JUST_RECIPES_ENFORCE=off claude ...disables enforcement.How I can prove I was successful
bash -npassed. Standalone matrix (sample hook JSON piped to stdin; scratch dir contains a justfile):just --listnpm testnpm test(CLAUDE_PROJECT_DIR=/tmp)npm test+JUST_RECIPES_ENFORCE=offnot jsonls -lajustify thingsjust wrap "touch x"Deny output (verbatim):
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Raw bash is funneled through just here. Run 'just --list' to find a recipe, or use the escape hatch: just wrap \"<your command>\". To add a recipe: see the just-recipes skill."}}Load test:
claude --plugin-dir .../plugins/just-recipes -p "Reply with exactly: LOADED"→LOADED.claude plugin validate plugins/just-recipes→✔ Validation passed. Declared hook path diffed against the file on disk → match.Live end-to-end (
claude -pin a scratch dir with a justfile, plugin loaded via--plugin-dir), model transcript excerpts — green CI is not this proof:Raw command denied, file NOT created:
Recipe allowed:
🤖 Generated with Claude Code