AgentSkillsCN

finish-task

完成一项任务——核对所有标准、提交代码、推送更改、创建 Pull Request,并更新 Jira 事项。

SKILL.md
--- frontmatter
name: finish-task
description: Complete a task - verify all criteria, commit, push, create PR, and update Jira
disable-model-invocation: true
allowed-tools: Bash(git *), Bash(gh pr *), Bash(pytest *), Bash(ruff *), Bash(source *), Read

Finish Task Skill

This skill handles the completion workflow for a Ralph Loop task.

Prerequisites

  • Active task in docs/CURRENT_TASK.md
  • All tests must pass
  • All linting must pass
  • Changes must be committed

Workflow

Step 1: Read Current Task

code
Read docs/CURRENT_TASK.md
Extract: JIRA_ID, branch_name

Step 2: Verify Exit Criteria

Run verification checks:

bash
# Check tests pass
pytest || npm test

# Check linting
ruff check . || npm run lint

If any check fails, DO NOT proceed. Fix the issues first.

Step 3: Verify Acceptance Criteria

Review each acceptance criterion in CURRENT_TASK.md. All checkboxes must be checked.

Step 4: Final Commit

If there are uncommitted changes:

bash
git add -A
git commit -m "{JIRA_ID}: Final implementation - all tests pass"

Step 5: Push to Remote

bash
git push -u origin {branch_name}

Step 6: Create Pull Request

Use gh CLI to create PR:

bash
gh pr create \
  --title "[{JIRA_ID}] {summary}" \
  --body "## Summary

Implements {JIRA_ID}

## Changes

{list of commits}

## Testing

- [x] Unit tests pass
- [x] Integration tests pass
- [x] Linting passes

## Jira

[{JIRA_ID}]($JIRA_URL/browse/{JIRA_ID})

---
🤖 *Generated by Claude Code Agent*"

Step 7: Update Jira

Transition to "In Review":

code
python3 .claude/utils/jira_api.py transition-issue "{JIRA_ID}" "In Review"

Add completion comment:

code
python3 .claude/utils/jira_api.py add-comment "{JIRA_ID}" "🤖 Implementation complete!\n\n**Branch:** `{branch_name}`\n**PR:** {pr_url}\n\nAll tests pass. Ready for review."

Step 8: Update CURRENT_TASK.md

Mark task as complete:

markdown
## Active Task

**Jira ID:** {JIRA_ID}
**Status:** ✅ Complete - In Review
**Branch:** {branch_name}
**PR:** {pr_url}
**Completed:** {timestamp}

Step 8b: Notify Monitor - PR Created

Update the monitor to show the Jules Review step:

bash
python3 -c "
import sys; sys.path.insert(0, '.claude/utils')
from monitor_client import send_task_update
send_task_update('{JIRA_ID}', step=4, step_name='Jules Review', step_desc='PR created, awaiting review...')
import time; time.sleep(0.5)
"

If monitor is offline, ignore and continue (non-blocking).

Step 9: Output Completion Promise

Only after ALL steps are verified:

code
<promise>DONE</promise>

Step 10: Deactivate Ralph Loop

Remove the loop flag file to allow normal exit:

bash
rm -f .claude/.ralph_loop_active

This signals to the stop-hook that we're no longer in an active task loop.

Error Handling

  • Tests fail: Do not proceed, fix tests first
  • Lint fails: Do not proceed, fix linting issues
  • Push fails: Check for conflicts, resolve and retry
  • PR creation fails: Check gh auth status
  • Jira update fails: Log warning but continue (non-blocking)

Important

This skill should ONLY be invoked when:

  1. All acceptance criteria are met
  2. All tests pass
  3. All linting passes
  4. The agent is confident the implementation is complete

The <promise>DONE</promise> output triggers the stop-hook to allow exit.