Files
homelab-infrastructure-as-code/.claude/skills/merge/SKILL.md
T

5.9 KiB

name, description, argument-hint, disable-model-invocation
name description argument-hint disable-model-invocation
merge Commit the staged and unstaged changes that fit the branch with meaningful messages, push a branch, open a Gitea PR, wait for CI, and merge it, without stopping for confirmation.
optional note on intent
or paths to limit the merge to
true

Take the working tree changes through commit, push, PR 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 "ask before opening or merging" 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.md for branch names, commit messages and PR titles.
  • Add no AI attribution to commits or PRs.
  • Never use --no-verify, force push, or commit directly to main.
  • Use .claude/scripts/gitea.sh for PR calls, because gh does not work here. $REPO below means /repos/kasun/homelab-infrastructure-as-code, and must be written out in full in each command.
  • Never stage Pulumi.dev.yaml, .env files, keys, credentials, .claude/settings.local.json, or anything in sdks/. Leave them out, carry on, and mention them in the report.
  • Write commit messages and JSON bodies 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. cd prefixes, 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.
  • Typecheck or pulumi preview fails.
  • The preview shows a replace or delete of a VM, a PVC, or an imported resource.
  • 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.

Leave the branch and PR in place when stopping after they exist, and say what is needed to continue.

1. Inspect

  1. Run git status, git diff --staged, git diff, and git log --oneline -5. Read any untracked files that would be included.
  2. Run git fetch origin main.
  3. On a non-main branch, 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 and 7 first, which returns you to main, 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, such as an unrelated .claude/settings.json edit. 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 7, so each is merged and you are back on main before the next starts. If $ARGUMENTS names 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 is the stack (01-proxmox-infra/ is proxmox-infra), or ci for .gitea/workflows/. Omit the scope for repo-wide or .claude/ changes.
  • Add a body only when the diff shows a reason that is not obvious. Never invent a reason.

3. Verify

For each stack with changed code, run:

  • npm run typecheck --prefix <stack-dir>
  • pulumi preview --cwd <stack-dir> --stack dev

4. Commit and push

  1. If on main, run git switch -c <type>/<short-kebab-description>. This carries the changes across.
  2. For each commit, run git add -- <paths>, then git commit -F <message file> -- <paths>. Naming the paths commits only those files, whatever else is staged.
  3. Run git status to confirm only intentionally excluded files remain.
  4. 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, why, and the preview result for each stack.

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 ran because 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.

7. Merge

  1. Run .claude/scripts/gitea.sh POST $REPO/pulls/<number>/merge @<json file> with {"Do":"merge","head_commit_id":"<sha>"}, so only the commit CI checked can merge.
  2. Run git fetch origin main:main, then git switch main.

8. Report

Keep it short:

  • PR link and commits.
  • What the merge deploys, from the on.push.paths in .gitea/workflows/. 01, 03, 04 and 05 deploy on merge. A change under .gitea/workflows/ can deploy 03, 04 and 05, and a change to 01's own workflow deploys 01.
  • For 02 changes, say that they are not live until someone runs the manual workflow.
  • Anything left uncommitted, and a reminder to update <STACK>_PULUMI_DEV_YAML if local Pulumi config changed.

Do not delete the branch, dispatch a workflow, or change a live system.