AgentSkillsCN

finish-task

完成一项任务——核对所有标准、提交、推送、创建PR,并更新Jira

SKILL.md
--- frontmatter
name: finish-task
description: Complete a task - verify all criteria, commit, push, create PR, and update Jira
args: none (uses current task from CURRENT_TASK.md)

Finish Task Skill

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

Prerequisites

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

Workflow

Step 1: Read Current Task

code
Read CURRENT_TASK.md
Extract: JIRA_ID, branch_name

Step 2: Verify Exit Criteria

Run verification checks:

bash
# Check tests pass
pytest -xvs --cov=. --cov-report=term-missing --cov-fail-under=80

# Check linting
ruff check .

# Check formatting
ruff format --check .

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

Co-Authored-By: Claude Code <noreply@anthropic.com>"

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}](https://your-domain.atlassian.net/browse/{JIRA_ID})

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

Step 7: Update Jira

IMPORTANT: Use direct Jira API, NOT MCP tools.

Transition to "In Review":

bash
source venv/bin/activate && python3 -c "
from dotenv import load_dotenv
load_dotenv()
from src.sejfa.integrations.jira_client import get_jira_client
client = get_jira_client()
try:
    client.transition_issue('{JIRA_ID}', 'In Review')
    print('✅ Transitioned to In Review')
except Exception as e:
    print(f'⚠️ Could not transition: {e}')
"

Add completion comment:

bash
source venv/bin/activate && python3 -c "
from dotenv import load_dotenv
load_dotenv()
from src.sejfa.integrations.jira_client import get_jira_client
client = get_jira_client()
comment = '''🤖 Implementation complete!

**Branch:** {branch_name}
**PR:** {pr_url}

All tests pass. Ready for review.'''
try:
    client.add_comment('{JIRA_ID}', comment)
    print('✅ Added comment to Jira')
except Exception as e:
    print(f'⚠️ Could not add comment: {e}')
"

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 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.

Important: Never remove .claude/.ralph_loop_active before <promise>DONE</promise> is output — the stop-hook fails open when the loop flag is missing, which disables enforcement early.

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.