Complete an in-progress task by running clean-code, staging, committing, and closing the bead. Use after /verify-task.
Run clean-code, stage, and commit an in-progress task — the finalization phase of the development workflow. Whether the bead is closed here depends on the workflow: in a trunk / direct-commit repo the commit is the deliverable, so the bead closes now; in a PR-based repo the bead stays open until /create-pr; on a detached HEAD the commit is not safely owned by a branch, so the bead stays open.
/verify-task has passed (or verification is not needed)Run /verify-task before this skill to confirm requirements are met and test coverage is adequate. If you haven't verified yet, do that first.
/complete-task # Auto-detect in-progress bead
/complete-task <bead-id> # Complete a specific bead
Determine which bead is being completed, then prove which store owns it before reading or closing anything. Never infer the owning store from the bead ID or the current directory: at a workspace root the cwd store is the workspace store, not the repository that owns the work.
# Otherwise, find candidate in-progress beads in the active store
bd list --status=in_progress
# Resolve the chosen bead to its owning store (read-only)
~/.agents/skills/next/scripts/next-select resolve <bead-id>
If multiple beads are in progress, ask the user which one to complete. If no beads are in progress, ask the user what to do.
Act on the resolver status:
| status | action |
|---|---|
| resolved | take directory; every later bd call in this skill uses bd -C <directory> |
| ambiguous | show matches[].selector, ask which <repo>:<id> is meant; close nothing |
| unavailable | report failures; commit as normal but leave the bead untouched and say why |
| not-found | ask the user for the right ID; never guess another store or create a bead |
Then read it in its owning store:
bd -C <directory> show <bead-id>
make clean-code
If clean-code fails:
Inspect git status --porcelain=v1 --untracked-files=all first. Stop if the status command fails.
With task changes, HEAD may be unborn: stage and create the initial commit normally.
Only on the existing-commit path, require git rev-parse HEAD to succeed; stop if it does not.
If there is nothing to commit, do not create an empty commit. This includes a rerun after preserving
an earlier detached commit on a branch. Confirm that HEAD is the exact task commit, the working tree
is clean, and verification evidence applies to that commit; rerun /verify-task if evidence is
missing or HEAD changed. Show the SHA and ask Finalize this verified commit or Stop.
Only after confirmation, skip staging and committing and continue to §5. If HEAD or task identity is
uncertain, leave the bead open; an empty diff is not proof that the task is complete.
Stage only the files changed for this task:
git add <specific-files>
Rules:
git add -A or git add .git add src/)For staged task changes only, create a commit using conventional commit format:
git commit -m "$(cat <<'EOF'
<type>: <concise description>
EOF
)"
Commit message rules:
feat:, fix:, docs:, chore:, refactor:, perf:, test:feat:, bug → fix:, task → contextual)Require either a successful new commit or an explicitly confirmed existing verified commit from §3. Then classify the current checkout to decide whether the bead closes now or later; neither path bypasses detached-HEAD protection or the PR handoff.
# Default branch (origin/HEAD, falling back to local main/master)
default_branch=$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | sed 's#^origin/##')
if [ -z "$default_branch" ]; then
for c in main master; do git show-ref --verify --quiet "refs/heads/$c" && default_branch=$c && break; done
fi
current_branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null || true)
head_sha=$(git rev-parse HEAD)
git remote # empty output = no remote
Classify in this order:
current_branch is empty. The commit exists at head_sha but no branch owns
it, regardless of remotes or default-branch detection.current_branch equals default_branch, or there is no
remote. The commit itself is the deliverable.current_branch differs from default_branch) with a
remote. The PR is the next lifecycle step.Never close a bead if the commit failed or changes are still uncommitted.
Trunk mode — close the bead now (the commit is the whole deliverable):
bd -C <directory> close <bead-id> --reason="<brief summary of what was done>"
Detached mode — never close the bead. Report the detached commit SHA, leave the bead in_progress,
and offer the exact preservation command without running it automatically:
git switch -c {branch-name}
After the user creates an attached branch, /complete-task may be rerun to classify the workflow
and finalize the bead.
PR mode — do not close the bead here. By convention the bead is closed one step later, at the /create-pr stage (and reopened if review demands major changes); closing at commit time would be premature, before the PR even exists. Instead, tell the user a PR workflow was detected (on branch {current_branch}) and the bead is being left in_progress, then offer the next step with AskUserQuestion:
/create-pr skill via Skill. It pushes, opens the PR, and closes the bead.in_progress; remind the user to run /create-pr when ready.After finalizing:
Summarize what was done:
in_progress (PR or detached)git switch -c {branch-name}; never close the bead while no branch owns the commit./create-pr (or the user) handles the existing PR. Don't open a duplicate.--no-verify or skip git hooks/create-pr handoff, not in this skill/create-pr (reopen later if review demands major changes)Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer