# Jira Backlog Grooming Agent

> Groom your Jira backlog automatically. Find stale issues, close what is outdated, reprioritize what matters, and document every decision.

Source: https://cotera.co/solutions/ops/jira-backlog-grooming-agent

---

- **Team:** Operations
- **Tools:** Jira
- **Difficulty:** medium
- **Setup time:** 10 min
- **Time saved:** 2-3 hrs/sprint

## How it works
1. **Find Stale Issues** — Searches for backlog issues untouched for 90+ days with no sprint assignment or recent activity
2. **Analyze Relevance** — Reads full issue details to determine if each ticket should be closed, reprioritized, or refined
3. **Take Action** — Transitions stale issues to closed status and adds comments suggesting reprioritization where needed
4. **Report Health** — Generates a backlog health report with average age, unassigned counts, and grooming statistics

## Example requests
- Groom the ENG project backlog. Flag anything untouched for 90+ days.
- Close all stale issues in PLAT older than 6 months, but protect anything labeled roadmap.
- Review the MOBILE backlog and suggest which issues to close, reprioritize, or keep.

## Prompt

```markdown
## Task

Use @Jira/Search Issues to find stale backlog issues that need attention. Use @Jira/Get Issue to read full details and determine whether each issue should be closed, reprioritized, or kept. Use @Jira/Transition Issue to move stale issues to the appropriate status and @Jira/Add Comment to explain the reasoning behind each decision.

## Input

The user provides:
1. Their Jira project key (e.g., "ENG", "PLAT")
2. Staleness threshold (optional, defaults to 90 days) - how old an untouched issue should be before flagging
3. Action preferences (optional) - e.g., "close anything older than 6 months with no activity", "reprioritize rather than close"
4. Protected labels (optional) - e.g., "never close issues labeled 'roadmap' or 'tech-debt'"

**Example:** "Groom the ENG project backlog. Flag anything untouched for 90+ days."

## Context

### Stale Issue Discovery

1. Use @Jira/Search Issues with JQL to find old backlog issues:
   - `project = [PROJECT] AND status = "To Do" AND updated <= -90d ORDER BY updated ASC`
   - `project = [PROJECT] AND status = "Backlog" AND updated <= -90d ORDER BY updated ASC`
   - `project = [PROJECT] AND status = "Open" AND created <= -180d AND updated <= -90d ORDER BY created ASC`
2. Identify issues with no recent comments, no sprint assignment, and no linked PRs

### Issue Analysis

1. Use @Jira/Get Issue to read each stale issue's full description, labels, and linked issues
2. Categorize each issue into one of these buckets:
   - **Close:** No longer relevant, superseded by another issue, duplicate, or too vague to act on
   - **Reprioritize:** Still valid but priority has shifted, needs to be bumped up or down
   - **Keep:** Still relevant and correctly prioritized, just hasn't been picked up yet
   - **Needs Refinement:** Valid idea but description is too vague to be actionable
3. Consider protected labels - never recommend closing issues with user-specified protected labels

### Grooming Execution

1. For issues recommended to close:
   - Use @Jira/Transition Issue to move to "Done" or "Won't Do" status
   - Use @Jira/Add Comment explaining why the issue is being closed (e.g., "Closing as stale - no activity in 120 days and the feature area has been redesigned")
2. For issues that need reprioritization:
   - Use @Jira/Add Comment with the suggested new priority and reasoning
3. For issues needing refinement:
   - Use @Jira/Add Comment asking for clarification or suggesting a more specific scope

### Health Metrics

- Total backlog issues scanned
- Issues older than threshold
- Issues with no assignee and no sprint
- Average age of backlog issues
- Issues closed vs kept vs needs-review

## Output

**Backlog Grooming Report:**

**Project:** [Project Key]
**Issues Scanned:** [total count]
**Staleness Threshold:** [X] days

**Recommendations:**
- Close: [count] issues
- Reprioritize: [count] issues
- Needs Refinement: [count] issues
- Keep As-Is: [count] issues

**Actions Taken:**
| Issue | Title | Age | Action | Reasoning |
|-------|-------|-----|--------|-----------|
| [PROJ-123] | [title] | [X] days | Closed | [brief reasoning] |
| [PROJ-456] | [title] | [X] days | Comment added | [suggested change] |

**Backlog Health:**
- Average issue age: [X] days
- Issues with no assignee: [count]
- Issues never assigned to a sprint: [count]

**Summary:** [1-2 sentence overview of backlog health and actions taken]
```

## Related reading
- [Our Jira Backlog Had 847 Tickets. An AI Agent Cut It to 312.](https://cotera.co/articles/jira-ai-tools-guide.md)

