$npx -y skills add promptctl/links-issue-tracker --skill next --agent claude-code
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Next?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/promptctl-next)
---
name: next
description: Pull the next ticket
---
# Next
Pick up the next ready ticket and start work.
## Init
Run `lit quickstart` if you haven't already. This provides instructions for using the work tracking system.
If the user provided specific information (e.g., a ticket id or area of the codebase to work on), SKIP THE REST OF THESE INSTRUCTIONS except the next section, "Work from the checkout that holds the work", which holds for every ticket, and follow the guidance from `lit quickstart` to follow the user instructions. The rest of this skill is for determining which work to pick when the user did not specify.
## Work from the checkout that holds the work
lit counts a checkout — the primary clone or one linked worktree — as the claimant, not the session working in it. A checkout carries one epic at a time, and every ticket `lit next` serves it is worked there: `lit next`, `lit start`, the branch, the commits and `lit done` all run from inside it. Sessions are shifts at one desk: they come and go, and the work stays where it is.
- **A handoff that names a checkout** is where you run this skill. Go there first.
- **`lit next` says where its pick is started.** For a pick that belongs in a worktree of its own — new work served in the primary clone, or work from outside unfinished work this checkout holds — its start advice says `from a worktree of its own off the trunk (not …)` before `lit start <id>`. Create the worktree and run `lit start <id>` from inside it, because the claim lands on the checkout `lit start` runs in:
```
git fetch origin
git worktree add --detach <path> origin/master # or the repo's default branch
```
The worktree starts on no branch: step 3 below finds the ticket's branch or cuts it there. Start advice that names no worktree is started where you are.
- **A ticket held by a checkout on this machine** names it on its claim line in `lit backlog`: `claimed here: <path> (<branch>)`. That is where the ticket is worked.
- **A merged ticket does not end the checkout's work.** Keep the worktree and run `lit next` from inside it; the ticket it serves is cut on a fresh branch there (step 3 below).
The moment this goes wrong comes after a merge: the next ticket is in the same lane, and a fresh worktree off the trunk feels like the clean place to start it. It is a second checkout for the same lane. lit sees a new claimant take the lane, and `lit next` run from anywhere but the checkout that holds the lane routes away from the lane's next ticket.
- WRONG: an epic's four tickets worked in four worktrees, one per ticket — four claimants for one lane.
- RIGHT: all four worked in the one worktree that holds the epic, one branch per ticket.
## Finding work
Which command answers which question is the quickstart's job — run `lit quickstart work` for that reference. This skill covers only the procedure: wrapping up work already in flight before pulling anything new, what `lit next`'s pick means, and how to work a ticket once you hold one.
Two branches, in order. First settle whatever is already in flight here — a branch whose PR merged, uncommitted changes, then your open PRs. Only once nothing is in flight do you pull new work.
### Wrap up work already in flight
#### A branch whose PR merged
Before anything else, clean tree or not, ask whether the branch you stand on has a PR that merged and none still open:
```
b="$(git branch --show-current)"; test -z "$b" || test "$b" = master || gh pr list --head "$b" --state all --limit 1000 --json number,state,headRefOid,mergedAt,isCrossRepository \
--jq 'map(select(.isCrossRepository | not)) | if any(.[]; .state == "OPEN") then empty else ([.[] | select(.state == "MERGED")] | max_by(.mergedAt) // empty | "\(.number) \(.headRefOid)") end'
```
A non-zero exit is no answer, not a "no" — fix `gh` before you trust the empty output. Empty output — including a detached HEAD, which has no branch to have merged — means carry on to "Uncommitted changes".
The check skips the trunk (`master` here; put the repo's default branch in its place) and fork PRs, whose branch names say nothing about yours. Anywhere else, a line printed means the branch leads nowhere and its ticket has landed. One ticket lands as one PR, so anything here past that PR — uncommitted changes, and commits the PR does not hold — belongs to a follow-up ticket. Fetch first, then list those commits:
```
git fetch origin && git fetch origin pull/<number>/head
git log --oneline HEAD ^<headRefOid> ^origin/master # or the repo's default branch
```
Nothing listed and a clean tree: nothing is in flight here — detach onto the trunk as "Finishing a ticket" does, and go on to "Open PRs". A branch rewritten since the merge lists copies of merged commits too; read each and keep only new work.
Otherwise sort the uncommitted changes by the rules in "Uncommitted changes" below — discard the junk, stash what is plainly unrelated — and commit what is left onto this branch, so the work is one list of commits and nothing of it rides the shared stash. File the follow-up in the merged ticket's epic and lane, `lit start` it, and cut its branch from the trunk as step 3 of "Working the ticket" describes, under "Otherwise, branch from an up-to-date trunk". Cherry-pick the listed commits, plus the one you just made, onto it in order. Leave the merged branch where it is, and continue at step 4 of "Working the ticket".
#### Uncommitted changes
Determine if these changes are related to a backlog item. If so, that is your current ticket. If not, stop and think to your self: Are these changes worthwhile? Accidential? Incidental? Should we commit or discard them? Use your brain to think about the right solution because there is no one size fits all rule.
Examples:
- uncommitted pnpm lockfile update: check it out to discard, but then regengerate the lockfile as part of your commit when you do work
- Uncommitted typo in a random file: check it out to discard, it's not needed
- Minor update to the readme to include some more instructions: commit it and proceed
- Major update to the readme that is related to the work on the current branch: commit it and proceed
- Major update to work that is clearly NOT on this branch: stash it and proceed
- A half finished feature: find the ticket it's related to. THIS TICKET IS YOUR ASSIGNED WORK. Skip the selection steps and go straight to "Working the ticket". If it's not related to a ticket you see, do a quick code review. does the code look experimental and temporary or high quality? Does it look complete or barely started? Then briefly explain the state of the code, what it does, and any other info you have (no ticket, etc). Ask if they want you to create a ticket and continue the work, if they want it to committed to work as part of a different ticket, or whether they want you to stash or discard it. Follow that instruction.
Before proceeding, confirm the uncommitted changes are now resolved (committed, stashed, or discarded per the above). If anything you did previously resulted in a reference to a specific ticket, THAT IS YOUR TICKET ID and you should skip the selection steps and go straight to "Working the ticket".
Do NOT proceed without either:
- no uncommitted changes
OR
- A ticket id to work on
#### Open PRs
lit tracks tickets, not GitHub PRs, so no lit command will surface one. Two checks, in this order.
**This branch.**
```
gh pr list --head "$(git branch --show-current)" --state open --limit 1000
```
A PR here is your ticket, and its id is the one in the branch name; a branch whose name carries none is not lit-tracked, and its PR is left where it is, as "Your PRs elsewhere" leaves one. Skip the selection steps and take the ticket through "Finishing a ticket" below. "Working the ticket" does not apply: its checks and branch setup are for a ticket whose code is not yet written.
**Your PRs elsewhere.**
```
gh pr list --author @me --state open --limit 1000
```
A fresh session sitting on the trunk has no head branch to match, so the branch check alone reports nothing and the wrap-up rule never fires — you start new work on top of your own unfinished PR and find out at merge time.
These are candidates, not assignments, and there may be several — every checkout on this machine shares the one `gh` account, so each of them can have left a PR behind here. Classify the whole list before you act on any of it; an agent that starts merging partway down a list rarely comes back for the tail, and the one it walks past is the one the next session picks up instead of its own work.
For each PR the query returned, take the ticket id from its branch name and check who holds that lane: `lit backlog` prints a claim line under any lane somebody holds right now, and nothing under a lane nobody holds. A lane another checkout holds is theirs — leave it, say so, and move on.
A branch whose name carries no ticket id at all — someone's typo fix, a hand-cut experiment — is not lit-tracked work, so there is no lane to look up and nothing here for you to adopt. Leave it where it is.
Every lane nobody holds is yours to wrap up — an expired claim is no claim, so a lane whose holder went quiet six hours ago prints no claim line and is one of these — and so is a lane whose claim line is `claimed here: <path>` with this checkout's own path. Wrapping one up means taking its ticket through "Finishing a ticket" below. Work them one at a time, down the list you already classified, and do not pull new work until the last one is closed out.
**If nothing is in flight,** proceed to "Pull new work" below. Open PRs stay relevant after that — an older one may touch the files your new ticket touches — which is why the overlap check is a step in "Working the ticket".
### Pull new work
Run `lit next` first, always. It is the routing decision itself, not a suggestion box, and it is the only thing that knows what this checkout holds — a claim in lit belongs to a checkout, and no listing tells you which checkout you are. It serves your own live claims ahead of everything else: lanes you hold right now, work you left in progress there, and other lanes of the epic you are already in that nobody else holds. Only once you hold nothing, or your epic has nothing workable left, does it reach the global pool — and a claim expires after six hours of silence in its lane, so a checkout that has been away longer than that holds nothing and is routed by rank like any other. Whatever it hands you is your ticket — `lit start` it from the checkout it belongs in ("Work from the checkout that holds the work" above), then go to "Working the ticket".
#### Orphaned tickets
`lit orphaned` lists in_progress tickets that have gone quiet: work somebody started and walked away from. It is a repo-wide diagnostic view, not a queue you pull from, and you do not need it to find your *own* work in flight: while your claim on its lane is live, `lit next` hands that work back to you; once the claim has expired the work is nobody's, and `lit next` offers it by rank like everything else, so the "Uncommitted changes" and "Open PRs" checks above are what find it.
So reach for it only when `lit next` has nothing left to give, and read which of its empty-handed answers you got — they are not interchangeable, and each opens with its own words, quoted below.
- **Bare `no ready work`** — nothing is queued at all. An orphan is now the right pull: it is the most advanced work in the repo and somebody has to finish it. `lit start <id>` takes it, with no prompt and no ceremony: nobody holds the lane, so there is no claim to transfer. Check that lane for unmerged branches or PRs before building on it — lit knows nothing about git or the forge, and the ticket's history (`lit show`) is where its previous holder's trail is. The orphan you take is your ticket — if its lane has an open PR, take it through "Finishing a ticket"; otherwise skip ahead to "Working the ticket".
- **`no ready work — the backlog is not empty, but nothing in it is startable here`**, naming ids. Work exists; none of it is yours to take. `lit orphaned` will not rescue this, and not by luck: each row in that message carries a note saying why this checkout cannot start it, and `lit orphaned` reads only a row's own clock, so a quiet row whose lane somebody still holds appears on both lists, and pulling it from the second lands you on a lane you may not take. Report what `lit next` named and stop. Taking a lane another checkout holds fresh is `lit start --take`, a deliberate takeover the user directs — never your way around an empty-handed `next`.
- **`no ready work on the focus path — the backlog is not empty, and each row below says why this run did not serve it`** — a focus label narrowed this run. Each row it names carries its own note: a row on the focus path is the answer above again, one this checkout cannot start, and a row noted as off the focus path was never asked about. If an off-path row is the work to do, `lit next --all` routes over them; otherwise report what `lit next` named and stop.
- **`no ready work in`**, then a scope — the scoped answer. The scope is `epic(s) <ids>`, or `your claimed lane(s)` when the lane you hold has no epic over it. Then comes how far that scope had come, such as `(5/9 done)`, then what blocks it, and then that `lit next` has nothing ready outside it either. Under a focus label that last part instead names the rows outside the scope that the focus kept it from asking about; if one of them is the work to do, `lit next --all` routes over them. Otherwise, with no other work to move on to, the one route left is staying: file the ticket that unblocks the scope, as "What the pick means" below describes. The message offers that route only when something blocks the scope; when it names no route, or you cannot name the work that would clear the block, report the blocker and stop. An orphan is not a way around this: every orphan on that list is outside the scope `lit next` just named, so if one looks urgent, say so and let the user direct it.
- **`` `lit next` without --type, --status, --labels or --assignee hands you ``**, then a ticket — the filter on this run hid that ticket, and it is the one `lit next` hands you once the filter is dropped. Run `lit next` without the filter. The scoped answer above includes this same sentence when the filter is why nothing outside its scope was on offer.
#### What the pick means
`lit next` is not showing you a menu. Selection is epic-major: the epic in flight comes before anything else for as long as it has workable work. Once this checkout has started work in an epic, `lit next` keeps handing you tickets from that same epic until it has nothing workable left to give — the ranked backlog is the rationale for that order, not a list you shop from. Finishing a ticket does not open the field back up; run `lit next` again and it hands you the next thing in the same epic. It is the order, and there is no knob. (The exact routing precedence behind the pick is the quickstart's reference, not this skill's — `lit quickstart work` has it.)
**When your epic has open work but none of it is workable**, `lit next` neither strands you in it nor leaves it silently. First it serves anything that would clear the block: a ready dependency gating the epic comes back like any pick, marked `(gates <id>, which is on your path)`. Failing that, it prints why the epic stopped — `no ready work in epic(s) <ids> (<done>/<total> done)`, naming what blocks it — then the ways on, and serves the top ready ticket outside the epic beneath them. Choose one:
- **Stay** — file the ticket that clears a blocker with the `lit new` command the message prints, then make that blocker blocked by it with the `lit dep add` command the message prints for it, putting your ticket's id in place of `<new>`. It prints one for each blocker a ticket filed here could free, and only those: not a blocker waiting on an outside event, nor one still waiting on other tickets. Filing alone clears nothing: the blocked tickets still wait on their blocker until it waits on your ticket. That holds when the block sits on the epic itself (`lit show` marks it `(via epic)`) too: your new ticket starts out held back like every other child, and the `lit dep add` frees it, since an epic's blocker never holds back a ticket it waits on. Then run `lit next` again; it serves the new ticket. Choose this when you can see the work that would clear the block and no ticket carries it yet: a blocker that is itself stuck, or a piece the blocked tickets are waiting on that nobody has filed. The message offers this route only when something blocks the epic; when the rest of it is just underway in other checkouts, there is nothing to unblock.
- **Move on** — `lit start` the ticket `lit next` served. Choose this when the block is already somebody's work, such as a blocker another checkout holds, or when you cannot name the work that would clear it.
Those are the routes. Do not go looking for a third in `lit backlog` or `lit orphaned`: the ticket served is already the backlog's top ready pick outside your epic, chosen by rank, and an agent that shops past it recreates by hand the scattering this order exists to prevent.
## Working the ticket
However you arrived at a ticket — uncommitted work, an orphan, or `lit next` — work it through these steps:
1. **Read the ticket fully.** Title, description, acceptance criteria, comments, linked PRs, linked tickets. If the ticket references a spec, doc, or prior PR, read that too. You are about to author code that claims to satisfy this ticket — earn the right to claim it.
2. **Surface blockers before starting.**
- Acceptance criteria missing or vague? Investigate first (see below); ask only if it stays genuinely unresolvable.
- Depends on another ticket that isn't done? Stop and report.
- Spec referenced but doesn't exist? Stop and report.
- The ticket conflicts with current branch state or uncommitted work? Stop and report.
- **Does an older open PR touch the files this ticket will touch?** Rebuilding on top of stale code risks merge conflicts you cannot untangle later.
```
gh pr list --state open --limit 1000 --json number,headRefName,title,files \
--jq '.[] | select(.headRefName | . == "<ticket-id>" or startswith("<ticket-id>_") or startswith("<ticket-id>/") | not) | "\(.number) \(.headRefName) :: \(.files | map(.path) | join(", "))"'
```
The `select` drops *this ticket's own* PR, and it keys on the ticket id for a reason worth keeping. You reach this step from every arrival path, including one where you are still standing on the previous ticket's branch — step 3 has not switched you to the trunk yet. Filtering on the checked-out branch instead would there hide the previous ticket's open PR: the single most likely overlap, and the one the very next step warns you about building on top of.
Two things about that filter are load-bearing, and both look like clutter you could tidy away.
It compares literal strings — an equality and two `startswith` — rather than matching a pattern. A pattern has to be told where the id ends, and every way of saying that has been wrong once already: a bare prefix match also swallows a *longer* id that begins with yours (ids are minted at a hash length that widens only as a namespace fills, so both can exist), and a regex reads `.` as "any character", which quietly widens the match at every dot in a child ticket's id. Literal comparison cannot be widened by anything an id contains, so it stays right as id shapes change.
`--limit 1000` is there because `gh pr list` fetches 30 by default and says nothing when it stops. A truncated page looks exactly like a complete one, so the check would report a clean bill while the overlapping PR sat at position 31 — and this check hunts *older* PRs, which are the ones a default listing pushes off the end.
What the filter removes is your ticket's own branch and its slugged forms. Everything else survives to be read, including a PR whose branch carries no ticket id at all — you read that one and dismiss it, which is the direction to err in.
If a *different* PR overlaps, surface it to the user with both the ticket and PR references before starting, rather than silently building over it.
- Don't paper over ambiguity with assumptions — confirm scope first.
IN ALL CASES YOU MUST DO AS MUCH OBVIOUS PREPARATORY WORK AS YOU CAN BEFORE ASKING THE USER.
A mature engineer knows when to ask for help, and it isn't at the slightest hint of ambiguity and before they've put in a shred of effort to answer the question themselves. "What do I do with this uncommited work" is only a good question if it isn't obviously work that Directly corresponds to the ticket matching the branch name. "Acceptance criteria missing or vague?" It is only a good question if it's not clearly answerable via common sense or existing documentation or some other method. If there's real ambiguity, surface it. If it's just basic information about the repo, see if you can figure it out for yourself. In all cases, the user should be presented with The results of an Extremely quick Investigation rather than "Hey, I don't know what to do. Tell me what to do."
3. **Set up the workspace.**
- **Already on the ticket's branch?** You are, if you arrived here from uncommitted work. Stay on it and skip to the cleanliness check — creating a second branch here strands the work you just claimed.
- **Otherwise, branch from an up-to-date trunk** — not from wherever HEAD happens to be sitting. Finishing a ticket leaves you standing on its branch, and `git checkout -b` from there silently forks the new ticket off unmerged work: the PR opens carrying the previous ticket's diff on top of its own, and it cannot be reviewed or merged on its own. Fetch the trunk first; the branch is cut from it below:
```
git fetch origin
```
Cut from `origin/master` rather than checking `master` out: in a linked worktree, `git checkout master` fails while another checkout has it.
- **Look for an existing branch before you create one.** A previously-started ticket may already have one, and it may carry a slug — `<ticket-id>_slug` — so an exact-name checkout reads it as missing and you start a duplicate. Search by substring, locally and on the remote, and ask for clean names:
```
git branch --all --list '*<ticket-id>*' --format='%(refname:short)'
```
Judge this on its *output*, not its exit status: the command succeeds with rc=0 and prints nothing when there is no match. `--format` is not optional — the default output is decorated (`*` for the current branch, `+` for one checked out in another worktree, `remotes/` on every remote ref), and none of those lines can be pasted into a checkout.
Then read what it printed:
- **A bare name** — a local branch. `git checkout <name>`.
- **A bare name *and* `origin/<name>`** — one branch seen twice, local and remote. Use the bare one.
- **Only `origin/<name>`** — a branch pushed from somewhere you have never checked out here. `git checkout -b <name> origin/<name>`. Checking out the `origin/...` ref itself lands you on a detached HEAD with no branch and nothing to push to, which you will discover at the end, when you try to open the PR.
- **Several genuinely different branches** — the search is a substring match, so a sibling ticket id can collide with yours. Read them and choose deliberately; don't take the first line.
One failure to expect, because `--format` is what hides it. The `+` you just discarded meant "checked out in another worktree", so a checkout can come back:
```
fatal: '<name>' is already used by worktree at '<path>'
```
That is another local worktree holding the branch, and the message names where. Go work in that worktree, or stop and report it. Do not delete the branch and do not cut a second one for the same ticket — you would be starting the duplicate this whole step exists to prevent.
Only when the search prints nothing do you create one:
```
git checkout --no-track -b <ticket-id> origin/master # or the repo's default branch
```
Plain ticket id, no slug. A slug is invented, so two sessions that both slug one ticket invent two different names for it, and the next search turns up "several genuinely different branches" and a judgment call that never needed to exist. The bare id is the one name every session picks independently.
- Confirm the working tree is clean before starting. If dirty, Figure it the f*ck out. You're a mature, responsible, highly skilled engineer.
4. **State the plan in one paragraph, then start.** What the ticket asks for, how you'll verify it's done (the machine-verifiable criterion), and the first concrete step. Then begin.
5. **Record the phase as the work moves.** `lit start` put the ticket in `plan`. Run `lit phase <id> --to impl` when you start writing its code, and open its PR, or push to it if its branch already has one open; from there "Finishing a ticket" below takes it to `lit done`, and on to the next ticket.
## Finishing a ticket
A ticket with an open PR finishes here, whichever way you reached it: step 5 above, a PR under "Open PRs", or an orphan whose lane has one.
1. **Hold it from this checkout.** Read the claim line under the ticket's lane in `lit backlog`. A claim line naming anything but this checkout's path is another checkout's, and the ticket is theirs: leave it, say so, and take the way out below. Otherwise run `lit start <id>` here, and check its PR's branch out. `lit start` is safe to repeat: a ticket already in progress keeps the phase its work had reached, and any other enters `plan`.
2. **Close its PR out** — clean and merged — through the review process your instructions define, and where none defines one, by working its review threads by hand. Unless you wrote its code in "Working the ticket", read the ticket fully first, as step 1 there asks: the PR is reviewed against its acceptance criteria, and one that meets only part of them, or rests on a ticket that is not done, is not ready to merge. Record each phase when the work reaches it, not afterwards: `lit phase <id> --to review` now if `lit show <id>` puts the ticket short of review, and `lit phase <id> --to merge` when review is done and the merge is under way.
3. **Run `lit done <id>` once it has merged,** then step off its branch — `git fetch origin && git switch --detach origin/master` (or the repo's default branch) — so nothing is built on a branch that leads nowhere.
A statusline and other sessions read the phase to see where the work stands, so it is only as current as the last `lit phase` you ran. A handoff to the next session names this checkout's path, because a fresh session starts in the primary clone, and `lit next` run there routes away from the work this checkout holds.
Then take the way out that matches the way in. A PR found under "Open PRs" — this branch's own, or one from "Your PRs elsewhere" — goes back to the "Your PRs elsewhere" list, which may still hold one in flight; running `lit next` from there skips the rest of it. Every other route runs `lit next` from this checkout, and the next ticket it serves is worked here too, on a fresh branch (step 3).
## When to stop and ask
To be honest, rarely. You should be capable of figuring this stuff out.
If you think that there's a chance that this could have negative impacts on other work, you can ask a quick question, but like I said, You need to make an attempt to answer the question yourself. (The one recurring case — a branch carrying uncommitted work that belongs to no current ticket — is already handled in "Uncommitted changes" above.)