| Crates.io | diamond-cli |
| lib.rs | diamond-cli |
| version | 0.1.4 |
| created_at | 2026-01-04 02:01:00.706986+00 |
| updated_at | 2026-01-19 04:45:16.62046+00 |
| description | Lightning-fast CLI for stacked pull requests |
| homepage | https://github.com/rsperko/diamond |
| repository | https://github.com/rsperko/diamond |
| max_upload_size | |
| id | 2021157 |
| size | 2,094,936 |
Stop waiting for code reviews. Start shipping.
Diamond is a lightning-fast CLI for stacked pull requestsβthe workflow used at Meta, Google, and top engineering teams to ship code faster with higher quality.
β οΈ Alpha Software: Diamond is in active development. Works well, but expect rough edges. Please report issues!
You finish a feature. You open a PR. Then you wait.
Hours. Sometimes days. Your next feature depends on this one, so you're stuck. You could branch off your unmerged work, but rebasing that later? Nightmare fuel.
Meanwhile, your best engineers are context-switching instead of coding.
Diamond lets you build Feature B on top of Feature Aβbefore Feature A is even reviewed. When Feature A gets feedback, Diamond automatically rebases your entire stack in milliseconds.
β Stay in Flow β Never blocked waiting for reviews to continue working β Smaller, Focused PRs β Break features into reviewable chunks (200-500 lines each) β Automatic Rebase β Your entire stack rebases in milliseconds, not hours β Standard Git β Works with existing tools, no vendor lock-in
β 4x Faster Reviews β Research shows reviewers process 5 small PRs faster than 1 large one (Dr. Michaela Greiler) β 21% More Code Shipped β Teams using stacked workflows ship measurably more (Asana case study) β 7 Hours/Week Saved β Reduced context switching per developer (Asana case study) β Zero Reviewer Training β Creates standard GitHub/GitLab PRsβno new tools required
brew install rsperko/tap/diamond
See Getting Started Guide for Cargo, build-from-source, and more.
Verify installation:
dm --help
Next: Set up GitHub (gh auth login) or GitLab (glab auth login). See Getting Started for details.
# Initialize Diamond in your repo
dm init
# Create your first branch
dm create add-database-schema -am "Add users table"
# Stack another branch on top (no waiting!)
dm create add-user-service -am "Add service layer"
# Visualize your stack
dm log
# Submit both PRs
dm submit --stack
Full walkthrough: Getting Started Guide
Let's build a complete authentication system as a stack of small, focused PRs:
# Start from main
dm init
# Layer 1: Database (150 lines)
dm create auth-schema -am "Add users and sessions tables"
# Layer 2: Business logic (200 lines) - builds on Layer 1
dm create auth-service -am "Add authentication service"
# Layer 3: API endpoints (180 lines) - builds on Layer 2
dm create auth-api -am "Add /login and /logout endpoints"
# Layer 4: Frontend (220 lines) - builds on Layer 3
dm create auth-ui -am "Add login form component"
# Visualize the stack
dm log
Your stack:
β main
βββ β auth-schema
βββ β auth-service
βββ β auth-api
βββ β auth-ui β (current)
Submit for review:
dm submit --stack
Before (monolithic PR):
After (stacked PRs):
Result: Reviews happen in parallel. Total time: 30 minutes instead of 4 hours sequential.
Built with libgit2 for sub-millisecond operations. Your stack with 20 branches? Rebased in <100ms.
dm log gives you a beautiful terminal UI to visualize complex stacks. No more ASCII art in git log.
Diamond uses standard Git branches and commits. Your team doesn't need Diamond to review your PRs. You can always drop back to vanilla Git.
Metadata lives in .git/diamond/ (Git-ignored by default) and git refs. Delete it and you're back to regular Git branches. No remote dependencies.
| Command | Description |
|---|---|
dm create <name> |
Create branch on top of current |
dm checkout [name] |
Switch branches (interactive if no name) |
dm log |
Visualize stack tree (TUI) |
dm submit --stack |
Push and create PRs for entire stack |
dm sync |
Fetch trunk and rebase all branches |
dm restack |
Rebase stack without fetching |
dm up / down |
Navigate to child/parent branch |
dm modify -am "msg" |
Amend current branch |
dm continue / abort |
Handle conflicts or cancel operation |
dm doctor --fix |
Diagnose and repair metadata |
Full reference: Command Reference
Diamond stores parent-child relationships as git refs that travel with push/fetch:
refs/diamond/config/trunk β blob("main")
refs/diamond/parent/auth-schema β blob("main")
refs/diamond/parent/auth-service β blob("auth-schema")
refs/diamond/parent/auth-api β blob("auth-service")
When you run dm restack or dm sync, Diamond:
git rebasedm continue / dm abortThat's it. No magic. Just smart orchestration of Git primitives.
Q: Do my reviewers need Diamond? A: No. Diamond creates standard GitHub PRs and GitLab MRs. Reviewers see normal PRs with clear base branches.
Q: What if I get conflicts during rebase?
A: Diamond pauses and lets you resolve conflicts manually. Then run dm continue to resume.
Q: Does this work with GitLab?
A: Yes! GitLab has full feature parity with GitHub. Diamond creates MRs, handles approvals, waits for pipelines, and supports auto-merge. Requires glab CLI. Self-hosted GitLab instances are also supported.
More questions? See Getting Started or Troubleshooting
Diamond is open source and built with π¦ Rust. Contributions welcome!
Development setup:
git clone https://github.com/rsperko/diamond.git
cd diamond
cargo build
cargo test # 206+ tests, ~90% coverage
cargo clippy -- -D warnings
just setup-hooks # Configure git hooks (Gitleaks)
Security:
This project uses Gitleaks to prevent secrets from being committed. Run just setup-hooks to install the pre-commit hook.
Architecture:
src/main.rs β CLI parsing (clap)src/commands/ β Command implementationssrc/git_gateway.rs β Git operations (libgit2)src/ref_store.rs β Stack metadata in git refssrc/state.rs β Operation state managementsrc/forge/ β GitHub/GitLab integrationThe stacked diff workflow has been used for years at:
Diamond brings this workflow to any team using GitHub or GitLab, with the speed of Rust and zero SaaS dependencies.
Apache 2.0 Β© 2025
Built with β€οΈ for developers who ship fast.