Repository navigation
feat: add cross-harness workflow guard hooks (#102) - #105
Merged
Merged
Conversation
Design for enforcing the skill's rules through a shared Node.js guard engine, harness hook adapters (Claude Code and Codex CLI first), git hooks as a backstop and a session-start reminder. Refs #102
Add the guard.mjs entry point with a hook dispatch table, tool-input command extraction (Bash, Codex shell, context-mode), the Claude Code and Codex adapters, and the session-start reminder. Refs #102
Only off, warn, ask and deny change a finding; "on" and unknown values keep the rule's own decision instead of silently allowing. A configured ask becomes deny where the harness or git hook cannot ask, and the raw-text fallback now honours warn and off. Refs #102
A chained pre-push.local that read stdin (git-lfs does) left the guard with no refs, so a push to a protected branch passed. The shim now captures the ref list once and feeds it to both hooks; older shims are recognised as ours and upgraded in place. Refs #102
Only an explicit "no such issue" reply marks an issue missing; a repository or auth error is unknown. Refs or repos that start with a dash never reach gh. The fetch timeout drops to 5 s so a slow network stays inside the hook budget. Adds memoised branchExists and defaultBranch queries. Refs #102
git branch -f, checkout -B and switch -C on a protected or existing local branch reset it, so branch-name, branch-issue and fresh-base no longer deny them. pr-base without --base now checks the repository's default branch instead of assuming develop. Refs #102
timeout DURATION, xargs (including -I templates and value flags) and eval hid gh pr merge --squash and git push --force from the parsed rules. eval arguments are re-parsed like bash -c, under the same depth cap. Refs #102
gh -R o/r pr merge and gh pr -R o/r merge were not recognised, so the merge rules never ran. -R now folds into repo for every gh sub, the merge rules drop their R fallback, and pr edit passes the repo to its pr view lookup. Refs #102
--trailer values now reach the attribution scan. -uno and -S<keyid> take an attached value, so -uno is no longer read as --no-verify. -F and --body-file read only regular files up to 1 MiB, so a FIFO or device cannot hang the hook. Refs #102
- add Bash to the Codex PreToolUse matcher; Codex reports shell calls under that tool name - refuse a non-array hooks.<Event> instead of replacing it - raise the registered hook timeout to 30 s - write configs through symlinks and keep the file mode - install with scope opt-in prints how to enable a repository - repair backs up an invalid user config to <file>.bak first - doctor repo checks in tests use the exec stub Refs #102
A stale registration made guard.mjs hook exit 2, which Claude Code treats as a block for every Bash call. It now exits 0 with one warning line and no output. Refs #102
Resolved cwd expectations use path.resolve, so they hold on Windows where the parser yields drive-letter paths. Refs #102
Run the guard install after the skill symlink when node is available, and the guard uninstall on --uninstall. Add --no-hooks and --scope. Refs #102
Without --scope, install keeps a valid scope from the user config and merges harnesses with earlier runs. An explicit --scope still wins. Refs #102
The repository bootstrap in SKILL.md runs `git checkout -b develop`; branch-name denied it as an invalid name. Refs #102
A string such as "codex" in the user config was spread into single characters. Refs #102
Without .git-workflow.json, disable reported the guard as inactive even when the user scope is all. Refs #102
…ands Add the issue-title rule the conventional-title check already enforces, resolve the guard path from the skill directory, describe what disable really does, and note how a human allows recovery force-pushes on shared branches. Refs #102
Run enable inside the target repository, say what uninstall leaves behind, explain the on level, and state the force-push rule as the skill does. Refs #102
State which platform, harness and install-script combinations were exercised before release (Linux Claude Code and Codex, Windows Claude Code) and mark the untested ones (macOS, Windows Codex and PowerShell, install_windows.ps1, Copilot/Gemini/Cursor, GUI git clients) so that "supported" is not read as "verified". Refs #102
fs.realpathSync does not expand Windows 8.3 short names, so a skill dir under C:\Users\RUNNER~1\... never matched the long path git reports and update treated the clone as "not a git clone". Use realpathSync.native, which resolves short names on Windows and is a no-op change elsewhere. Refs #102
10 tasks done
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.
What does this PR do?
Adds an optional enforcement guard for the skill's rules:
hooks/guard.mjs(Node ≥ 20, no dependencies) hooks into AI coding harnesses before they rungit/ghcommands, plus optionalcommit-msg/pre-pushgit-hook shims. The skill itself stays self-contained; the guard is opt-in tooling.conventional-commit,protected-commit,branch-name,branch-issue,fresh-base,pr-base,force-push,no-verify,no-ai-attribution,merge-method,merge-gate,test-plan-ticked): deny > ask > warn > allow, one-line messages with what to do instead, fail-open on parse/state errorsmerge-gateasks where the harness can ask, otherwise needsWORKFLOW_GUARD_APPROVE=<PR>install | update | doctor | repair | uninstall | enable | disable; scopeopt-in(per-repo.git-workflow.json) orall--scope,--no-hooks); CIguard-testsmatrix on Ubuntu/macOS/Windows with Node 20; issue templates usefix:/feat:prefixeschore(release): prepare X.Y.Z; README guard section incl. a tested / not tested table; CLAUDE.md; CHANGELOG[Unreleased]force-pushrule matches the Rebase RulesCloses #102
Test plan
Automated:
./scripts/lint.sh— All checks passednode --test hooks/test/on Linux (Node 26) — 211/211guard-testson ubuntu/macos/windows with Node 20 — all green (first run caught a Windows 8.3 short-path bug inupdate, fixed in a696936)Manual (throwaway repos, deleted afterwards):
bash -c,timeout,+refspec), protected-delete, merge-method deny; plainechono false positiveautomode, user No → not merged;dontAsk→ deny with approval hint, wrong number rejected, agent did not self-approve,WORKFLOW_GUARD_APPROVEafter user yes mergedexec_command); merge-gate deny with approval hint, wrong number rejected, approval path merged; epic/* merge allowedcd /c/...drive paths work; merge-gate ask shown; git-hook shims (commit-msg, pre-push) checked over SSH--no-hooks,--uninstallNot tested (also listed in the README):
install_macos.sh(only the automated suite runs, in CI)install_windows.ps1(not executed)Checklist