Skip to content

feat: add critical-rules, PR reference expansion, and Claude Code hook recipes#23

Merged
CybotTM merged 3 commits into
mainfrom
feat/critical-rules-and-hooks
Apr 18, 2026
Merged

feat: add critical-rules, PR reference expansion, and Claude Code hook recipes#23
CybotTM merged 3 commits into
mainfrom
feat/critical-rules-and-hooks

Conversation

@CybotTM

@CybotTM CybotTM commented Apr 18, 2026

Copy link
Copy Markdown
Member

Summary

Adds non-negotiable workflow rules and operational hook recipes derived from recurring high-cost friction patterns (see also sibling PRs across the skill-repo fleet).

Changes

skills/git-workflow/SKILL.md

  • New Critical Rules (Non-Negotiable) section listing six rules: no direct push to main, no merge before threads resolved, no squash unless asked, no unverified success claims, no cache-path edits, force-push only with `--force-with-lease`.

skills/git-workflow/references/pull-request-workflow.md

  • Atomic Commits (Default — No Squash Unless Asked) — strategy order, what "atomic" means, the "if you catch yourself typing --squash" check.
  • Review Thread Resolution (SHA Citation Required) — correct reply pattern, banned lazy replies (`Addressed`, `Fixed — merged`, etc.), GitHub-side verification pattern that re-fetches thread state.

skills/git-workflow/references/claude-code-hooks.md (new)

  • Recipe 1: Block `gh pr merge` when review threads unresolved / mergeState not CLEAN
  • Recipe 2: Reject Write/Edit/MultiEdit on installed skill/plugin cache paths
  • Recipe 3: Warn (not block) on `--squash` to allow squash-policy repos
  • Recipe 4: Auto-lint Go files on PostToolUse (template adaptable to PHP/JS)
  • Recipe 5: Stop-hook sentinel for "verified/tested" claims without tool output
  • Scope/file-location table, deployment caveats, anti-patterns

Why

These rules codify the recurring process violations that have caused force-pushes, follow-up PRs, manual cache restorations, and untested-fix breakage in prior sessions. Making them explicit at the skill level — rather than re-teaching per project — closes the loop.

Test plan

  • `scripts/validate-skill.sh` passes (SKILL.md ≤ 500 words)
  • Reference cross-links resolve
  • No breaking changes to existing sections

Copilot AI review requested due to automatic review settings April 18, 2026 06:09

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces critical Git workflow rules and provides Claude Code hook recipes to enforce them. Key additions include a non-negotiable "no squash" policy to preserve atomic commits and a requirement for SHA citations when resolving review threads. Feedback focuses on improving the robustness of the provided shell-based hooks, specifically regarding PR number extraction, path matching for relative files, and ensuring MultiEdit operations are correctly handled during auto-linting.

Comment thread skills/git-workflow/references/claude-code-hooks.md Outdated
Comment thread skills/git-workflow/references/claude-code-hooks.md
Comment thread skills/git-workflow/references/claude-code-hooks.md

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR codifies stricter PR/merge workflow guidance for the git-workflow skill by adding “non-negotiable” rules, expanding PR workflow references (atomic commits + review-thread resolution discipline), and providing Claude Code settings.json hook recipes to enforce these rules at tool-invocation time.

Changes:

  • Adds a “Critical Rules (Non-Negotiable)” section to the skill and links to new/expanded reference material.
  • Expands PR workflow documentation with atomic-commit defaults and a SHA-cited review-thread resolution pattern (plus GitHub-side thread-state verification).
  • Introduces a new reference doc with Claude Code hook recipes (merge gating, cache-path write denial, squash warning, auto-lint, and a “verified claim” sentinel).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
skills/git-workflow/SKILL.md Adds critical rules and links to workflow/hook references.
skills/git-workflow/references/pull-request-workflow.md Adds atomic-commit default guidance and a SHA-cited thread-resolution workflow with GitHub verification.
skills/git-workflow/references/claude-code-hooks.md New hook recipe collection for enforcing workflow rules inside Claude Code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread skills/git-workflow/references/claude-code-hooks.md
Comment thread skills/git-workflow/SKILL.md
Comment thread skills/git-workflow/SKILL.md
Comment thread skills/git-workflow/references/pull-request-workflow.md
Comment thread skills/git-workflow/references/claude-code-hooks.md Outdated
CybotTM added 2 commits April 18, 2026 08:23
Adds a concise 'Critical Rules (Non-Negotiable)' section to SKILL.md:
- No direct push to main; no merge before threads resolved
- No squash unless asked (atomic commits default)
- No unverified success claims (paste command output)
- No edits to installed skill/plugin cache paths
- Force-push only with --force-with-lease

Adds to references/pull-request-workflow.md:
- 'Atomic Commits (Default — No Squash Unless Asked)' with strategy order
- 'Review Thread Resolution (SHA Citation Required)' with banned lazy
  replies and GitHub-side verification pattern

Codifies recurring high-cost friction patterns as non-negotiable rules.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Adds references/claude-code-hooks.md with settings.json hook recipes
that enforce the critical-rules at tool-invocation time:

- Recipe 1: Block gh pr merge when review threads are unresolved or
  mergeState is not CLEAN (denies via PreToolUse, surfaces reason in
  permission prompt)
- Recipe 2: Reject Write/Edit/MultiEdit to installed skill/plugin
  cache paths and .bare/ directories
- Recipe 3: Warn (not block) on --squash merge to allow squash-policy
  repos while prompting confirmation
- Recipe 4: Auto-lint Go files via golangci-lint on PostToolUse (and
  template for PHP/JS equivalents)
- Recipe 5: Stop-hook sentinel for 'verified/tested' claims without
  backing tool output (soft guardrail)

Also documents scope/file-location table, deployment caveats (settings
watcher only picks up .claude/ that existed at session start), and
anti-patterns for writing hooks.

Provides the hook-recipe content that a separate 'update-config' skill
would have provided — update-config is a built-in Anthropic skill with
no editable source, so operational hook recipes live here where the
merge-gate rules they enforce are already documented.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@CybotTM CybotTM force-pushed the feat/critical-rules-and-hooks branch from e9e5f8b to 8cf0c98 Compare April 18, 2026 06:24
@github-actions

github-actions Bot commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

…KILL.md

Reviewer-identified issues in Recipe 1:

- Inline awk regex '/gh pr merge[[:space:]]+([0-9]+)/' only matched
  'gh pr merge 123' — missed '--auto 123', full PR URL, and
  owner/repo#N forms (all valid for gh pr merge). Bypass = silent
  merge through the gate.
- Large inline JSON string with nested escaping was unreadable and
  hard to test or evolve.

Fix: move logic to ~/.claude/hooks/merge-gate.sh. The script parses
all three PR-reference forms gh pr merge accepts (plain number via
positional arg after optional flags, full URL, owner/repo#N),
fetches state via gh pr view, and emits a PreToolUse deny JSON via
jq -cn (safer than string concatenation). If parsing fails, the
hook allows the call rather than producing false-positive denies.

Also condenses Critical Release Rules prose to keep SKILL.md under
the 500-word validator cap after adding the script body.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@CybotTM

CybotTM commented Apr 18, 2026

Copy link
Copy Markdown
Member Author

Review response

Thanks for the review. Pushed fix commits addressing the raised issues.

Summary commit: 32b5df9

What was addressed: merge-gate regex now handles --auto/URL/owner#N; script extracted to ~/.claude/hooks/merge-gate.sh with safe JSON via jq -cn.

Please re-review. If any thread still needs work, point at the specific file/line and I'll iterate.

@CybotTM CybotTM merged commit f7bd6ca into main Apr 18, 2026
11 checks passed
@CybotTM CybotTM deleted the feat/critical-rules-and-hooks branch April 18, 2026 08:34
CybotTM added a commit that referenced this pull request Apr 18, 2026
SKILL.md Critical Rule 2 tells readers to 'run the merge gate in
references/pull-request-workflow.md' but the reference had no section
literally titled 'Merge Gate' — it was called 'Merge Requirements
Checklist'. Reviewer flagged the inconsistency on PR #23.

Renames the section to 'Merge Gate', retitles the inline check to
'Merge-Gate Command', adds reviewThreads to the gh pr view query and
the isResolved-all-true criterion (making the gate behavior match the
claude-code-hooks merge-gate.sh script), and cross-links that script
for automated enforcement.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
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.

3 participants