# sdlc:complete > Finish work and reset local environment for next task - Author: Matthew Fornaciari - Repository: mattforni/skillset - Version: 20260126154408 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/mattforni/skillset - Web: https://mule.run/skillshub/@@mattforni/skillset~sdlc:complete:20260126154408 --- --- name: sdlc:complete description: Finish work and reset local environment for next task disable-model-invocation: true allowed-tools: - Bash(git:*) - Bash(linearis:*) --- # Complete Work Finish the current task and reset the local environment for the next piece of work. ## Workflow 1. **Verify PR is merged** - Confirm the work is complete 2. **Update Linear issue** - Mark as Done (if applicable) 3. **Checkout main** - Switch to main branch 4. **Pull latest** - Get all merged changes 5. **Cleanup branches** - Delete merged local branches 6. **Confirm reset** - Show clean state ## Step 1: Verify PR is Merged Check if the current branch has a merged PR: ```bash # Get default branch (see scripts/get-base-branch.sh) BASE_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@') CURRENT_BRANCH=$(git branch --show-current) # Skip if already on default branch if [ "$CURRENT_BRANCH" = "$BASE_BRANCH" ]; then echo "Already on default branch ($BASE_BRANCH)" else # Check PR status PR_STATE=$(gh pr view --json state --jq '.state' 2>/dev/null || echo "NONE") if [ "$PR_STATE" = "OPEN" ]; then echo "WARNING: PR for $CURRENT_BRANCH is still open" echo "Are you sure you want to abandon this work?" # Continue anyway - user may want to discard elif [ "$PR_STATE" = "MERGED" ]; then echo "PR merged successfully" elif [ "$PR_STATE" = "NONE" ]; then echo "No PR found for branch $CURRENT_BRANCH. Proceeding to clean up local branch." fi fi ``` ## Step 2: Update Linear Issue (Optional) If the branch name looks like a Linear issue ID (e.g., `ATE-123`), update its status: ```bash # Extract issue ID from branch name if it matches pattern ISSUE_ID=$(echo "$CURRENT_BRANCH" | grep -oE '^[A-Z]+-[0-9]+') if [ -n "$ISSUE_ID" ] && command -v linearis &> /dev/null; then echo "Marking $ISSUE_ID as Done..." linearis issues update "$ISSUE_ID" --state "Done" 2>/dev/null || true fi ``` ## Step 3: Checkout Default Branch ```bash # BASE_BRANCH was determined in Step 1 git checkout "$BASE_BRANCH" ``` ## Step 4: Pull Latest ```bash git pull origin "$BASE_BRANCH" ``` ## Step 5: Cleanup Branches Prune remote tracking branches: ```bash git fetch --prune ``` List branches and identify those that can be deleted: ```bash git branch -vv ``` For branches showing `[gone]` (remote was deleted after merge), delete them: ```bash # Delete branches where remote is gone (handles spaces in branch names) git branch -vv | grep ': gone]' | sed -E 's/^\s*(\* )?//; s/\s+[a-f0-9]{7,}.*//' | while read -r branch; do echo "Deleting merged branch: $branch" git branch -d "$branch" done ``` Also delete the branch we were just on if it's different from the default branch: ```bash if [ "$CURRENT_BRANCH" != "$BASE_BRANCH" ]; then git branch -d "$CURRENT_BRANCH" 2>/dev/null || true fi ``` ## Step 6: Confirm Reset Show the clean state: ```bash echo "" echo "Environment reset complete" echo "Branch: $(git branch --show-current)" echo "Status:" git status --short ``` ## Output ``` Environment reset complete Branch: main Status: (clean) Ready for next task. Use /sdlc:plan to start. ```