Skip to content

My5t3r10us/cesizen / .agents/skills/apex

Systematic implementation using APEX methodology (Analyze-Plan-Execute-eXamine) with optional parallel subagents, self-validation, and adversarial review. Use when implementing features, fixing bugs, or making code changes that benefit from structured workflow.

steps/step-09-finish.md

View on GitHub
---
name: step-09-finish
description: Finish APEX workflow and create pull request
previous_step: step-08-run-tests.md (or step-04-validate.md if no tests)
---

# Step 9: Finish & Create PR

## MANDATORY EXECUTION RULES (READ FIRST):

- πŸ›‘ NEVER push without user confirmation (unless auto_mode)
- πŸ›‘ NEVER create PR if there are uncommitted changes
- βœ… ALWAYS verify all changes are committed
- βœ… ALWAYS push to remote before creating PR
- πŸ“‹ YOU ARE A FINISHER, completing the workflow
- πŸ’¬ FOCUS on PR creation and workflow summary
- 🚫 FORBIDDEN to make code changes in this step

## EXECUTION PROTOCOLS:

- 🎯 Verify git status before any push/PR operations
- πŸ’Ύ Save PR details to output file if save_mode enabled
- πŸ“– Provide clear workflow summary
- 🚫 FORBIDDEN to proceed with uncommitted changes

## CONTEXT BOUNDARIES:

- Variables available: `{task_id}`, `{task_description}`, `{branch_name}`, `{pr_mode}`, `{auto_mode}`, `{save_mode}`, `{teams_mode}`, `{output_dir}`
- Previous steps completed: analyze, plan, execute, validate (+ optional: tests, examine)
- All implementation should be done at this point

## YOUR TASK:

Finalize the APEX workflow by committing remaining changes, pushing to remote, and creating a pull request.

---

## EXECUTION SEQUENCE:

### 0. Shutdown Agent Team (if teams_mode)

<critical>
This is the ONLY step where team shutdown should happen.
All previous steps (validate, examine, resolve) keep the team alive.
</critical>

**If `{teams_mode}` = true:**

1. Send shutdown_request to each teammate:
```
SendMessage:
  type: "shutdown_request"
  recipient: "impl-{name}"
  content: "APEX workflow complete. Shutting down team."
```

2. Wait for all teammates to confirm shutdown.

3. Delete the team:
```
TeamDelete
```

β†’ This cleans up team files and task directories.

### 1. Verify Git Status

```bash
git rev-parse --is-inside-work-tree
git status
```

If Git metadata is unavailable, skip every commit, push and pull-request step.
Finish with the changed-file and validation summary only.

**If uncommitted changes exist:**
β†’ Commit them with message: `feat({task_id}): {task_description}`

**If working tree is clean:**
β†’ Continue to step 2

### 2. Check Commits to Push

```bash
git log origin/{branch_name}..HEAD --oneline 2>/dev/null || git log --oneline -5
```

Display commits that will be included in PR.

### 3. Confirm Push (if not auto_mode)

**If `{auto_mode}` = true:**
β†’ Auto-push to remote

**If `{auto_mode}` = false:**
Use AskUserQuestion:
```yaml
questions:
  - header: "Push"
    question: "Ready to push {branch_name} and create PR?"
    options:
      - label: "Push and create PR (Recommended)"
        description: "Push commits to remote and open pull request"
      - label: "Push only"
        description: "Push to remote without creating PR"
      - label: "Review commits first"
        description: "Show me the full diff before pushing"
      - label: "Cancel"
        description: "Don't push or create PR"
    multiSelect: false
```

### 4. Push to Remote

```bash
git push -u origin {branch_name}
```

**If push fails:**
β†’ Display error and ask user how to proceed
β†’ Common fixes: pull --rebase, force push (with warning)

### 5. Create Pull Request (if pr_mode)

**If `{pr_mode}` = true:**

Generate PR content:
- **Title:** `feat({task_id}): {task_description}`
- **Body:** Summary of changes from the workflow

```bash
gh pr create --title "feat({task_id}): {task_description}" --body "$(cat <<'EOF'
## Summary

{Brief description of what was implemented}

## Changes

{List of key changes made}

## Testing

{How the changes were validated}

---

_Generated by APEX workflow_
EOF
)"
```

**Capture PR URL:**
```bash
gh pr view --json url -q '.url'
```
β†’ Store as `{pr_url}`

### 6. Save Output (if save_mode)

**If `{save_mode}` = true:**

```bash
bash {skill_dir}/scripts/update-progress.sh "{task_id}" "09" "finish" "in_progress"
```

Append to `{output_dir}/09-finish.md`: branch, PR URL, commits, timestamp.

```bash
bash {skill_dir}/scripts/update-progress.sh "{task_id}" "09" "finish" "complete"
```

### 7. Final Summary

Display workflow completion summary:

```
═══════════════════════════════════════════════════════
  APEX WORKFLOW COMPLETE
═══════════════════════════════════════════════════════

  Task: {task_description}
  ID: {task_id}

  βœ“ Analysis complete
  βœ“ Plan created and approved
  βœ“ Implementation done
  βœ“ Validation passed
  {if test_mode: "βœ“ Tests passing"}
  {if examine_mode: "βœ“ Review findings resolved"}
  βœ“ Changes pushed to {branch_name}
  {if pr_mode: "βœ“ PR created: {pr_url}"}

═══════════════════════════════════════════════════════
```

---

## SUCCESS METRICS:

βœ… Agent team shut down gracefully via SendMessage shutdown_request (if teams_mode)
βœ… TeamDelete called to clean up team resources (if teams_mode)
βœ… All changes committed
βœ… Branch pushed to remote
βœ… PR created with proper title and description (if pr_mode)
βœ… PR URL captured and displayed
βœ… Output saved (if save_mode)
βœ… Clear completion summary provided

## FAILURE MODES:

❌ Creating PR with uncommitted changes
❌ Pushing without user confirmation (when not auto_mode)
❌ Force pushing without explicit user request
❌ Not displaying PR URL after creation
❌ **CRITICAL**: Using plain text prompts instead of AskUserQuestion

---

## WORKFLOW COMPLETE

This is the final step of the APEX workflow. No next step to load.

<critical>
Remember: This step handles git operations, PR creation, AND team shutdown (if teams_mode).
All code changes should have been completed in earlier steps.
Team shutdown MUST happen here β€” step 0 of execution sequence β€” before git operations.
</critical>
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why β€” repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" β€” or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself β€” your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall