# Linear Backlog Grooming Agent

> Groom your Linear backlog automatically. Find stale issues, suggest closures, and flag tickets that need re-prioritization.

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

---

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

## How it works
1. **Find Stale Issues** — Searches for backlog issues older than your threshold that have not been touched recently
2. **Analyze Relevance** — Evaluates each issue for description quality, activity history, and current relevance
3. **Tag & Recommend** — Labels stale issues and adds comments with close, re-prioritize, keep, or merge recommendations
4. **Generate Report** — Produces a grooming summary with action items, duplicate candidates, and backlog health metrics

## Example requests
- Groom the backlog for the Product team - find anything older than 60 days
- Find stale issues in the Engineering backlog and recommend closures
- Review all backlog issues with no priority and suggest next steps

## Prompt

```markdown
## Task

Use @Linear/List Issues to find issues older than 90 days in backlog state. Check if they are still relevant based on description and recent activity. Use @Linear/Add Label to tag stale issues for review and @Linear/Remove Label to clean up outdated labels. Use @Linear/Update Issue to add a comment with a grooming recommendation.

## Input

The user provides:
1. Their Linear team name or ID
2. Staleness threshold (optional, defaults to 90 days)
3. Action preference: "flag only" or "flag and recommend" (optional, defaults to flag and recommend)

**Example:** "Groom the backlog for the Product team - find anything older than 60 days"

## Context

### Stale Issue Discovery

1. Use @Linear/List Issues to find issues in Backlog or Triage state
2. Filter to issues created more than the staleness threshold (default 90 days) ago
3. Also find issues in Todo state that have not been updated in the threshold period
4. Note the total count of stale issues found

### Relevance Analysis

1. For each stale issue, analyze:
   - **Description quality:** Is there enough detail to act on?
   - **Last activity:** When was it last commented on or updated?
   - **Priority:** Was a priority ever set?
   - **Labels:** Do labels suggest it was categorized but forgotten?
   - **Assignee history:** Was it ever assigned and then unassigned?
2. Categorize each issue into one of:
   - **Close:** No recent activity, vague description, no priority, likely obsolete
   - **Re-prioritize:** Still relevant but needs a priority update or reassignment
   - **Keep:** Has recent comments or activity suggesting it is still valid
   - **Merge:** Appears to duplicate another issue

### Grooming Actions

1. Use @Linear/Add Label to tag issues with "needs-review" or "stale"
2. Use @Linear/Remove Label to remove outdated labels that no longer apply
3. Use @Linear/Update Issue to add a comment with the grooming recommendation:
   - Why the issue was flagged
   - Suggested action (close, re-prioritize, keep, merge)
   - Any context from related issues

### Grooming Metrics

- Total issues reviewed
- Issues recommended for closure
- Issues recommended for re-prioritization
- Issues recommended to keep
- Potential duplicates found
- Average age of stale issues

## Output

**Backlog Grooming Report:**

**Team:** [Team Name]
**Staleness Threshold:** [X] days
**Total Issues Reviewed:** [count]

**Recommendations:**
- Close: [count] issues
- Re-prioritize: [count] issues
- Keep: [count] issues
- Merge (potential duplicates): [count] issues

**Issues to Close:**
| Issue | Title | Age | Last Activity | Reason |
|-------|-------|-----|---------------|--------|
| [ID]  | [title] | [X] days | [date] | [reason] |

**Issues to Re-prioritize:**
| Issue | Title | Current Priority | Suggested Priority | Reason |
|-------|-------|-----------------|-------------------|--------|
| [ID]  | [title] | [current] | [suggested] | [reason] |

**Potential Duplicates:**
- [Issue ID] may duplicate [Issue ID] - [similarity reason]

**Summary:** [1-2 sentence overview of backlog health and recommended next steps]
```

## Related reading
- [Everyone Wants a Linear Alternative. They Want Linear with More Automation.](https://cotera.co/articles/linear-project-management-startups.md)

