一键导入
finish
Finish a worktree development session - commit, merge to main, and clean up
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Finish a worktree development session - commit, merge to main, and clean up
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | finish |
| description | Finish a worktree development session - commit, merge to main, and clean up |
High-level orchestrator that completes a worktree development session. This skill manages three phases — commit, merge, cleanup — delegating each to a sub-agent via the Agent tool so failures are isolated and the parent never loses track of its checklist.
Critical rule: The parent agent does almost no real work itself. It launches sub-agents, checks their results, and moves to the next phase. Only Steps 4–5 (lightweight verification and summary) are done by the parent directly.
Run each step sequentially. If any step fails, stop and report the failure to the user. Do not proceed to the next step.
Launch a foreground sub-agent (via the Agent tool) with this prompt:
Check for uncommitted changes and commit them if needed.
- Run
git status --porcelainto check for uncommitted changes.- If the working tree is clean (no output), report "Nothing to commit" and stop.
- If there are uncommitted changes, commit them. Follow the standard commit procedure: stage relevant files, write a concise commit message describing the changes, and create the commit.
- Verify the commit succeeded by confirming
git status --porcelainis now clean.- If the commit fails (e.g. pre-commit hook rejection), fix the issue and retry once. If it still fails, report the error.
Report back: what was committed (file list + commit message), or that the tree was already clean.
Wait for the result. If the agent reports a commit failure, stop and tell the user.
Before launching the agent, capture the worktree info for later:
WORKTREE_NAME=$(basename "$(git rev-parse --show-toplevel)")
AGENT_NAME=$(cat _agent/agent/.agent_info/name 2>/dev/null || echo "")
Launch a foreground sub-agent (via the Agent tool) with the full merge + e2e instructions inlined. Do NOT tell the agent to "invoke the /merge skill" or "invoke the /e2e skill". Instead, use this prompt:
Merge the current worktree branch into main and run full checks.
Preflight
- Ensure we are not already on main.
- Ensure all changes are committed. If not, commit them automatically.
Merge
- Run
git checkout main && git merge <branch>.- If the merge succeeds with no conflicts, proceed to the check step.
- If there are merge conflicts: a. Run
git diff --name-only --diff-filter=Uto list conflicted files. b. For each conflicted file, read it, understand both sides of each conflict, resolve intelligently, and edit to remove all conflict markers. c. Stage resolved files:git add <resolved files>d. Complete the merge:git commit --no-edite. Report what resolutions were made.Rebuild native utilities if changed
After merging, check if native utility source code changed:
git diff HEAD^1 HEAD --name-only -- app/native_utils/If any files under
app/native_utils/were changed, run./preparefrom the repo root. If none changed, skip this.Run checks
- Run
./quickcheckfrom the repo root.- Then run the end-to-end tests. Determine a short note describing why this run is happening. Include the branch name and, if an agent name was provided, the agent name (e.g. "Verifying main after merging branch
wt-pale-dotfrom agentfix-graph-drag-selection"). If no agent name is available, omit the "from agent" part. The agent name for this worktree is: "${AGENT_NAME}". Run:./app/e2e-tests/_module/scripts/slowcheck --run-notes "<your note>"- If any check fails: a. Read the output carefully to identify what failed. b. Investigate the failing code — read relevant files and understand the issue. c. Fix the problem. d. Stage the fix and commit with the prefix
merge fix:in the message. e. Re-run./quickcheck(and e2e if the e2e test failed). f. Repeat up to 3 times. If still failing after 3 attempts, report: "Checks are still failing after 3 fix attempts. Manual intervention needed." and include the failure output.Key files for e2e debugging
app/e2e-tests/tests/*.spec.ts— test specsapp/e2e-tests/src/run/test-fixtures.ts— custom Playwright fixturesapp/e2e-tests/src/run/pages/— page object models used by testsapp/e2e-tests/playwright.config.ts— test configuration, Docker container setup~/meadow-e2e-artifacts/— test run output (videos, logs, state snapshots)Report back
- Branch that was merged
- Whether there were conflicts (and how they were resolved)
- Whether any post-merge fixes were needed (list the fix commits)
- quickcheck result (pass/fail)
- e2e test result (pass/fail, which tests ran)
Wait for the result. Verify that e2e tests were actually executed — look for e2e test output in the agent's response. If there is no evidence that e2e tests ran and the agent reported success, that is a failure — report it to the user. If the merge or checks failed, stop and tell the user. Do not proceed to cleanup.
Launch a foreground sub-agent (via the Agent tool) with the cleanup instructions inlined plus the tmux cleanup. Use the WORKTREE_NAME captured earlier. Do NOT tell the agent to "invoke the /cleanup skill". Use this prompt:
Safely clean up the current worktree and its branch.
Preflight checks
Run all of these. If any check fails, report why and stop.
- Run
git rev-parse --git-dirand confirm we are inside a worktree (the git-dir path will contain/worktrees/). If not, stop.- Run
git status --porcelain. If there is any output, stop — there are uncommitted changes.- Record the current state:
BRANCH=$(git branch --show-current) WORKTREE_PATH=$(git rev-parse --show-toplevel) MAIN_REPO=$(git rev-parse --path-format=absolute --git-common-dir | sed 's|/\.git$||') WORKTREE_NAME=$(basename "$WORKTREE_PATH")Determine if it is safe to delete
Check these conditions in order:
Condition A: No work done — branch is identical to main
git diff main...HEAD --quiet git rev-list main..HEAD --count # must be 0If both pass, the branch has no unique work. Safe to delete.
Condition B: All work has been merged to main
git rev-list main..HEAD --count # greater than 0 means there are commits git branch --contains HEAD main # if main appears, all commits are mergedIf there are commits but main contains HEAD, everything is already merged. Safe to delete.
Neither condition met: Report that this branch has commits not yet on main and stop. Do not delete anything.
Clean up
Kill any tmux sessions associated with this worktree:
tmux kill-session -t "meadow_dev_${WORKTREE_NAME}" 2>/dev/null || true tmux list-sessions -F '#{session_name}' 2>/dev/null | grep "$WORKTREE_NAME" | while read -r sess; do tmux kill-session -t "$sess" 2>/dev/null || true doneNavigate out and remove the worktree and branch:
cd "$MAIN_REPO" git worktree remove --force "$WORKTREE_PATH" git branch -D "$BRANCH" git worktree pruneReport back
- Worktree path that was removed
- Branch that was deleted
- Tmux sessions that were killed (if any)
- Which condition applied (no work done, or already merged to main)
Wait for the result. If cleanup failed, report the issue to the user.
The parent does this itself — no sub-agent needed.
Run through this checklist. If any item fails, report it to the user as a warning.
git status --porcelain is clean on main (no uncommitted changes)git worktree list does not mention the old worktree pathgit branch does not list the old worktree branchtmux list-sessions 2>/dev/null | grep "$WORKTREE_NAME" returns nothing)./quickcheck was run during merge and passedPrint a final summary:
List and run agent tasks defined in _module/agent_tasks/ directories across the repo
Build the Meadow Electron app and launch it in test mode to verify it starts cleanly
Safely clean up the current worktree after verifying no unmerged work would be lost
Run the end-to-end test suite, automatically diagnose and fix failures
Understand and extend the regenerable canonical scenario artifact in the e2e report viewer — used for iterating on the viewer's UI against stable, self-documenting data without running real tests
Merge a worktree branch into main - handle conflicts, run full checks, auto-fix issues