Fetch a Jira ticket, research the codebase, plan the implementation, and execute it. Use when the user provides a Jira ticket URL, key (STUDIO-15807), or bare number (15807).
End-to-end workflow: fetch a Jira ticket → research the codebase → plan → implement.
Intermediate files are saved to .jira/{JIRA_KEY}/ (e.g. .jira/STUDIO-15807/).
The user provides the ticket as $ARGUMENTS. Parse it into a Jira issue key:
| User input | Parsed key |
|---|---|
https://<jira-host>/browse/STUDIO-15807 | STUDIO-15807 |
STUDIO-15807 | STUDIO-15807 |
15807 | STUDIO-15807 |
Rules:
/browse/[A-Z]+-\d+, use it directlySTUDIO-Store the parsed key as JIRA_KEY (e.g. STUDIO-15807).
Look for the file .jira/.credentials in the project root.
If it exists, read it. It contains:
JIRA_URL=https://jira.example.com
[email protected]
JIRA_TOKEN=the-api-token
JIRA_AUTH=Bearer
If it does not exist, or if JIRA_URL is missing from the file:
https://jira.example.com), username, and API token using AskUserQuestion.jira/ directory and write .jira/.credentials with the provided values.jira/ is in .gitignore (add it if missing)Load the URL, username, and token into variables for subsequent API calls. Store the base URL as JIRA_URL (no trailing slash).
Call the Jira REST API to get the ticket details. The authentication method depends on JIRA_AUTH:
JIRA_AUTH=Bearer: use -H "Authorization: Bearer $JIRA_TOKEN"JIRA_AUTH=Basic or not set: use -u "$JIRA_USERNAME:$JIRA_TOKEN"curl -s -H "Authorization: Bearer $JIRA_TOKEN" \
"$JIRA_URL/rest/api/2/issue/$JIRA_KEY" \
| python -m json.tool
If this returns a 401, tell the user their credentials are invalid and ask them to update .jira/.credentials.
If this returns a 404, tell the user the ticket was not found.
From the JSON response, extract:
fields.summary — ticket titlefields.description — full descriptionfields.issuetype.name — Bug, Story, Task, etc.fields.status.name — current statusfields.priority.name — priority levelfields.assignee.displayName — who it's assigned tofields.labels — labelsfields.components — componentsfields.comment.comments[] — discussion comments (author + body)fields.subtasks[] — subtask keys and summariesfields.issuelinks[] — linked issuesCreate the directory .jira/$JIRA_KEY/ if it doesn't exist.
Write .jira/$JIRA_KEY/ticket.md with the extracted ticket information, formatted as:
# {JIRA_KEY}: {summary}
- **Type**: {issuetype}
- **Status**: {status}
- **Priority**: {priority}
- **Assignee**: {assignee}
- **Labels**: {labels}
- **Components**: {components}
- **URL**: {JIRA_URL}/browse/{JIRA_KEY}
## Description
{description}
## Comments
### {comment_author} — {comment_date}
{comment_body}
## Subtasks
- {subtask_key}: {subtask_summary}
## Linked Issues
- {link_type}: {linked_issue_key} — {linked_issue_summary}
Omit empty sections.
Based on the ticket description and requirements, explore the codebase to understand:
For Bug tickets: Additionally investigate and document:
Use the Explore agent or Glob/Grep tools to search the codebase thoroughly.
Save findings to .jira/$JIRA_KEY/research.md with the structure:
# Research: {JIRA_KEY}
## Relevant Files
- `path/to/file.cpp` — description of what it does and why it's relevant
## Existing Patterns
- Description of relevant patterns found in the codebase
## Architecture Notes
- How the affected components are structured and connected
## Root Cause Analysis (for bugs)
### Error Code Path
1. `entry_function()` in `path/to/file.cpp:123`
2. → calls `intermediate_function()` in `path/to/other.cpp:456`
3. → bug occurs at `faulty_function()` in `path/to/bug.cpp:789` because {reason}
### Root Cause
{Detailed explanation of why the bug occurs}
### Reproduction Logic
{How the inputs/state trigger the bug through the code path above}
## Test Coverage
- Existing tests that cover the affected area
Omit the "Root Cause Analysis" section for non-bug tickets.
Based on the ticket details and research, create an implementation plan.
Save the plan to .jira/$JIRA_KEY/plan.md with the structure:
# Plan: {JIRA_KEY} — {summary}
## Approach
{High-level description of the implementation approach}
## Changes
### 1. {file_path}
- What to change and why
### 2. {file_path}
- What to change and why
## Testing
- How to verify the changes work correctly
## Risks
- Any risks or edge cases to watch out for
Present the plan to the user and wait for approval before proceeding. Use AskUserQuestion or simply present the plan and ask if they want to proceed. Do NOT implement without explicit approval.
Once the user approves the plan, execute it:
After the user accepts the implementation (explicitly or implicitly), create a commit and push it to Gerrit for code review.
Follow the project's existing commit message convention. The message has two lines separated by a blank line:
{TYPE}: {description}
JIRA: {JIRA_KEY}
Where {TYPE} is derived from the ticket type:
FIXENHENH (or FIX if the task is a fix)REFACTORThe JIRA: {JIRA_KEY} line MUST be on its own line after the description, separated by a blank line.
Examples:
FIX: show error dialog when gcode.3mf export fails due to locked file
JIRA: STUDIO-17233
Co-Authored-By: Claude Opus 4 <[email protected]>
ENH: add multi-nozzle support for X2D
JIRA: STUDIO-15807
Co-Authored-By: Claude Opus 4 <[email protected]>
Always include the Co-Authored-By: Claude Opus 4 <[email protected]> line after JIRA: {JIRA_KEY}.
git add -A or git add .)Change-Id trailer.git log -1Push the commit to Gerrit for review:
git push origin HEAD:refs/for/master
If the current branch is not master, push to the appropriate target branch:
git push origin HEAD:refs/for/{target_branch}
After pushing, report the Gerrit review URL to the user (it is printed in the push output).
| Error | Action |
|---|---|
no new changes | The change already exists in Gerrit — inform the user |
permission denied | Ask user to check SSH keys / Gerrit access |
hook errors | The commit-msg hook may have failed — check if Change-Id was added |
| Error | Likely Cause | Action |
|---|---|---|
| 401 Unauthorized | Wrong email/token | Ask user to check .jira/.credentials |
| 404 Not Found | Wrong ticket key | Verify the key, check if project prefix is correct |
| Connection error | VPN/network issue | Ask user to check network access to the Jira host configured in .jira/.credentials |
Empty $ARGUMENTS | User didn't provide a ticket | Ask user to provide a ticket number |
$ARGUMENTS is empty, ask the user which ticket to work on