Orchestrate

Orchestrate Jira tasks through implementation, review, and PR creation

SamuelReeder updated 1mo ago
Claude CodeGeneric
View source ↗
---
description: Orchestrate Jira tasks through implementation, review, and PR creation
argument-hint: <JIRA-KEY> [JIRA-KEY ...] [additional instructions]
allowed-tools: [Bash, Read, Glob, Grep, Write, Edit, Task, ToolSearch, AskUserQuestion, TaskCreate, TaskUpdate, TaskList, TaskGet]
---

# Jira-to-PR Orchestration

Automate the full lifecycle: Jira intake → beads task → worktree → plan → implement → review → draft PR → Jira transition.

**You are the orchestrator AND the planner.** You coordinate subagents for execution tasks (worktree creation, implementation, review, finalization) but do the planning yourself using your own tools.

**Arguments:** $ARGUMENTS

Process each Jira key sequentially. Each task fully resolves before the next starts.

---

## Phase 1 — Jira Intake

For each Jira key in `$ARGUMENTS`:

1. Call `jira_get_issue` with the Jira key to fetch:
   - Summary, description, components, labels
   - Project key, priority
   - Acceptance criteria (check description and custom fields)
2. Store the extracted data for use in subsequent phases.

If the Jira key is invalid or inaccessible, report the error and skip to the next key.

---

## Phase 2 — Project Mapping

Read the mapping config:

Read: .claude/skills/orchestrate/jira-mapping.json


Read the project registry:

Read: .claude/registry/projects.json


Match the Jira task to a ROCm project using this priority:
1. **Jira components** → match against `projects.json` `components` and `subprojects` lists
2. **Jira labels** → match against project keys and `aliases` in `projects.json`
3. **Jira project key** → look up in `jira-mapping.json` `project_key_map`
4. **Ambiguous** → use `AskUserQuestion` to let the user pick the target project

Also determine the base branch from `jira-mapping.json` `base_branches`.

---

## Phase 3 — Beads Task Creation

Create a beads task:

```bash
source "$HOME/.cargo/env"
br create "<Jira summary>" --label <project-key> --label orchestrated
br update <id> --external-ref "<JIRA-KEY>"

Set acceptance criteria and design notes:

br comments add <id> "Acceptance criteria: <criteria from Jira>"
br comments add <id> "Jira description: <description summary>"

Store the beads task ID for subsequent phases.


Phase 4 — Worktree Creation (Subagent)

  1. Fetch latest from the base branch:

    git -C <main-repo-path> fetch origin <base-branch>
    
  2. Derive branch name:

    • Format: users/sareeder/<jira-key-lowercase>/<short-feature-summary>
    • Feature summary: derived from Jira title, kebab-cased, max ~40 chars
    • Example: users/sareeder/almiopen-123/add-convolution-descriptor-cache
  3. Create branch from the latest base:

    git -C <main-repo-path> branch <branch-name> origin/<base-branch>
    
  4. Spawn worktree subagent using a general-purpose haiku agent with worktree-setup instructions:

    1. Read .claude/agents/worktree-setup.md
    2. Extract the body (everything after the YAML frontmatter closing ---)
    3. Append task details: "Create a <project> worktree for branch <branch-name> at path /home/AMD/sareeder/worktrees/<prefix>-<jira-key-lowercase>"
    4. Task(subagent_type="general-purpose", prompt=<agent body + task details>, model="haiku", mode="bypassPermissions")
    

    The worktree path uses ~/worktrees/ to keep orchestrated worktrees separate.

  5. Update projects.json with the new worktree entry.

  6. Update beads task:

    source "$HOME/.cargo/env"
    br comments add <id> "Worktree: <path>, Branch: <branch>"
    br update <id> --status in_progress
    

Phase 5 — Planning (Orchestrator — You)

You do the planning yourself. Do NOT spawn a Plan subagent. Use your own Glob, Grep, and Read tools to explore the codebase and create the plan.

Read the planning instructions:

Read: .claude/skills/orchestrate/plan-template.md

Follow those instructions directly, substituting the context values:

  • {{worktree_path}} — full worktree path
  • {{branch}} — branch name
  • {{project_name}} — project name
  • {{jira_key}} — Jira key
  • {{jira_description}} — Jira description text
  • {{acceptance_criteria}} — acceptance criteria
  • {{beads_id}} — beads task ID

Your planning work:

  1. Read the project CLAUDE.md at <worktree_path>/CLAUDE.md
  2. Explore code areas relevant to the task using Glob, Grep, Read
  3. Identify files to modify, patterns to follow, and risks
  4. Produce the structured plan output format from the template

After creating the plan:

  1. Record the plan in beads:

    source "$HOME/.cargo/env" && br comments add <id> "PLAN: <one-line plan summary>"
    
  2. Present the plan to the user via AskUserQuestion:

    • Show the full plan text
    • Options:
      • Approve — "Approve this plan and proceed to implementation"
      • Revise — "I have feedback on this plan" (user provides feedback)
      • Abort — "Cancel this task"
  3. Handle the response:

    • Approve → store the plan text for Phase 6 and continue
    • Revise → revise the plan yourself based on user feedback. Do additional exploration if needed. Then re-present via AskUserQuestion. (Loop until approved or aborted.)
    • Abort → update beads:
      source "$HOME/.cargo/env"
      br comments add <id> "ABORTED: User cancelled during planning"
      br update <id> --status open
      
      Skip remaining phases for this task.

Phase 6 — Implementation (Subagent)

Read the implementation template:

Read: .claude/skills/orchestrate/impl-template.md

Replace all {{placeholders}} with actual values:

  • {{worktree_path}} — full worktree path
  • {{branch}} — branch name
  • {{project_name}} — project name
  • {{jira_key}} — Jira key
  • {{jira_description}} — Jira description text
  • {{acceptance_criteria}} — acceptance criteria
  • {{beads_id}} — beads task ID
  • {{implementation_plan}} — the approved plan text from Phase 5

Maintain Orchestrate?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Orchestrate on getagentictools](https://getagentictools.com/loops/samuelreeder-jira-to-pr-orchestration?ref=badge)
npx agentictools info loops/samuelreeder-jira-to-pr-orchestration

The second line is the CLI lookup for this page — handy in READMEs and docs.