|
| 1 | +--- |
| 2 | +name: close-task-commit-push-pr |
| 3 | +description: Close the active backlog task (detected from branch name), commit all changes, push to remote, and open a pull request. Use when the user says "close task and ship it", "close task commit push pr", or invokes /close-task-commit-push-pr. |
| 4 | +allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git diff:*), Bash(git log:*), Bash(git commit:*), Bash(git push:*), Bash(git branch:*), Bash(git checkout:*), Bash(gh pr create:*), mcp__backlog__task_edit, mcp__backlog__task_complete, mcp__backlog__task_view |
| 5 | +--- |
| 6 | + |
| 7 | +# Close Task, Commit, Push & PR |
| 8 | + |
| 9 | +## Context |
| 10 | + |
| 11 | +- Current git status: !`git status` |
| 12 | +- Current git diff (staged and unstaged changes): !`git diff HEAD` |
| 13 | +- Current branch: !`git branch --show-current` |
| 14 | +- Main branch: !`git rev-parse --verify main 2>/dev/null && echo main || echo master` |
| 15 | +- Recent commits: !`git log --oneline -10` |
| 16 | + |
| 17 | +## Your task |
| 18 | + |
| 19 | +Close the active backlog task, commit all changes, push, and open a pull request. |
| 20 | + |
| 21 | +### Step 0 — Identify the task |
| 22 | + |
| 23 | +- Extract the task ID from the current branch name (e.g. `feature/task-113-split-css-modules` → `task-113`). |
| 24 | +- If no task ID is found in the branch name, ask the user which task to close. |
| 25 | + |
| 26 | +### Step 1 — Close the backlog task |
| 27 | + |
| 28 | +Close the task **before** committing so the task file changes are included in the commit and PR. |
| 29 | + |
| 30 | +- Use `mcp__backlog__task_view` to read the task details (title, acceptance criteria). |
| 31 | +- Use `mcp__backlog__task_edit` to: |
| 32 | + - Set status to `Done` |
| 33 | + - Check off all acceptance criteria that were completed (review the diff to determine which ones) |
| 34 | + - Write a `finalSummary` that concisely describes what was implemented |
| 35 | +- Use `mcp__backlog__task_complete` to move the task to the completed folder. |
| 36 | + |
| 37 | +### Step 2 — Analyze changes and plan commits |
| 38 | + |
| 39 | +Before committing, analyze `git status` and `git diff HEAD` to identify logically distinct groups of changes. Group by feature or concern — for example: |
| 40 | + |
| 41 | +- New files that form a self-contained module → one commit |
| 42 | +- Modifications to an existing file that depend on the new module → separate commit |
| 43 | +- Task/backlog file changes → include in the final commit (or a dedicated chore commit) |
| 44 | + |
| 45 | +Print a short commit plan (list of planned commits with the files in each) so the grouping is visible. |
| 46 | + |
| 47 | +### Step 3 — Commit |
| 48 | + |
| 49 | +- Create one commit per logical group identified above. Stage only the files for that group using explicit file names (never `git add -A`; never stage `.env` or credential files). |
| 50 | +- Write a clean, descriptive commit message for each commit using conventional commits style. |
| 51 | +- End every commit message with: |
| 52 | + `Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>` |
| 53 | +- Use a HEREDOC to pass the commit message for correct formatting. |
| 54 | +- **Include the closed task file** in the final commit. |
| 55 | + |
| 56 | +### Step 4 — Push |
| 57 | + |
| 58 | +- If the current branch is `main` or `master`, create a new feature branch first (use a descriptive name based on the changes). |
| 59 | +- Push the branch to origin with `-u` to set upstream tracking. |
| 60 | + |
| 61 | +### Step 5 — Pull Request |
| 62 | + |
| 63 | +- Create a PR using `gh pr create` targeting the main branch. |
| 64 | +- Keep the PR title short (under 70 characters), using conventional commit style. |
| 65 | +- Use a HEREDOC for the PR body with this format: |
| 66 | + |
| 67 | +``` |
| 68 | +## Summary |
| 69 | +<1-3 bullet points describing the changes> |
| 70 | +
|
| 71 | +## Test plan |
| 72 | +- [ ] <testing checklist items> |
| 73 | +
|
| 74 | +🤖 Generated with [Claude Code](https://claude.com/claude-code) |
| 75 | +``` |
| 76 | + |
| 77 | +### Step 6 — Update task with PR reference |
| 78 | + |
| 79 | +- Now that you have the PR number, use `mcp__backlog__task_edit` to append the PR URL/number to the `finalSummary`. |
| 80 | + |
| 81 | +### Step 7 — Amend commit with updated task file |
| 82 | + |
| 83 | +- Stage the updated task file and amend the last commit to include the PR reference: `git commit --amend --no-edit` then `git push --force-with-lease`. |
| 84 | + |
| 85 | +### Step 8 — Report |
| 86 | + |
| 87 | +- Print the PR URL and confirm the task was closed. |
| 88 | + |
| 89 | +## Rules |
| 90 | + |
| 91 | +- Do all steps in as few messages as possible. Parallelize independent tool calls. |
| 92 | +- Do not read or explore code beyond what git provides in the context above. |
| 93 | +- Do not use interactive git flags (`-i`). |
| 94 | +- Never force-push or amend existing commits. |
| 95 | +- If a pre-commit hook fails, fix the issue and create a NEW commit (do not amend). |
0 commit comments