finish-task

Cleans up worktrees, branches, and plan files after a PR merges.

5|Updated Jun 22, 2026
One-click install
npx skills add https://github.com/A158Coke/WotbTools --skill finish-task-a158coke
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: finish-task
Source: https://github.com/A158Coke/WotbTools/tree/main/.agents/skills/finish-task
Command: npx skills add https://github.com/A158Coke/WotbTools --skill finish-task-a158coke

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? After a pull request is merged, developers often leave behind stale task worktrees, merged local and remote branches, and outdated plan files. This Skill automates the entire post-merge cleanup so the workspace is immediately ready for the next task. ## Core Features & Use Cases - Worktree Cleanup: Verifies the task worktree has no uncommitted changes, then removes it from the main worktree using non-forced git worktree remove and prunes stale entries. - Branch Deletion: Deletes merged local branches with safe git branch -d (never -D) and removes remote branches only after confirming via git ls-remote that the PR is merged. - Plan File Reset: Marks tasks in docs/current-plan.md as COMPLETED or BLOCKED, then resets the file to its initial template state. - Use Case: After your feature PR is merged on GitHub, tell the agent to start cleanup; it switches to main, pulls the latest merge commit, removes the task worktree and branches, resets the plan file, and reports a full cleanup summary. ## Quick Start Tell the agent the PR has been merged and ask it to run the finish-task cleanup for that PR number.

Frequently Asked Questions about finish-task

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I clean up Git worktrees and branches after a PR merge?

Verify the PR state is MERGED with gh pr view, switch to the main worktree, run git worktree remove on the task worktree, then delete merged branches with git branch -d locally and git push origin --delete remotely after confirming with git ls-remote.

What is the safe way to delete a Git branch after merging?

Use git branch -d instead of -D, since -d refuses to delete branches that are not fully merged into main. For remote branches, first check existence with git ls-remote --heads origin and confirm the associated PR is merged before deleting.

Can this cleanup run if the worktree has uncommitted changes?

No. The workflow runs git status --short first and stops immediately if uncommitted changes exist, asking the user to decide. It never uses --force removal or overwrites uncommitted work.

Why does git worktree remove fail and how is it handled?

Removal fails when the worktree contains uncommitted modifications or when the command runs from inside the worktree being deleted. The procedure switches to the main worktree first and uses non-forced removal, then runs git worktree prune to clear stale entries.

What happens to the current-plan.md file after task completion?

The plan file is read, in-progress tasks are marked COMPLETED or BLOCKED based on actual results, and the file is reset to its initial template containing only the header comment so it is ready for the next task.