Cascade CLI improves Git workflows by enabling stacked diffs for Bitbucket Server - a powerful technique for managing chains of related commits as separate, reviewable pull requests. Perfect for feature development, bug fixes, and complex changes that benefit from incremental review.
๐ Table of Contents
- โจ Key Features
- ๐ฟ How Stacked Diffs Work: Branch Management
- ๐ Why Stacked Diffs?
- ๐ Quick Start
- ๐ง Git Hooks (Recommended)
- โก Essential Commands
- ๐ Command Reference
- ๐ค Smart Conflict Resolution
- ๐ง Configuration
- ๐จ Advanced Features
- ๐ Documentation
- ๐ค Contributing
- ๐ง Development
- ๐๏ธ Architecture
- ๐งช Testing
- ๐ License
โจ Key Features
๐ Stacked Diff Workflow
- Chain related commits into logical, reviewable stacks
- Independent PR reviews while maintaining dependencies
- Automatic rebase management when dependencies change
- Smart force-push strategy to preserve review history
- Smart conflict resolution - Auto-resolves 60-80% of common rebase conflicts
๐ข Team Integration
- Bitbucket Server native integration
- Pull request automation with dependency tracking
- Team workflow enforcement via Git hooks
- Progress tracking with real-time status updates
๐ฅ๏ธ Clean Interface
- Interactive TUI for visual stack management
- Shell completions (bash, zsh, fish)
- Rich visualizations (ASCII, Mermaid, Graphviz, PlantUML)
- Beautiful CLI with progress bars and colored output
๐ฟ How Stacked Diffs Work: Branch Management
Key Insight: Each Commit = Its Own Branch + PR
Cascade CLI automatically creates individual branches for each commit in your stack:
# You work normally (on main or a feature branch)
# Make commits as usual
# Push to stack - Cascade CLI creates separate branches automatically:
# Submit creates individual PRs to main:
Two Workflow Options:
Option 1: Work on Main (Recommended for Solo Development)
# Make commits directly on main (they stay local until you push to remote)
# Cascade CLI handles all branch creation and PR management
Option 2: Work on Feature Branch (Team-Friendly)
# Make commits on your feature branch
# Cascade CLI creates individual branches from your feature branch
# All PRs target main, not your feature branch
What You See vs. What Reviewers See:
| You (Developer) | Reviewers (Bitbucket) |
|---|---|
| Work on 1 branch | See 3 separate PRs |
| 3 commits in sequence | Each PR focuses on 1 logical change |
git log shows: AโBโC |
PR #101: A, PR #102: B, PR #103: C |
The Magic: Auto-Generated Branch Names
Cascade CLI creates meaningful branch names from your commit messages:
๐ Why Stacked Diffs?
Traditional Git workflows often result in:
- Large, hard-to-review PRs
- Blocked development waiting for reviews
- Merge conflicts from long-lived branches
- Lost context in massive changesets
Stacked diffs solve this by:
- โ Small, focused PRs that are easy to review
- โ Parallel development with dependency management
- โ Reduced conflicts through frequent integration
- โ Better code quality via incremental feedback
๐ Quick Start
1. Installation
Quick Install (Recommended)
Universal Script (Linux/macOS):
|
Package Managers:
# macOS - Homebrew (download formula first)
# Rust users
Manual Installation
Pre-built Binaries:
# macOS (auto-detect architecture)
|
# Linux (auto-detect architecture)
|
# Windows (PowerShell)
From Source:
See Installation Guide for detailed platform-specific instructions.
2. Initialize Your Repository
# Navigate to your Git repository
# Quick setup wizard (recommended)
# Or manual initialization
3. Create Your First Stack
# Create a new stack
# Make multiple incremental commits (for your own tracking)
&&
&&
&&
&&
# SQUASH + PUSH - Combine incremental commits into clean commit!
# OR: Make some commits normally, then squash later ones
# SQUASH UNPUSHED - Only squash the last 3 commits
# BATCH SUBMIT - Submit all unsubmitted entries as separate PRs!
# Alternative options (for granular control):
๐ง Git Hooks (Recommended)
Cascade CLI provides Git hooks that automate common stacked diff workflows:
| Hook Name | Purpose | When It Runs |
|---|---|---|
post-commit |
Auto-add commits to active stack with unique branch names | After every git commit |
pre-push |
Prevent force pushes, validate stack state | Before git push |
commit-msg |
Validate commit message format | During git commit |
prepare-commit-msg |
Add stack context to commit messages | Before commit message editor |
# Install all hooks for automated workflow
# Remove all hooks
# Check installation status
# Remove specific hooks
๐ช Default hooks installed:
- Pre-push: Prevents force pushes that break stack integrity
- Commit-msg: Validates commit message quality
- Prepare-commit-msg: Adds helpful stack context
๐ Complete Hooks Guide - Detailed explanation of each hook, troubleshooting, and advanced usage
๐ก Pro tip: The post-commit hook (auto-add commits to stack) is available but not installed by default to avoid conflicts with existing repo hooks.
# Install optional post-commit hook if no conflicts
๐ก Installation Tips:
- For full automation: Install all hooks with
ca hooks install - For manual control: Remove
post-commithook, keep others for safety - For team safety: Always keep
pre-pushto prevent stack corruption
4. Experience the Magic
# Check your stack status
# Stack: feature-auth (3 entries)
# Entry 1: [abc123] Add authentication endpoints โ PR #101
# Entry 2: [def456] Add password validation โ PR #102
# Entry 3: [ghi789] Add comprehensive tests โ PR #103
# Monitor and auto-merge approved PRs
# โ
Monitoring PRs for approval + passing builds
# โ
Will auto-merge in dependency order when ready
๐ก๏ธ Safe Development Flow (Recommended)
Cascade CLI protects against accidentally polluting your base branch:
# โ
SAFE: Start on base branch, but work on feature branches
# Make your changes
# Push to stack (automatically tracks source branch)
๐ Auto-Branch Creation (Even Safer)
Let Cascade CLI handle branch creation automatically:
# If you accidentally work on main...
# (make commits directly on main - oops!)
# Cascade CLI will protect you:
๐ฏ Smart Interactive Edit Mode
When editing stack entries, Cascade CLI intercepts your Git commands and provides smart interactive guidance:
# Just commit normally - the system takes care of the rest!
# โ ๏ธ You're in EDIT MODE for a stack entry!
#
# Choose your action:
# ๐ [A]mend: Modify the current entry
# โ [N]ew: Create new entry on top (current behavior)
# โ [C]ancel: Stop and think about it
#
# Your choice (A/n/c): A
#
# โ
Running: git commit --amend
# [Opens editor for amending]
# ๐ก Entry updated! Run 'ca sync' to update PRs
No more remembering commands - just type git commit and Cascade guides you to the right action automatically!
๐ Scattered Commit Detection & Auto-Fix
Cascade CLI detects when you're adding commits from different Git branches to the same stack and provides automatic resolution options:
# This creates a "scattered commit" problem:
# When you push both to the same stack:
# โ ๏ธ WARNING: Scattered Commit Detection
# You've pushed commits from different branches:
# - feature-branch-1 (1 commit)
# - feature-branch-2 (1 commit)
#
# This makes branch cleanup confusing after merge.
# Consider organizing commits into separate stacks instead.
# ๐ง Modern Fix: Use validation to detect and resolve
๐ Smart PR Creation
Cascade CLI automatically generates meaningful pull request titles and descriptions:
# Create draft PRs for review:
# Each PR gets intelligent metadata:
# โโ PR Title: Generated from commit messages
# โโ Description: Combines commit details & context
# โโ Branch: Auto-created with semantic naming
# โโ Target: Points to previous stack entry or base
# Custom titles and descriptions:
# Default behavior (auto-generated):
How PR Content is Generated:
- Title: Uses your commit message or most significant change
- Description: Includes commit details, file changes, and stack context
- Branch Context: Shows relationship to previous entries
- Target Branch: Automatically set to build on previous stack entry
Daily Development Flow
Cascade CLI follows a simple, powerful workflow optimized for modern development:
# 1. Create & Develop
# 2. Push & Submit (with modern shortcuts)
# 3. Auto-Land (set and forget)
# 4. Iterate (if review feedback)
๐ Advanced Workflows: See our comprehensive Workflows Guide for complex scenarios including:
- Multi-commit stacks with dependencies
- Handling review feedback on middle commits
- Managing emergency hotfixes during feature development
- Cross-team collaboration patterns
- Base branch updates with smart force push
- Modern WIP-to-clean commit workflows
๐ค Smart Conflict Resolution
Automatic Conflict Resolution
Cascade CLI automatically resolves 60-80% of common rebase conflicts using intelligent pattern recognition.
โ Resolved Automatically
- Import statement conflicts - Merges and deduplicates imports
- Dependency version conflicts - Uses latest compatible versions
- Simple formatting conflicts - Applies consistent code style
- Non-overlapping changes - Safely combines independent modifications
How It Works
- Pattern Recognition: Analyzes conflict types using AST parsing
- Safe Resolution: Only resolves conflicts with zero ambiguity
- Manual Fallback: Escalates complex conflicts to developer review
- Audit Trail: Logs all automatic resolutions for transparency
# Smart conflict resolution in action
# ๐ค Auto-resolved 3 import conflicts in src/auth.rs
# ๐ค Auto-resolved 1 dependency conflict in package.json
# โ ๏ธ Manual resolution needed: 1 logic conflict in src/validation.rs
Supported File Types for Import Resolution
- JavaScript/TypeScript (
.js,.ts,.jsx,.tsx) - Python (
.py) - Rust (
.rs) - Swift (
.swift) - Kotlin (
.kt) - C# (
.cs)
Benefits
- Faster rebases - No manual intervention for simple conflicts
- Consistent results - Deterministic conflict resolution
- Reduced errors - Eliminates common merge mistakes
- Learning system - Improves resolution patterns over time
Configuration
# Enable/disable smart resolution
โก Essential Commands
# Stack Management (Multiple Stacks)
# Current Stack Operations (Shortcuts)
# Branch Management & Safety
# Or use full commands when needed:
# ๐ Automatic branch change detection: Cascade detects when you switch branches
# and prompts you to continue with current stack, deactivate, or switch stacks
# Entry Editing (Modern Convenience)
# Repository Overview
๐ก Pro tip: Use ca stack for current stack details, ca repo for everything overview.
๐ Command Reference
Stack Management
# Create and manage stacks
# List stacks
# Switch and view stacks
Entry Editing (Modern Convenience)
# Checkout specific entries for editing
# Track edit status
# Amend the current stack entry (safer than raw git commit --amend)
# Clear edit mode
๐ก๏ธ Working Branch Safety Net:
When you use ca entry amend, Cascade automatically updates your original working branch to include the amended changes. This ensures your working branch always serves as a reliable safety net/fallback, even after amending stack entries.
# Safe amend workflow:
# make changes...
# โ
Both the stack branch AND working branch are updated!
# Compare to unsafe raw git:
# โ ๏ธ Working branch becomes stale - safety net broken!
Adding Commits to Stack
# Basic push operations
# Batch operations
# Smart squash operations
# Remove from stack
Pull Request Workflow
# Submit for review
# Batch submission
# Status and management
Sync and Rebase Operations
# Sync with remote
# Rebase operations
# Rebase conflict resolution
Advanced Tools
# Interactive interfaces
# Visualization and diagramming
# Git hooks integration
# Individual hook management
# Configuration and setup
# System information
๐ง Configuration
Bitbucket Setup
# Interactive wizard (recommended)
# Manual configuration
PR Description Templates
Cascade CLI supports configurable PR description templates that automatically apply to all pull requests:
# Set a PR description template (supports markdown)
# View current template
# Remove template (fallback to --description or commit messages)
Template Behavior:
- With template configured: Template is ALWAYS used for all PRs (overrides
--description) - Without template: Uses
--descriptionargument or commit message body as fallback - Automatic stack hierarchy: All PRs automatically get a stack information footer showing the hierarchy and current position
Setup Integration:
The ca setup command includes an optional step to configure the PR template with an example template or custom content.
๐จ Advanced Features
Terminal User Interface
Launch ca tui for an interactive stack browser with:
- Real-time stack visualization
- Keyboard navigation (โ/โ/Enter/q)
- Live status updates
- Error handling and recovery
Visualization Export
# Generate diagrams for documentation
# Include in CI/CD pipeline
|
Shell Integration
# Install completions
# Check installation
# Manual installation
๐ Documentation
- ๐ User Manual - Complete command reference
- ๐ Installation Guide - Platform-specific instructions
- ๐ Onboarding Guide - Step-by-step tutorial
- ๐ง Configuration Reference - All settings explained
- ๐ Troubleshooting - Common issues and solutions
- ๐๏ธ Architecture - Internal design and extending
- ๐ Smart Force Push Strategy - How PR history is preserved
- ๐ ๏ธ Development Scripts - CI debugging and development tools
๐ค Contributing
We welcome contributions! See our Contributing Guide for details.
Development Setup
Release Process
See Release Guide for maintainer instructions.
๐ง Development
Quick Development Setup
# Clone and build
Pre-Push Validation
Always validate before pushing to GitHub! Run our comprehensive check script:
This runs all the same checks as CI:
- โ Code formatting and linting
- โ Unit and integration tests
- โ Documentation generation
- โ Binary compilation
๐ก Pro Tip: Set up a git hook to run this automatically:
# Add to .git/hooks/pre-push
#!/bin/sh
CI Debugging Tools
Having trouble with CI failures that don't reproduce locally? We have specialized tools for that:
๐ Development Scripts Guide - Complete reference for all CI debugging and development scripts
See docs/DEVELOPMENT.md for complete development guidelines, testing strategies, and contribution workflows.
๐๏ธ Architecture
Cascade CLI is built with:
- ๐ฆ Rust - Performance, safety, and reliability
- ๐ git2 - Native Git operations without subprocess overhead
- ๐ HTTP/REST - Direct Bitbucket API integration
- ๐จ TUI Libraries - Rich terminal interfaces (ratatui, crossterm)
- โก Async - Non-blocking operations with tokio
Design Principles
- Smart Force Push - Preserves review history while enabling safe rebases
- Atomic Operations - All-or-nothing state changes
- Conflict Detection - Early detection with resolution guidance
- Graceful Degradation - Continue working when services are unavailable
๐งช Testing
# Run full test suite
# Tests cover:
# - Core stack management (40 tests)
# - Git operations and safety
# - Bitbucket integration
# - CLI command functionality
# - Error handling and recovery
Test Coverage: 141 tests passing โ
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.