# Picking the next ticket

`tkt next` names the next startable ticket; `--claim` also claims it in one atomic step and prints its bundle.

Exit 1: nothing startable (`tkt next --explain` says why).

- **Startable:** `todo`, not an `epic`, every `blockedBy` done, `has_blockers: false`, no `assignee` or the caller's own (`--assignee`, `AITODO_ASSIGNEE`).
- **Ranking:** step 0 of [the loop](/en/docs/guides/loop/steps.md#loop-steps); a priority set by hand overrides value. Inside the project focus ([The project focus](/en/docs/concepts/focus.md#plan-focus)), `--all` looks at everything.
- **Empty result:** `--json` adds `byStatus`, `promoteCandidates` (the top 3 backlog tickets, e.g. `tkt ticket update SG-107 --status todo`) and `stalledEpics`. Backlog → todo is the user's decision: propose it, never promote it yourself.

## Details

- Ranking: an earlier `targetDate` first; value decides within a priority; last an older `createdAt`, then the id. With a milestone scope (focus or `--milestone`) only that milestone counts, another active one never boosts.
- At claim time a ticket without a repo anchor is skipped (`repo_anchor_missing`) and the claim moves on to the next one.
- `--include-backlog` ranks backlog too and exits 0 with a candidate; with `--claim`: 2. `--claim` needs `--assignee` or `AITODO_ASSIGNEE` (else 2); a store-wide lock (`.aitodo/claim.lock`) keeps two claims off one ticket.
- A running ticket counts as already picked: `in_progress`, `in_review` (not merged yet) or a live claim in any worktree, this one too; never a candidate, its repo refs from the committed file. A candidate not `parallel` with one is left out (`running: true`); a running one without repo refs makes every candidate `unknown`. `--ignore-running` checks the candidates only against each other (REST `ignoreRunning=true`; there only the status counts).

- Value per point = (own or inherited value + 0.5 × the value of the open tickets waiting on it over `blockedBy`, transitively, each once) / estimate (min 0.5; none: the store's median, and `why` says so); no value: after the valued ones. Each candidate's `why` names its keys.
- A candidate without a value (none own, none inherited): `why` says `no value`, `--json` `valued: false`; if any, one line counts them, with the command: `tkt ticket update PAY-001 --value 5`. Same rule as the `unvalued` count of `tkt milestone get`.
- A promote candidate is no epic, has every `blockedBy` done and is never `deferred`.
- `tkt next --parallel N` suggests the best N that are safe to start together and claims nothing (N ≥ 2; with `--claim`: 2): the best ranked candidate, then each next one that the `tkt plan parallel` rules call `parallel` with every picked one (no `blockedBy` path, shared path or risky pattern: at most one touches migrations), until N. One without own repo refs is never picked, not even the top one (`unknown`, `no_repo_refs`). The text says why each one examined was left out. Exit 1: none picked. REST: `GET /v1/tickets:next?parallel=N`.

- `tkt next`: `--milestone`, `--group`, `--epic`, `--type`, `--assignee` narrow the scope, `--focus` sets your own focus.
- `--json`: `{ticket, candidates[], skipped[{id, reason, detail}], reasons}`; candidates carry `value`, `valueSource`, `effectiveValue`, `estimate`, `score`, `unlocks`, `promoteFirst`, `decidedBy`, `valued`. Skip reasons (`tkt meta`, `enums.skip_reason`): `claimed_elsewhere` (`<branch> @ <worktree>`), `not_todo`, `epic`, `assigned`, `open_blocker`, `has_blockers`, at claim time `repo_anchor_missing` (the claim moves on).
- `decidedBy` (`{key, over}`): the first key (`tkt meta`, `enums.rank_key`) in which the candidate beats the one below it (`over`); `null` for the last; `--explain`: `above PAY-002 by priority`.
- `byStatus` splits the `not_todo` skips by status (backlog 40, deferred 2); a promote candidate has `promoteCommand` and `promoteFirst: true`; `stalledEpics` are `todo`/`in_progress` epics with no `todo` child, with their best child.
- `--parallel N --json`: `parallel: {requested, picked[], leftOut[{id, rank, verdict, reasons, conflicts[{with, running, verdict, reasons}]}]}`, a `picked` candidate with its `rank`; `running[{id, title, status, claim}]`, `ignoreRunning`.

## Commands on this page

- [`tkt next`](/en/docs/reference/commands/workflow.md#tkt-next): The next startable ticket (todo, no blockers), ranked by active milestone (earlier targetDate first), priority, value per point (value + half of what it unlocks, per estimate), warnings and age

## Related

- Guide: [The loop, step by step](/en/docs/guides/loop/steps.md)
- Concept: [The project focus](/en/docs/concepts/focus.md): A milestone, an epic or a release the project works through now: tkt next stays inside it.
