Complete Work
Close out a finished unit of work: archive the OpenSpec change, commit with trailers, transition the Jira issue to Done, push, and verify CI.
When to use
- All tasks in an active OpenSpec change are implemented and tested.
- The user says "complete work", "wrap up", "finish this one", or names a change to close out.
- Work needs to land on
main/masterwith a clean audit trail.
Steps
- Find the active OpenSpec change in
openspec/changes/. If multiple exist, ask the user which change to complete. - Read the proposal (
openspec/changes/<id>/proposal.md) to extract the issue key (look for a Jira key pattern likePROJ-123in the metadata or body) and the title. - If an issue key was found: Fetch the issue details using
af jira get <issue-key>to verify it exists and get the summary. If no issue key was found: Skip all Jira operations (steps 3, 6) and omit theIssue=trailer in step 5. - Archive the OpenSpec change (if not already archived):
- Check if
openspec/changes/<id>/directory exists - If it exists, invoke the
openspec-archive-changeskill (Skill tool) with the<change-id> - If the directory does not exist (already archived), skip this step
- Check if
- Commit with trailers:
Wheregit add -A git commit -m "<summary>" \ [--trailer "Issue=<issue-key>"] \ --trailer "OpenSpec-Id=<change-id>"<summary>is derived from the Jira issue (if available) or from the OpenSpec proposal title. Only include the--trailer "Issue=<issue-key>"flag when an issue key is present. - If an issue key was found: Transition the issue to "Done", always supplying a resolution so the issue does not close with an empty Resolution field:
Status and resolution names are workflow-specific. If this fails, runaf jira transition <issue-key> --to "Done" --resolution "Fixed" --comment "<change-id> archived and pushed"af jira transitions <issue-key>— it lists the available transitions and the fields each one's screen requires — then retry with the correct--to/--resolutionnames (add--field name=valuefor any other required screen field). If no issue key: Skip this step. - Push to remote:
git push
CI Verification
Read the Jenkins job path from the project's CLAUDE.md (e.g.,
Jenkins job: folder/pipeline-name). If not configured, skip this phase. Job paths use/to separate folder/pipeline/branch segments, so the path to poll is the branch build the push just triggered:<job-path>/<branch>— not the bare<job-path>, which is the multibranch parent. (af jenkins branches <job-path>lists the per-branch build statuses.)Wait ~30 seconds for Jenkins to pick up the push, then poll build status:
af jenkins build <job-path>/<branch> --jsonRepeat every 30 seconds until the build is no longer in progress (check the
buildingfield orresultfield in JSON output).If build succeeds: Done.
If build fails:
- Run
af jenkins stages <job-path>/<branch>to identify the failing stage - Run
af jenkins stage-log <job-path>/<branch> "<failing-stage>"to read the error output (arg order is<name> <stage> [number|latest]) - Fix the code based on the failure
- Commit the fix using the same
git add -A && git commit -m "<summary>" --trailer ...pattern from step 5, push, and poll again
Escape valve: If the build still fails after 3 CI attempts, STOP and report the failing stage, error output, and what fixes were attempted.
- Run
Reference
- Run
openspec --helpfor OpenSpec CLI options - See the
jiraskill, or run bareaf jira(notaf jira --help, which is only a stub) for the full CLI reference - See the
jenkinsskill for job paths, polling, and stage logs; run bareaf jenkinsfor the full CLI reference