Adds a /merge skill that takes working tree changes through commit, push, PR, CI, review and merge in one run, and a hook that enforces the review.
.claude/skills/merge/SKILL.md: the workflow. Only the user can start it (disable-model-invocation). It lints, waits for CI, runs /code-review medium on the PR diff, posts the result as a PR comment and stops on important findings.
.claude/hooks/guard-merge.sh: refuses a merge unless it is the single strict gitea.sh POST .../pulls/N/merge @FILE command, head_commit_id matches the PR's head commit, and the PR's newest review comment is a pass for that commit. It fails closed (exit 2) on any error, and refuses gitea.sh write calls with non-plain paths and curl/wget merges.
.claude/settings.json: registers the hook. The ask rule for merges stays, so every merge prompts once, also inside /merge.
CLAUDE.md: /merge replaces "ask before opening or merging"; deploy PRs will need approval once deploy-on-merge exists.
.claude/scripts/gitea.sh: header updated to the new scope.
Why: the user reviews changes in the IDE as they are made, so approval clicks in Gitea would repeat that review. The gate is the user typing /merge and confirming the merge prompt, plus required CI checks and an agent review bound to the exact commit that merges.
The first review of this PR (comment above) failed on five ways around the hook; the second commit fixes them.
Adds a `/merge` skill that takes working tree changes through commit, push, PR, CI, review and merge in one run, and a hook that enforces the review.
- `.claude/skills/merge/SKILL.md`: the workflow. Only the user can start it (`disable-model-invocation`). It lints, waits for CI, runs `/code-review medium` on the PR diff, posts the result as a PR comment and stops on important findings.
- `.claude/hooks/guard-merge.sh`: refuses a merge unless it is the single strict `gitea.sh POST .../pulls/N/merge @FILE` command, `head_commit_id` matches the PR's head commit, and the PR's newest review comment is a pass for that commit. It fails closed (exit 2) on any error, and refuses `gitea.sh` write calls with non-plain paths and `curl`/`wget` merges.
- `.claude/settings.json`: registers the hook. The ask rule for merges stays, so every merge prompts once, also inside `/merge`.
- `CLAUDE.md`: `/merge` replaces "ask before opening or merging"; deploy PRs will need approval once deploy-on-merge exists.
- `.claude/scripts/gitea.sh`: header updated to the new scope.
Why: the user reviews changes in the IDE as they are made, so approval clicks in Gitea would repeat that review. The gate is the user typing `/merge` and confirming the merge prompt, plus required CI checks and an agent review bound to the exact commit that merges.
The first review of this PR (comment above) failed on five ways around the hook; the second commit fixes them.
/merge takes changes from commit to merged PR in one run. A PreToolUse hook
refuses any merge without a passing review comment for the PR's current head
commit, so the review can't be skipped or go stale after new commits.
Effort: medium (/code-review on origin/main...HEAD)
.claude/hooks/guard-merge.sh:16: unexpected errors (non-JSON response, unset variable) exit with 1 or 5; Claude Code only blocks on exit 2, so the merge runs. Needs an ERR trap that denies. important
.claude/hooks/guard-merge.sh:18: only one spelling of the merge path is recognised; /pulls/N/./merge and similar variants skip the hook and, without the ask rule, merge with no prompt. important
.claude/settings.json:63: removing the merge ask rule leaves "outside /merge, ask first" enforced by instruction only. important
.claude/hooks/guard-merge.sh:48: an older pass marker still counts after a later fail for the same commit; only the newest marker should count. important
.claude/hooks/guard-merge.sh:40: head_commit_id is read from the first @word anywhere in the command, not from the body argument actually sent. important
.claude/skills/merge/SKILL.md:75: no CI ran counts as a pass even when the runner is merely slow or offline; branch protection's required checks catch this on the server. pre-existing
.claude/scripts/gitea.sh:10: header still says PRs only and that merges always ask. nit
<!-- claude-review: fail 737a3a29ecf449b05b001a04602b7908fdbbf4a1 -->
## Review
Effort: medium (`/code-review` on `origin/main...HEAD`)
- `.claude/hooks/guard-merge.sh:16`: unexpected errors (non-JSON response, unset variable) exit with 1 or 5; Claude Code only blocks on exit 2, so the merge runs. Needs an ERR trap that denies. **important**
- `.claude/hooks/guard-merge.sh:18`: only one spelling of the merge path is recognised; `/pulls/N/./merge` and similar variants skip the hook and, without the ask rule, merge with no prompt. **important**
- `.claude/settings.json:63`: removing the merge ask rule leaves "outside /merge, ask first" enforced by instruction only. **important**
- `.claude/hooks/guard-merge.sh:48`: an older `pass` marker still counts after a later `fail` for the same commit; only the newest marker should count. **important**
- `.claude/hooks/guard-merge.sh:40`: `head_commit_id` is read from the first `@word` anywhere in the command, not from the body argument actually sent. **important**
- `.claude/skills/merge/SKILL.md:75`: `no CI ran` counts as a pass even when the runner is merely slow or offline; branch protection's required checks catch this on the server. **pre-existing**
- `.claude/scripts/gitea.sh:10`: header still says PRs only and that merges always ask. **nit**
The first review found ways around the hook: unexpected errors exited with
non-blocking codes, unusual spellings of the merge path skipped it, and an
older pass outlived a newer fail. The ask rule for merges is back as a second
layer, so merging outside /merge is enforced, not just instructed.
Effort: medium (/code-review on origin/main...HEAD)
.claude/hooks/guard-merge.sh:72: the issue comments endpoint ignores page/limit (verified: page 5 returns the same comment), so the loop never sees an empty page and refuses every merge with "too many comments". important
.claude/hooks/guard-merge.sh:43: only the first gitea.sh call in a command is inspected; gitea.sh POST .../comments @a && gitea.sh POST .../pulls/N/merge @b passes unchecked. important
.claude/settings.json:101: no hook timeout and no curl --max-time; a slow Gitea makes the hook time out, which Claude Code treats as non-blocking. important
.claude/hooks/guard-merge.sh:67: the merge body may carry extra fields such as delete_branch_after_merge, which the skill forbids; only Do and head_commit_id should be allowed. important
.claude/hooks/guard-merge.sh:66: a relative @FILE is resolved against the hook's cwd, which may differ from the shell's; require an absolute path. nit
.claude/hooks/guard-merge.sh:80: a CR at the end of the marker line makes a valid pass fail; edited comments keep their original position. nit
<!-- claude-review: fail f45fb7421aab06e8ae6efd7bd9f51644fbaad7aa -->
## Review
Effort: medium (`/code-review` on `origin/main...HEAD`)
- `.claude/hooks/guard-merge.sh:72`: the issue comments endpoint ignores `page`/`limit` (verified: page 5 returns the same comment), so the loop never sees an empty page and refuses every merge with "too many comments". **important**
- `.claude/hooks/guard-merge.sh:43`: only the first `gitea.sh` call in a command is inspected; `gitea.sh POST .../comments @a && gitea.sh POST .../pulls/N/merge @b` passes unchecked. **important**
- `.claude/settings.json:101`: no hook `timeout` and no curl `--max-time`; a slow Gitea makes the hook time out, which Claude Code treats as non-blocking. **important**
- `.claude/hooks/guard-merge.sh:67`: the merge body may carry extra fields such as `delete_branch_after_merge`, which the skill forbids; only `Do` and `head_commit_id` should be allowed. **important**
- `.claude/hooks/guard-merge.sh:66`: a relative `@FILE` is resolved against the hook's cwd, which may differ from the shell's; require an absolute path. **nit**
- `.claude/hooks/guard-merge.sh:80`: a CR at the end of the marker line makes a valid pass fail; edited comments keep their original position. **nit**
Gitea's issue comments endpoint ignores paging, so the hook now reads all
comments in one call; the paged loop refused every merge. Any command that
calls gitea.sh and mentions a merge must now be the strict form as a whole,
while commands that only name gitea.sh as a file (git add, git diff) pass.
The body may only pin the head commit, and curl calls have time limits so
the hook can't time out into a non-blocking error.
Effort: medium (/code-review on origin/main...HEAD)
Out of scope (deliberate workarounds, which the hook header excludes; the merge prompt and required server checks cover them):
.claude/hooks/guard-merge.sh:59: empty quotes inside the word (me""rge) hide a merge from the "merg" check. out of scope
.claude/hooks/guard-merge.sh:54: a chained call written with ${IFS} instead of spaces is swallowed by the @file strip. out of scope
.claude/hooks/guard-merge.sh:71: quotes or globs in the body path make the hook read a different file than curl sends. out of scope
Nits:
.claude/hooks/guard-merge.sh:70: harmless calls that mention "merge" (GET /pulls/N/merge, inline bodies) are refused. nit
.claude/hooks/guard-merge.sh:69: any absolute path ending in .claude/scripts/gitea.sh is accepted as the merge script. nit
.claude/hooks/guard-merge.sh:94: a null comment body gives the misleading reason "was edited". nit
<!-- claude-review: pass 1e02dd593042f7607690168331039fbda239c1d3 -->
## Review
Effort: medium (`/code-review` on `origin/main...HEAD`)
Out of scope (deliberate workarounds, which the hook header excludes; the merge prompt and required server checks cover them):
- `.claude/hooks/guard-merge.sh:59`: empty quotes inside the word (`me""rge`) hide a merge from the "merg" check. **out of scope**
- `.claude/hooks/guard-merge.sh:54`: a chained call written with `${IFS}` instead of spaces is swallowed by the @file strip. **out of scope**
- `.claude/hooks/guard-merge.sh:71`: quotes or globs in the body path make the hook read a different file than curl sends. **out of scope**
Nits:
- `.claude/hooks/guard-merge.sh:70`: harmless calls that mention "merge" (GET `/pulls/N/merge`, inline bodies) are refused. **nit**
- `.claude/hooks/guard-merge.sh:69`: any absolute path ending in `.claude/scripts/gitea.sh` is accepted as the merge script. **nit**
- `.claude/hooks/guard-merge.sh:94`: a null comment body gives the misleading reason "was edited". **nit**
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Adds a
/mergeskill that takes working tree changes through commit, push, PR, CI, review and merge in one run, and a hook that enforces the review..claude/skills/merge/SKILL.md: the workflow. Only the user can start it (disable-model-invocation). It lints, waits for CI, runs/code-review mediumon the PR diff, posts the result as a PR comment and stops on important findings..claude/hooks/guard-merge.sh: refuses a merge unless it is the single strictgitea.sh POST .../pulls/N/merge @FILEcommand,head_commit_idmatches the PR's head commit, and the PR's newest review comment is a pass for that commit. It fails closed (exit 2) on any error, and refusesgitea.shwrite calls with non-plain paths andcurl/wgetmerges..claude/settings.json: registers the hook. The ask rule for merges stays, so every merge prompts once, also inside/merge.CLAUDE.md:/mergereplaces "ask before opening or merging"; deploy PRs will need approval once deploy-on-merge exists..claude/scripts/gitea.sh: header updated to the new scope.Why: the user reviews changes in the IDE as they are made, so approval clicks in Gitea would repeat that review. The gate is the user typing
/mergeand confirming the merge prompt, plus required CI checks and an agent review bound to the exact commit that merges.The first review of this PR (comment above) failed on five ways around the hook; the second commit fixes them.
Review
Effort: medium (
/code-reviewonorigin/main...HEAD).claude/hooks/guard-merge.sh:16: unexpected errors (non-JSON response, unset variable) exit with 1 or 5; Claude Code only blocks on exit 2, so the merge runs. Needs an ERR trap that denies. important.claude/hooks/guard-merge.sh:18: only one spelling of the merge path is recognised;/pulls/N/./mergeand similar variants skip the hook and, without the ask rule, merge with no prompt. important.claude/settings.json:63: removing the merge ask rule leaves "outside /merge, ask first" enforced by instruction only. important.claude/hooks/guard-merge.sh:48: an olderpassmarker still counts after a laterfailfor the same commit; only the newest marker should count. important.claude/hooks/guard-merge.sh:40:head_commit_idis read from the first@wordanywhere in the command, not from the body argument actually sent. important.claude/skills/merge/SKILL.md:75:no CI rancounts as a pass even when the runner is merely slow or offline; branch protection's required checks catch this on the server. pre-existing.claude/scripts/gitea.sh:10: header still says PRs only and that merges always ask. nitReview
Effort: medium (
/code-reviewonorigin/main...HEAD).claude/hooks/guard-merge.sh:72: the issue comments endpoint ignorespage/limit(verified: page 5 returns the same comment), so the loop never sees an empty page and refuses every merge with "too many comments". important.claude/hooks/guard-merge.sh:43: only the firstgitea.shcall in a command is inspected;gitea.sh POST .../comments @a && gitea.sh POST .../pulls/N/merge @bpasses unchecked. important.claude/settings.json:101: no hooktimeoutand no curl--max-time; a slow Gitea makes the hook time out, which Claude Code treats as non-blocking. important.claude/hooks/guard-merge.sh:67: the merge body may carry extra fields such asdelete_branch_after_merge, which the skill forbids; onlyDoandhead_commit_idshould be allowed. important.claude/hooks/guard-merge.sh:66: a relative@FILEis resolved against the hook's cwd, which may differ from the shell's; require an absolute path. nit.claude/hooks/guard-merge.sh:80: a CR at the end of the marker line makes a valid pass fail; edited comments keep their original position. nitReview
Effort: medium (
/code-reviewonorigin/main...HEAD)Out of scope (deliberate workarounds, which the hook header excludes; the merge prompt and required server checks cover them):
.claude/hooks/guard-merge.sh:59: empty quotes inside the word (me""rge) hide a merge from the "merg" check. out of scope.claude/hooks/guard-merge.sh:54: a chained call written with${IFS}instead of spaces is swallowed by the @file strip. out of scope.claude/hooks/guard-merge.sh:71: quotes or globs in the body path make the hook read a different file than curl sends. out of scopeNits:
.claude/hooks/guard-merge.sh:70: harmless calls that mention "merge" (GET/pulls/N/merge, inline bodies) are refused. nit.claude/hooks/guard-merge.sh:69: any absolute path ending in.claude/scripts/gitea.shis accepted as the merge script. nit.claude/hooks/guard-merge.sh:94: a null comment body gives the misleading reason "was edited". nit