Skip to content

Harden hooks, add tests, and tighten agents#2

Merged
poshan0126 merged 1 commit into
mainfrom
feat/hook-tests-agent-confidence
Apr 16, 2026
Merged

Harden hooks, add tests, and tighten agents#2
poshan0126 merged 1 commit into
mainfrom
feat/hook-tests-agent-confidence

Conversation

@poshan0126

Copy link
Copy Markdown
Owner

Summary

  • Hook fixes + regression tests: 11 bugs in block-dangerous-commands.sh and protect-files.sh fixed; 36 fixtures under hooks/tests/ with a plain-bash runner; CI on Linux + macOS (.github/workflows/hook-tests.yml).
  • Agents: all 5 reviewers now use confidence gating (Conf ≥ 8 with a concrete failure scenario + fix), calibrated exclusion lists, and stack-aware conditional checks (auto-detect Supabase, Stripe, JWT, RSC, Prisma, etc.).
  • Docs aligned: root README tree lists all 9 hooks + hooks/tests/; hooks/agents/rules READMEs rewritten to match what's actually on disk; CONTRIBUTING requires fixtures for any hook change.
  • setupdotclaude hardened: stops editing the old main|master regex (no longer exists — hook reads git config init.defaultBranch and honors CLAUDE_PROTECTED_BRANCHES); new phases adapt auto-test.sh runner and customize context-recovery.sh RULES per project; Phase 0 strips hooks/tests/ and stray CI file from user installs.

Notable hook bug fixes

  • 2>/dev/null no longer triggers the /dev/ destructive-write rule (was blocking every stderr redirect).
  • DELETE FROM a; SELECT ... WHERE x no longer bypasses the DELETE block via an unrelated later WHERE — SQL is parsed per-statement.
  • rm -rf "\$HOME/x" and rm -rf \$VAR now caught (quoted paths + unresolved expansions).
  • chmod 0777, chmod -R 777, chmod a+rwx all blocked.
  • git push upstream main (and any remote, not just origin) now blocked.
  • Protected branch list configurable via CLAUDE_PROTECTED_BRANCHES env; develop/release can be added without editing the hook.
  • npm publish --dry-run allowed.

Test plan

  • bash hooks/tests/run-all.sh → 36 passed, 0 failed
  • hook-tests.yml workflow runs on push (Linux + macOS matrix)
  • Manual: git push origin main from a feature branch still blocked
  • Manual: CLAUDE_PROTECTED_BRANCHES=main,develop blocks push to develop
  • Manual: /setupdotclaude on a Next.js/Supabase project — verify Phase 3.8 / 3.8b / 3.8c behave as described
  • Manual: agents produce short reports (confidence ≥ 8 default) on a clean diff

Hook fixes (11 bugs, 36 regression fixtures, CI on Linux+macOS):
- block-dangerous-commands: configurable protected branches via
  CLAUDE_PROTECTED_BRANCHES + init.defaultBranch; multi-statement SQL
  parsed per-statement; quoted rm -rf paths handled; chmod 0777/-R
  777/a+rwx caught; /dev/null false-positive fixed; npm publish
  --dry-run allowed
- protect-files: case-insensitive dotfile matching
- New hooks/tests/ with run-all.sh runner honoring fixture env
- New .github/workflows/hook-tests.yml

Agents: confidence-gated reviews (>=8) with concrete failure
scenarios, calibrated exclusion lists, and stack-aware conditional
checks (Supabase/Stripe/JWT/RSC/etc). New "When to Invoke" matrix.

Docs: README structure tree now lists all 9 hooks + tests/; hooks and
agents READMEs rewritten; rules README adds database + error-handling
sections; CONTRIBUTING requires fixtures for hook changes.

setupdotclaude: stop editing the block-dangerous regex (now runtime-
configurable); new Phase 3.8b adapts auto-test.sh; new Phase 3.8c
customizes context-recovery.sh RULES per project; Phase 0 removes
hooks/tests/ and stray CI file from user installs.
@poshan0126
poshan0126 merged commit 505e4ed into main Apr 16, 2026
3 checks passed
PoshanP added a commit that referenced this pull request May 5, 2026
Resolves 12 conflicts from main's PR #2 (hook hardening + tests +
agent tightening) against this branch's marketplace + token-discipline
work.

Resolution rules:
- agents/ (5 files), skills/setupdotclaude/SKILL.md, README.md,
  agents/README.md, hooks/README.md: kept ours. This branch's rewrites
  (operating principles, terse-by-default with verbose mode, Phase Init
  bootstrap, Phase 4 budget enforcement, marketplace-first README) are
  supersets of main's wording polishes.
- hooks/protect-files.sh, hooks/block-dangerous-commands.sh: kept theirs
  (main's hardened logic) and re-applied em-dash strip to comments.
- .gitignore: merged both additions (.devswarm-temp/ + the new
  hooks/*.html web-page-save patterns).
- Auto-merged files (CONTRIBUTING.md, rules/README.md) had em-dashes
  reintroduced from main; re-stripped.

New from main, untouched:
- .github/workflows/hook-tests.yml (CI for hook tests)
- hooks/tests/ (test fixtures + run-all.sh runner)

Bundled template (plugins/setupdotclaude/template/) re-synced so the
plugin install path picks up main's hardened hooks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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