.agents/skills/worktree-rebase-merge/SKILL.md
Use this skill to finish a worktree branch by committing the source branch,
rebasing it onto a target branch, then merging it from a worktree checked out to
that target branch. When the current branch is already the resolved target
branch, skip the rebase/merge path and commit directly via the git-commit
skill. Delegate all source-branch and direct-commit mechanics to git-commit.
origin; if no origin exists and
exactly one remote exists, use that remote. Query the live remote HEAD with
git ls-remote --symref <remote> HEAD, read the
ref: refs/heads/<branch> HEAD line, then strip the refs/heads/ prefix.
This read-only query is not a fetch or pull.refs/remotes/<remote>/HEAD. You may read that symbolic ref
only to report a fallback candidate, then stop and ask the user to name or
confirm the target branch.git-commit empty-index git add . pass, or conflict resolutions.git branch --show-current, git branch --list <target-branch>,
and git status --short.git worktree list.git worktree list whose branch is
exactly <target-branch>. Use that path for the final merge when present.<target-branch>.
If no worktree is already checked out to the target branch, plan to create a
temporary target worktree for the merge step instead of switching another
checkout's branch.<target-branch>, use the first
clean one. If all target worktrees are dirty, record each dirty target path
and its git status --short output. Do not touch the target worktrees or stop
yet; finish the source branch creation and source commit first, then use the
dirty-target pause flow below.When git branch --show-current is empty, create a source branch automatically
without staging files or changing the current commit:
git rev-parse HEAD and the exact git status --short output.git log <target-branch>..HEAD.git-commit skill's Branch Name Guidance to derive the
candidate from the evidence above. Derive the name only; do not enter that
skill's staging or commit workflow yet.git check-ref-format --branch <branch-name>.git switch -c <branch-name>.git switch <branch-name> and reuse it.-2, -3, and so on until an unused valid name is
found, then run git switch -c <numbered-branch-name>.
Use git show-ref --verify and git worktree list --porcelain to distinguish
these cases. Never reset or move an existing branch.git rev-parse HEAD still matches
the recorded commit, and require git status --short to preserve the exact
staged, unstaged, and untracked state. Stop if attachment changes content.Do not stage files solely to generate the branch name. Continue with the normal commit, rebase, and merge workflow after attachment.
git-commit skill:
staging scope, the single empty-index git add . pass, message drafting,
commit execution, permission retry, and cleanup all follow git-commit.git rebase, run git merge,
locate a target worktree, create a temporary target worktree, fetch, pull, or
push.git-commit Post-Commit Report and state
that no rebase, merge, or push was performed.git-commit mechanics for staged source changes. Let that skill own
staged-only scope, the one allowed empty-index git add . pass, message
drafting, commit execution, permission retry, and cleanup. In normal
rebase/merge mode, this workflow overrides git-commit default-mode
reporting order; in direct commit mode, follow git-commit reporting.HEAD before the commit step. Classify the source result as
created-this-run only when the commit step changes HEAD; otherwise, when
the source is already committed and clean, classify it as
preexisting-source-commit.commit_message.txt or running git commit -F commit_message.txt, send a normal assistant message with the fixed heading
提交信息预览 and a fenced text code block containing the full actual
drafted commit message.commit_message.txt content,
except for Markdown code fences. It must not appear only in tool output,
terminal output, hidden reasoning, log files, commit_message.txt, or final
Git command output.git-commit reports there is no commit to make, continue only when the
source worktree has no uncommitted changes. Mark the result as
preexisting-source-commit; otherwise stop and report the uncommitted state.git status --short after the commit step. Rebase only from a clean
source worktree unless the user explicitly decides otherwise.<target-branch>, finish the
source commit through git-commit and require a clean source worktree, then
stop before scope inspection, rebase, merge, or push.继续. On continuation,
rerun target resolution, git worktree list, and target cleanliness checks.
Reuse the existing clean source commit unless the source gained new changes;
if it did, commit those changes through git-commit before rebasing.git log --oneline <target-branch>..<source-branch> and
git diff --stat <target-branch>...<source-branch>.git rebase <target-branch>.git status --short, resolve semantically, stage only
resolved files, and run git rebase --continue. Stop for product decisions
or unsafe conflicts.git diff --check <target-branch>...HEAD, and run broader validation only
when repository rules or touched code require it./tmp/worktree-rebase-merge-<repo>-<target>-<pid>, with
git worktree add <temporary-path> <target-branch>. Confirm the temporary
worktree is on <target-branch> and clean before merging.<target-branch>.git update-ref, git branch -f, or other worktree-bypassing operations.
Use a real target worktree so Git keeps the branch, index, and files in an
understandable state.git merge <source-branch> with default Git behavior. Do not force
--no-ff, squash, rebase again, or push unless the user explicitly asks.git merge --continue. If the conflict
happens in a temporary target worktree, keep that worktree and report its path
for follow-up resolution instead of deleting it.git worktree remove <temporary-path>.existing-target-worktree or
temporary-target-worktree), temporary target worktree path when one was
created, merge result, and final clean status. For an attached checkout, also
report the original detached commit and whether the source branch was created
or reused. State that no push was performed unless the user asked for one.git-commit Post-Commit Report for that commit. Use 已创建提交 for
created-this-run; for preexisting-source-commit, use
本次未创建新提交;合并的是源分支已有提交.--range <target-commit>...<source-commit> to report aggregate total, code, and
documentation text changes. Do not present one commit message as the message
for the whole range.