7.4 KiB
name, description, argument-hint, disable-model-invocation
| name | description | argument-hint | disable-model-invocation | ||
|---|---|---|---|---|---|
| merge | Commit the working tree changes that fit the branch, push, open a Gitea PR, wait for CI, review the PR with /code-review, and merge it, without stopping for confirmation. |
|
true |
Take the working tree changes through commit, push, PR, review and merge in one run. If $ARGUMENTS names paths, include only those. If it describes intent, use it for the commit messages and PR.
Typing /merge is the user's explicit instruction to commit, push, open a PR and merge these changes. It satisfies the "commit" and PR rules in CLAUDE.md for this run. Do not ask for confirmation, and do not pause to show drafts. Stop only for a condition under "Stop conditions".
Rules
- Follow
CONVENTIONS.mdfor branch names, commit messages and PR titles. The allowed commit scopes are in.githooks/commit-msg. - Add no AI attribution to commits, PRs or comments.
- Never use
--no-verify, force push, or commit directly tomain. - Never run
ansible,ansible-playbook(not even--check), SSH or Docker commands. This skill changes git and Gitea only. - Use
.claude/scripts/gitea.shfor Gitea calls, becauseghdoes not work here.$REPObelow means/repos/kasun/homelab-ansible, and must be written out in full in each command. - Never stage
vault.yml,.vault_pass*,.envfiles, private keys, credentials,.claude/settings.local.jsonor.venv/. Leave them out, carry on, and mention them in the report. - Write commit messages, JSON bodies and the review comment to files in the scratchpad directory with the Write tool.
- Run each command on its own, in the exact forms below, from the repo root.
cdprefixes, pipes, loops and redirects cause permission prompts.
Stop conditions
Stop and report only if:
- HEAD is detached, or a merge or rebase is in progress.
- There are no changes and no unpushed commits.
- yamllint or ansible-lint fails.
- A file that looks like a secret is the only change.
- A commit hook, push or API call fails after one corrected retry of a message-format error.
- CI fails, or the PR is not mergeable.
- The review leaves an important finding open (step 7).
- The merge hook denies the merge.
Leave the branch and PR in place when stopping after they exist, and say what is needed to continue.
1. Inspect
- Run
git status,git diff --staged,git diff, andgit log --oneline -5. Read any untracked files that would be included. - Run
git fetch origin main. - On a non-
mainbranch, run.claude/scripts/gitea.sh GET $REPO/pulls?state=open. If this branch has an open PR, reuse it only for changes that serve its purpose. If all remaining changes are unrelated to it, take that PR through steps 6 to 8 first, which returns you tomain, then continue with the remaining changes as new work.
2. Group into commits
Split by reason for the change, and decide without asking. Each commit should make sense and be revertable alone.
- First decide the PR's purpose from
$ARGUMENTS, the conversation, the branch name, or else the largest change. - On the first
/merge, leave out any change that does not serve that purpose. Keep it uncommitted and untouched, do not ask, and list it in the report. - On a repeat
/merge, meaning an earlier run this session left changes out or its PR is still open, handle all remaining changes in this run. Give each separate purpose its own branch and PR, and take them one at a time through steps 3 to 8, so each is merged and you are back onmainbefore the next starts. If$ARGUMENTSnames paths, handle only those. - Use one commit when the remaining changes serve one purpose, and several when they are distinct steps toward it.
- Group whole files. If one file mixes purposes, put it in the commit for its main change.
- Scope:
cifor.gitea/workflows/,claudefor.claude/, otherwise the top-level folder if it is an allowed scope. Omit the scope for repo-wide changes. - Add a body only when the diff shows a reason that is not obvious. Never invent a reason.
3. Verify
Run .venv/bin/yamllint --strict . and .venv/bin/ansible-lint. Both must pass. Dry runs against hosts belong in CI, not here.
4. Commit and push
- If on
main, rungit switch -c <type>/<short-kebab-description>. This carries the changes across. - For each commit, run
git add -- <paths>, thengit commit -F <message file> -- <paths>. Naming the paths commits only those files, whatever else is staged. - Run
git statusto confirm only intentionally excluded files remain. - Run
git push -u origin <branch>.
5. Open the PR
Unless one exists, run .claude/scripts/gitea.sh POST $REPO/pulls @<json file> with title, body, head and base: "main". The body says what changed and why.
6. Wait for CI
Get the SHA with git rev-parse HEAD, then run .claude/scripts/gitea.sh WAIT $REPO/commits/<sha>/status as a background command. Do not write a polling loop, because that causes a permission prompt.
- Exit 0: checks passed, or it printed
no CI ranbecause workflows are path-filtered. Continue. - Exit 1: stop, and report the failing check and its
target_url. - Exit 3: CI timed out. Stop and report it.
Then run .claude/scripts/gitea.sh GET $REPO/pulls/<number> and confirm mergeable is true and head.sha equals the SHA from git rev-parse HEAD.
7. Review
-
Invoke the
code-reviewskill withmedium origin/main...HEAD. Wait for its findings, also if it runs in the background. -
Check each finding against the code and the PR's purpose. Classify it as important (a real bug or broken
CLAUDE.mdrule this PR adds), pre-existing, or nit, and drop findings that don't hold up. -
Write the review comment to a file. First line, exactly one of:
<!-- claude-review: pass <sha> -->when no important finding is left<!-- claude-review: fail <sha> -->otherwise
Then a
## Reviewheading, the effort level, and one line per finding:path:line, what is wrong, its class. WriteNo findings.if there are none. -
Run
.claude/scripts/gitea.sh POST $REPO/issues/<number>/comments @<json file>with{"body": "<comment>"}. -
On
fail, stop and report the important findings. Do not fix them in this run; the user decides.
Never edit a review comment; post a new one. The merge hook refuses PRs with edited review comments.
Never write a pass marker for a SHA you did not review, or when an important finding is open. The merge hook only checks that the marker exists, so the honesty of the marker is on you.
8. Merge
- Run
.claude/scripts/gitea.sh POST $REPO/pulls/<number>/merge @<absolute path of json file>with exactly{"Do":"merge","head_commit_id":"<sha>"}and no other fields, so only the commit CI and the review checked can merge. Run it exactly in this form, alone. Theguard-merge.shhook refuses any other form, and refuses the call unless the newest review comment is apassfor this SHA. This call asks the user for permission: that prompt is the one intended pause of the run. If the user declines, stop. - Run
git fetch origin main:main, thengit switch main.
9. Report
Keep it short:
- PR link and commits.
- The review result, with any pre-existing findings or nits worth a follow-up.
- What the merge triggers, from
on.pushin.gitea/workflows/. Say whether the PR touched adeploy-stacks.yamlpath, and so deployed. - Anything left uncommitted.
Do not delete the branch, dispatch a workflow, or change a live system.