chainrail

command module
v0.1.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: MIT Imports: 3 Imported by: 0

README ยถ

chainrail ๐Ÿš‚

Ship smaller PRs. Review faster. Never fight a squash-merge conflict again.

Latest release MIT License Go

Chainrail organises your work into a chain of small, reviewable pull requests and keeps the whole chain healthy when things change โ€” including when a parent PR gets squash-merged and GitHub would normally explode with false conflicts.


The problem ๐Ÿ˜ค

Your team uses squash-and-merge. You build a stacked PR. The parent gets merged โ€” GitHub squashes it to a new commit. Now every child branch shows the entire parent diff as "conflicts." You spend the next hour doing git surgery.

cn sync does that surgery for you, automatically, every time.


Install

go install github.com/brayschurman/chainrail@latest
alias cn=chainrail

Requires Go 1.21+ and the gh CLI installed and authenticated.


See your stack at a glance โœจ

Run cn status on any branch in your stack:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚                                                              โ”‚
โ”‚   chainrail ยท dev-42                                         โ”‚
โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€         โ”‚
โ”‚                                                              โ”‚
โ”‚     1  bray/dev-42-1-schema    #12  โœ“ merged                 โ”‚
โ”‚   โ–ถ 2  bray/dev-42-2-api       #13  โ— open                   โ”‚
โ”‚     3  bray/dev-42-3-ui        #14  โ— open  โš  needs sync     โ”‚
โ”‚                                                              โ”‚
โ”‚     q quit                                                   โ”‚
โ”‚                                                              โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Color-coded PR states, sync warnings, and your current position โ€” all live from GitHub. No more keeping the stack in your head.


Quickstart ๐Ÿš€

# one-time setup per repo
cn init --base main

# build a stack, one layer at a time
cn add feature-schema   # creates your-name/feature-1-schema and checks it out
# ... write code, commit ...
cn add feature-api      # stacks on top
# ... write code, commit ...
cn add feature-ui       # one more layer
# ... write code, commit ...

# open all PRs at once, with correct bases
cn submit

# parent PR got squash-merged? just run:
cn sync                 # chainrail figures out the rest

Commands

cn init --base <trunk> โ€” set up chainrail in your repo (once per clone)

cn add <slug> โ€” create the next branch in your stack

cn submit โ€” push all layers and open PRs with correct base chains

cn sync โ€” rebase everything onto fresh trunk; handles squash-merged parents automatically

cn status โ€” open the TUI to see your full stack health at a glance


Stack map in every PR ๐Ÿ—บ๏ธ

Every PR description gets a navigation block so reviewers know where they are:

Stack (bottom โ†’ top)
1. your-name/feature-1-schema โ† you are here
2. your-name/feature-2-api
3. your-name/feature-3-ui

Rerunnning cn submit updates it in place โ€” no duplicates.


Working with agents ๐Ÿค–

Chainrail is built to be agent-friendly. If you're using Claude Code or another AI assistant, add the skill file so your agent understands stacked PR workflows automatically:

Load the chainrail skill from .claude/skills/chainrail/SKILL.md and use it to manage my PR stack.

A good starting prompt:

I want to split my current work into a stack of small PRs. Use chainrail to help me layer it โ€” schema first, then API, then UI.

The skill file teaches your agent when to reach for chainrail, how to decompose work into layers, and what to do when a parent PR gets merged.

For developers building on chainrail, see AGENTS.md for the full architectural guide.


How it compares

Capability chainrail Graphite ghstack Manual stacking gh stack
Stacked PRs with correct bases โœ… โœ… โœ… โœ… โœ…
Squash-merge conflict recovery โœ… โœ… โŒ โŒ โœ…
TUI stack health view โœ… โŒ โŒ โŒ โŒ
Agent / AI skill file โœ… โŒ โŒ โŒ โŒ
Works with standard GitHub PRs โœ… โœ… โŒ โœ… โœ…
No account or subscription needed โœ… โŒ โœ… โœ… โœ…
Open source โœ… โŒ โœ… โ€” โœ…
Requires Go (no binary install yet) โœ… โŒ โŒ โ€” โŒ

Chainrail is early. Graphite is the mature, polished option โ€” if you want a SaaS product with a web UI, use Graphite. Chainrail is for teams who want a lightweight, open-source tool that an AI agent can drive.


License

MIT

Documentation ยถ

The Go Gopher

There is no documentation for this package.

Directories ยถ

Path Synopsis
cmd
mockup command
internal
diffview
Package diffview renders unified diffs from `gh pr diff` in a TUI.
Package diffview renders unified diffs from `gh pr diff` in a TUI.
git
reviewstate
Package reviewstate persists per-file PR-review progress on disk.
Package reviewstate persists per-file PR-review progress on disk.
tui

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL