---
name: youtrack-ticket-planning
description: >-
  Refines and plans work from a YouTrack ticket using the YouTrack MCP, then
  produces a structured plan with context, requirements, risks, and questions.
  Use when the user mentions YouTrack tickets or issues, issue keys like
  PROJ-123, or asks to plan or refine a YouTrack ticket.
---

# YouTrack Ticket Planning

## Quick Start

When asked to plan a YouTrack ticket:

1. Fetch the issue via the YouTrack MCP (`get_issue`).
2. Extract summary, description, custom fields (esp. acceptance criteria), and links.
3. Identify uncertainties or inconsistencies; ask concise questions.
4. Produce a structured plan using the template below.

## Workflow

### 0) Resolve the issue ID

- If the user provides an explicit issue ID (e.g. `PROJ-123`), use that directly.
- If the user says "current ticket", "what I'm working on", "zebra", or similar without providing an explicit ID:
  1. Run `zebra status` in the shell.
  2. The output looks like: `Project <name> [<activity>] started <duration> (<timestamp>) - <ISSUE-ID>: <description>.`
  3. Extract the issue ID from after the ` - ` separator (e.g. `PHGO-145` from `... - PHGO-145: Implement feature.`). Use a pattern like: match the text after ` - ` up to the first `:` to get the issue ID.
  4. If `zebra status` returns no active timer or the output cannot be parsed, inform the user and ask them for the issue ID manually.
- Once you have the issue ID, confirm it with the user before proceeding.

### 1) Gather ticket details

- Use YouTrack MCP to fetch the ticket by the resolved issue key.
- If key details are missing, optionally check comments or linked issues (e.g. `get_issue_comments` or other YouTrack MCP tools as appropriate).

### 2) Refine requirements

- Translate the description into concrete requirements and constraints.
- Call out implied behavior, dependencies, or edge cases.

### 3) Plan the work

- Outline a step-by-step implementation plan.
- Include validation or testing steps when relevant.

### 4) Ask questions

- If anything is ambiguous, inconsistent, or depends on business rules, ask.
- Keep questions short and actionable.

## Output Template

Use this exact structure:

```markdown
## Context
[1–3 sentences from ticket summary/description]

## Requirements
- [Concrete requirement]
- [Acceptance criteria as bullets if present]

## Plan
- [Step 1]
- [Step 2]
- [Step 3]

## Risks / Assumptions
- [Risk or assumption]

## Questions
- [Question]
```

## Notes

- Prefer facts from the ticket; avoid inventing details.
- If the ticket includes an explicit acceptance-criteria checklist, preserve it verbatim.
- If no uncertainties exist, explicitly say "No open questions."
- **`zebra`** is a time-tracking CLI; it must be available in the environment for the "current ticket" resolution path.

## Examples

**Input request:** "Please create a plan for the YouTrack ticket PROJ-123."

**Expected behavior:** Use the template above, plus any questions needed to clarify requirements.

**Input request:** "Plan the ticket I'm working on." / "Plan what I'm currently working on (zebra)."

**Expected behavior:** Run `zebra status`, extract the issue ID, confirm with the user, then proceed as normal.
