branchless-workflow
Git-branchless stacked diffs workflow patterns and command reference
Best use case
branchless-workflow is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Git-branchless stacked diffs workflow patterns and command reference
Teams using branchless-workflow should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/branchless-workflow/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How branchless-workflow Compares
| Feature / Agent | branchless-workflow | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Git-branchless stacked diffs workflow patterns and command reference
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Git-Branchless Workflow Git-branchless enables stacked diffs development - working with multiple commits that build on each other, editing any commit in the stack, and managing PRs efficiently. ## Core Concepts ### Detached HEAD Workflow In git-branchless, you work in **detached HEAD** mode. Main stays put while you stack commits above it. ```bash # Always detach before building a stack git checkout --detach # Or use git record -d to auto-detach git record -d -m "feat: first commit" ``` ### Smartlog Icons | Icon | Meaning | |------|---------| | `◆` | Public commit (on main branch) | | `◯` | Draft commit (your work in progress) | | `●` | Current HEAD position | | `✕` | Abandoned/hidden commit | | `ᐅ` | Current branch indicator | ## Essential Commands ### Visualization ```bash git sl # View commit stack (smartlog) ``` ### Navigation ```bash git prev # Move to parent commit git next # Move to child commit git prev N # Jump N commits up git next N # Jump N commits down git sw -i # Interactive commit selector (fuzzy finder) git sw -i <search> # Pre-filter by search term ``` ### Committing ```bash git record -m "msg" # Commit all changes (no git add needed) git record -c pr/name -m "msg" # Commit + create branch in one step git record -d -m "msg" # Detach from branch, then commit git record -I -m "msg" # Insert commit in middle, auto-rebase children ``` ### Editing Commits ```bash git amend # Amend current commit + auto-restack descendants git reword # Change commit message + auto-restack git restack # Rebase descendants onto amended commit ``` ### Moving Commits ```bash git move -s <src> -d <dst> # Move commit(s) to new parent ``` ### Syncing ```bash git sync # Rebase stack onto local main git sync --pull # Fetch remote + rebase stack ``` ### Submitting PRs ```bash git switch -c pr/name # Create branch at current commit git submit -c @ # Push current branch to remote (first time) git submit # Force-push existing branches (update PRs) ``` ### Housekeeping ```bash git hide <hash> # Hide commit from smartlog git unhide <hash> # Restore hidden commit ``` ### Recovery ```bash git undo # Undo last operation (with confirmation) git undo -i # Interactive undo — browse history ``` ## Common Workflows ### Building a Stack ```bash git checkout --detach git record -m "feat: first feature" git record -m "feat: second feature" git record -m "feat: third feature" git sl # View your stack ``` ### Fixing a Middle Commit ```bash git prev 2 # Go to the commit to fix # make changes... git add . && git amend # Amend + restack descendants git next 2 # Return to top ``` ### Creating PRs for a Stack ```bash # For each commit, create branch and submit git prev 2 git switch -c pr/first-feature git submit -c @ git next git switch -c pr/second-feature git submit -c @ git next git switch -c pr/third-feature git submit -c @ ``` ### Setting Stacked PR Base Branches For true stacked PRs on GitHub: | PR | Base Branch | |----|-------------| | pr/first-feature | `main` | | pr/second-feature | `pr/first-feature` | | pr/third-feature | `pr/second-feature` | ### After PR Merge ```bash git pull origin main git sl # Find merge commit hash git move -s <next-commit> -d <merge-commit-hash> # Recreate branches for remaining commits git switch -c pr/remaining-feature git submit -c @ ``` ### Syncing with Updated Main ```bash git sync --pull # Fetch + rebase stack git submit # Update all PRs ``` ### Recovering from Mistakes ```bash git undo -i # Browse history, find good state, restore ``` ## Interactive Rebase Operations ```bash git rebase -i main ``` In the editor: - `pick` — keep commit as-is - `drop` — remove commit - `fixup` — squash into previous (discard message) - `squash` — squash into previous (combine messages) - Reorder lines to change commit order ## Best Practices 1. **Always detach before stacking** - Use `git checkout --detach` or `git record -d` 2. **Use `git amend` instead of `git commit --amend`** - It auto-restacks descendants 3. **Use `git record` instead of `git add` + `git commit`** - Simpler workflow 4. **Run `git restack` after manual amends** - Fixes abandoned commits 5. **Use `git sync --pull` regularly** - Keep stack updated with main 6. **Create branches only when ready to PR** - Use `git switch -c` or `git record -c` 7. **Force-push updates with `git submit`** - Updates all stacked PRs at once ## Troubleshooting ### "Abandoned commits (✕) showing in smartlog" ```bash git restack # Rebase descendants onto amended commit ``` ### "git sl only shows main / no stack visible" You committed on main. Fix: ```bash git checkout --detach git branch -f main <initial-commit-hash> ``` ### "git submit @ does nothing / skipped" You need a branch AND `--create`: ```bash git switch -c pr/my-feature git submit -c @ ``` ### "Messy graph after PR merge" Move remaining commits onto merge commit: ```bash git pull origin main git sl # Find merge commit hash git move -s <next-commit> -d <merge-commit-hash> ``` ### "Conflict during restack or sync" ```bash # Resolve conflicts in files git add <resolved-files> git rebase --continue ```
Related Skills
zod
Zod schema validation patterns and type inference. Auto-loads when validating schemas, parsing data, validating forms, checking types at runtime, or using z.object/z.string/z.infer in TypeScript.
typescript-import-style
Merge-friendly import formatting (one-per-line, alphabetical). Auto-loads when writing TypeScript/JavaScript imports to minimize merge conflicts in parallel development. Enforces consistent grouping and sorting.
setup-mcp-auth
Configure authentication for an existing FastMCP server
fastmcp
FastMCP TypeScript framework patterns for MCP servers. Auto-loads when building MCP servers, creating tools/resources/prompts, implementing authentication, configuring transports, or working with FastMCP in TypeScript.
add-mcp-tool
Add a new tool to an existing FastMCP server with guided configuration
add-mcp-resource
Add a new resource or resource template to an existing FastMCP server
plan-with-team
Validate plan file ownership
privacy-compliance
GDPR, CCPA, and privacy compliance guidance for data protection. Use when handling personal data, implementing consent management, or ensuring regulatory compliance across jurisdictions.
oauth
OAuth 2.0 and OpenID Connect implementation patterns. Use when implementing authentication, authorization flows, or integrating with OAuth providers like Google, GitHub, or custom identity providers.
mcp-security
Use when securing MCP servers, preventing prompt injection, implementing authorization, validating user input, or building secure multi-agent pipelines. Provides 5-layer defense architecture patterns.
rag-cag-security
Security patterns for RAG and CAG systems with multi-tenant isolation. Use when building retrieval-augmented or cache-augmented generation systems that require tenant isolation, access control, and secure data handling.
chunking-strategies
Document chunking strategies for RAG systems. Use when implementing document processing pipelines to determine optimal chunking approaches based on document type and retrieval requirements.