---
name: multi-agent-estimate
description: "Estimate new work from similar closed Jira work: a P25-P75 range per role from logged time, with the tickets behind it and the modules touched. Read-only; never a single number, none below three samples. Use when a story, analysis or request needs an effort range."
user-invocable: true
argument-hint: "<analysis.md | \"free text\"> [--project KEY]"
metadata:
  language: en
  not-for: analysis, analysis-jira
---

# multi-agent-estimate

**Input**: $ARGUMENTS

Turns history into a range. The query and the reading of the work are yours;
the arithmetic and the minimum-sample rule are the script's. Nothing is written
to Jira or anywhere else.

Script: `$HOME/.claude/scripts/estimate.mjs`.

## Gotchas

- The query must say `statusCategory = Done`; the script refuses anything else, because open work has no final time.
- Logged time is only as good as the team's logging. A role with sub-tasks but no `timespent` has no samples; say that rather than reading it as zero effort.
- Similar means similar work, not similar words: narrow by component or label first, then by text. A query that returns fifty unrelated issues gives a confident-looking range about nothing.
- Fewer than three samples gives no number for that row. Do not fill it in from judgement.

## Step 1 - What is being estimated

From an analysis document, read its feature name, the components or channels it
names and its story count; from free text, its nouns. Map the modules it
touches with the repo map when a repository is at hand:

```bash
node "$HOME/.claude/scripts/repo-map.mjs" --root "<repo>" --budget 800
```

## Step 2 - The query

Build one JQL from the project (`--project`, else `prefs.global.issueTree.projectKey`),
`statusCategory = Done`, the components or labels found above, and at most two
`text ~` terms. Show it and let the user edit it with one `AskUserQuestion`
(**Run it** / **Edit the query** / **Cancel**).

## Step 3 - Run

```bash
node "$HOME/.claude/scripts/estimate.mjs" --jql "<jql>" \
  --roles "$(jq -r '.global.issueTree.subtaskRoles // [] | join(",")' "$HOME/.claude/multi-agent-preferences.json")"
```

With no roles configured the report has the total and story-point rows only.

## Step 4 - Report

Print the table verbatim, then the modules from Step 1. Say which rows had too
little history, how many issues were sampled, and that the range describes the
past work the query found: the choice of query is judgement, the numbers are
arithmetic over it.

**Stop. No ticket is created or edited.**
