---
name: next-slice
description: >-
  Advance to the next PRD slice after a merge: clean up the finished worktree and branch, fast-forward main, pick the next unblocked sub-issue of the PRD, set up a fresh worktree, and hand off to address-issue. Use when the user says "next slice", "move on", "advance", or wants to start the next issue after a merge.
title: next-slice
canonical_url: https://skilld.dev/gh/mia-cx/skills/next-slice
last_updated: 2026-09-21T03:56:39.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install mia-cx/skills/next-slice`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/next-slice`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/mia-cx/skills/next-slice) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/next-slice`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/next-slice --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/next-slice --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Next slice

Transition from a just-merged slice to the next one. This skill handles the in-between (cleanup, branch hygiene, slice selection, fresh worktree), then hands the chosen issue to the `address-issue` skill, which owns planning, implementation, and the PR.

## Workflow

### 1. Verify the current slice is done

- Identify the repo root (the main worktree, not a `.worktrees/` child), the current worktree, and its feature branch.
- Confirm the PR for the current slice is merged. If not, stop and report: the slice isn't done (`review-relay` / `pr-merge` come first).

### 2. Clean up the finished slice

From the **repo root** (not from inside the worktree being removed):

```bash
cd <repo-root>
git worktree remove .worktrees/<current-name>
git branch -d <current-branch>
git pull --ff-only origin main
```

A `-d` warning about the branch not being merged to HEAD is expected; it merged to `origin/main` via the PR. Use `-D` only if `-d` fails and the PR is confirmed merged. Confirm the repo root ends up clean and tracking `origin/main`.

### 3. Pick the next slice

The parent PRD's sub-issues are the source of truth. A slice is eligible when it is **open** and **unblocked** (every issue in its "Blocked by" section is closed):

```bash
# Sub-issues of the PRD with their state
gh api graphql -f owner=OWNER -f repo=REPO -F number=PRD_NUMBER -f query='
  query($owner:String!,$repo:String!,$number:Int!){
    repository(owner:$owner,name:$repo){issue(number:$number){
      subIssues(first:50){nodes{number title state}}}}}'

# Check a candidate's blockers via its body's "Blocked by" section
gh issue view <number> --json body,state
```

Pick the lowest-numbered eligible slice; prefer AFK slices when an HITL slice would otherwise block unattended progress. Without a PRD, fall back to `.plans/*.md` order or open implementation issues. Skip meta/tracking issues (PRDs, discussions, umbrella trackers).

If no eligible slice remains: report all slices complete, or name the HITL/blocked issues that need the user.

### 4. Set up the new worktree

Derive the worktree and branch names from the issue title:

```bash
cd <repo-root>
git worktree add .worktrees/<short-name> -b feat/<short-name> main
```

### 5. Report and hand off

```
Cleaned up: .worktrees/<old> (branch <old-branch> deleted)
Main: <commit> on origin/main
Next slice: #<N> <title> (sub-issue of PRD #<P>)
Worktree: .worktrees/<new> on branch <new-branch>
```

Then run the `address-issue` skill on issue `#<N>` in the new worktree; it owns the plan file, TODO-per-commit implementation, and the PR. Begin immediately if the user asked to advance and implement; otherwise wait for their go-ahead.

## Rules

- Always operate from the repo root when removing worktrees or pulling main.
- Never force-delete branches without confirming the PR is merged.
- Each slice gets its own worktree under `.worktrees/`; never implement directly on `main`.
- If the next eligible slice is HITL, surface the decision it needs instead of starting it unattended.
