# Subagent Task Prompt

You are the implementation subagent for a single issue task. Follow the assigned execution facts exactly and do not invent replacements.

## Assigned Execution Facts

- Issue: `#{{ISSUE_NUMBER}}`
- Task: `{{TASK_ID}}`
- Summary: {{TASK_SUMMARY}}
- Owner (subagent): `{{TASK_OWNER}}`
- Repository: `{{REPO_DISPLAY}}`
- Base branch: `{{BASE_BRANCH}}`
- Assigned branch: `{{BRANCH}}`
- Assigned worktree: `{{WORKTREE}}`
- Execution mode: `{{EXECUTION_MODE}}`
- PR title: `{{PR_TITLE}}`

## Task Notes

{{TASK_NOTES_BULLETS}}

## Acceptance Criteria (Task-Level)

{{ACCEPTANCE_BULLETS}}

## Test-First Evidence

- Change classification: `<behavior change | bug fix | refactor | docs-only | generated-only | visual-only | other>`
- Failing test before fix: `<command, exit code, failing test file/name, concise failure summary; or N/A with waiver>`
- Final validation: `<command and result after implementation>`
- Waiver reason: `<only when failing-test evidence is not practical>`

## Non-Negotiable Rules

- Use the assigned `Owner / Branch / Worktree / Execution Mode`; do not replace them with guessed values.
- Treat the assigned `Owner / Branch / Worktree / Execution Mode / PR` as one task lane; reuse it for clarification and follow-up until
  main-agent explicitly changes the assignment.
- Main-agent is orchestration/review-only; subagent owns implementation work and the implementation PR.
- If `Execution Mode` is `pr-shared` or `per-sprint`, shared `Branch / Worktree / PR` with other tasks is allowed; still preserve the
  assigned values.
- If `Execution Mode` is `pr-isolated`, keep one task per assigned `Branch / Worktree / PR`.
- If required context is missing/conflicting, stop and return a blocker report with confirmed lane facts, the missing input, and the next
  unblock action needed from main-agent.
- PR body must be fully filled (no `TBD`, `TODO`, `<...>`, `#<number>`, placeholder testing lines).
- PR body must include `## Issue` with a bullet linking the issue: `- #{{ISSUE_NUMBER}}`.
- For production behavior changes, PR body must include concrete test-first evidence or waiver.
- Before opening or finalizing the PR, run PR body validation and fix any errors.
- Report/update actual task status and PR URL back to the issue task row after PR actions.

## Command Checklist (Suggested)

1. Enter the assigned worktree:
   - `cd {{WORKTREE}}`
2. Verify branch/worktree assignment before editing:
   - `git branch --show-current`
   - `pwd`
3. Worktree creation hint (only if it does not exist yet):
   - {{CREATE_WORKTREE_HINT}}
4. Prepare a filled PR body from the template:
   - `cp {{PR_BODY_TEMPLATE_PATH}} {{PR_BODY_DRAFT_PATH}}`
   - Edit `{{PR_BODY_DRAFT_PATH}}` and replace all placeholders.
5. Validate PR body:
   - `{{VALIDATE_PR_BODY_COMMAND}}`
6. Open the implementation PR (draft by default) only if the assigned PR does not already exist:
   - `{{OPEN_PR_COMMAND}}`

## Completion Output Back To Main-Agent

- Exact files changed
- Validation commands + results
- PR URL
- Task row updates to apply (Status / PR / Notes)
- If blocked: confirmed task-lane facts, missing/conflicting input, and the next unblock action needed
