code-gt-linearize-descendants

Linearizes and consolidates descendant branches of a Graphite stack with confirmation-gated rewrites.

2|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/nseng-ai/ns --skill code-gt-linearize-descendants-nseng-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-gt-linearize-descendants
Source: https://github.com/nseng-ai/ns/tree/main/skills/internal/code/code-gt-linearize-descendants
Command: npx skills add https://github.com/nseng-ai/ns --skill code-gt-linearize-descendants-nseng-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Graphite stacks often accumulate accidental forks, duplicate PRs, and misplaced branches that make review and merging painful. This Skill inspects the full descendant subtree of a target branch, proposes a clean linear stack, and performs supervised rewrites only after explicit confirmation. ## Core Features & Use Cases - Read-only descendant analysis: Gathers a complete JSON report of descendant branches, commits, diffs, and PR status via ns slot gt exec descendants-report before proposing any change. - Proposal-first workflow: Renders a compact plan covering keep/move/reorder/drop actions per branch, superseded PR title prefixes, and submit consequences, then waits for one explicit confirmation. - Safe mutation with backups: Requires a clean worktree, creates timestamped backup refs for every affected branch, rewrites via gt track/gt restack or cherry-pick rebuilds, runs gt submit --no-interactive, and prefixes superseded PR titles with [superseded-pr] instead of closing them. - Use Case: A developer discovers their Graphite stack forked into three parallel branches with overlapping changes. The Skill identifies which PRs are independent, which are duplicates, proposes a single linear stack, and executes the rebase, submit, and retitling after approval. ## Quick Start Ask the agent to linearize the descendants of a specific Graphite branch, for example: linearize the descendants of branch feature-auth and consolidate any duplicate PRs.

Frequently Asked Questions about code-gt-linearize-descendants

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I linearize a forked Graphite stack?

Run the descendants-report command for the target branch to gather complete topology, commit, diff, and PR evidence. The Skill then proposes a final linear stack with per-branch actions and rewrites only after your explicit confirmation.

How to clean up duplicate PRs in a Graphite stack?

Duplicate branches are identified by comparing diffs across the descendant report. After the rewrite succeeds, the duplicate branch is deleted and the superseded PR's title is prefixed with [superseded-pr] rather than being closed, preserving review context.

Does this workflow close or delete GitHub PRs automatically?

No, it never closes GitHub PRs. Superseded PRs are preserved for context and only receive a [superseded-pr] title prefix after confirmation, and only when the proposal names the complete set of replacement PRs.

What happens if the worktree is dirty before a stack rewrite?

The workflow stops and asks you to checkpoint, stash, or switch to another worktree. Mutation only proceeds when git status is clean and timestamped backup refs exist for every affected branch.

What are the limitations of automated Graphite stack linearization?

It requires a complete descendants report and stops on partial or malformed data rather than inferring a partial subtree. When diffs overlap but intent is ambiguous, it escalates to manual consolidation instead of guessing.