Supercharge Your Workflow with Git Worktrees and Claude Code

Kunal Singh

Apr 6, 2026

Most developers context-switch. You are mid-way through a feature, a bug comes in, you stash, switch branches, fix the bug, switch back, pop the stash, and try to remember where you were. It is friction. Small, constant, invisible friction that compounds across a day.

Git worktrees combined with Claude Code eliminate this entirely. You can run multiple agents on the same repository in parallel, each working on a different task, without any of them knowing or caring about the others.


What is a Git Worktree

A git worktree is an additional working directory linked to the same repository. It shares your .git folder, which means it has access to the full history, all branches, and all configuration. But it operates independently — its own branch, its own files on disk, its own terminal context.

You can have as many worktrees as you want. They live in separate directories, and they do not interfere with each other.


What This Looks Like in Practice

Your repository lives at ~/projects/my-app. You add two worktrees:

~/projects/my-app-auth       → branch: feature/auth
~/projects/my-app-dashboard → branch: feature/dashboard
~/projects/my-app-bugfix → branch: fix/api-timeout

You open a terminal in each directory, start Claude Code in each one, and assign a task. All three agents work simultaneously. When each is done, you review and merge the branches as normal.


Setting It Up

Step 1 — Create worktrees from your main repo

# From your main project directory
git worktree add ../my-app-auth -b feature/auth
git worktree add ../my-app-dashboard -b feature/dashboard
git worktree add ../my-app-bugfix -b fix/api-timeout

Each command creates a new directory with the full working tree checked out on the specified branch.

Step 2 — Open Claude Code in each worktree

# Terminal 1
cd ../my-app-auth && claude

# Terminal 2
cd ../my-app-dashboard && claude

# Terminal 3
cd ../my-app-bugfix && claude

Step 3 — Assign tasks and let them run

Give each Claude Code session its task. You can stay in one terminal, check progress, steer, and come back to others. All three agents run independently with their own full context of the project.

Step 4 — Clean up when done

# After merging a branch, remove the worktree
git worktree remove ../my-app-auth

# List all active worktrees
git worktree list

Why This Works So Well with Claude Code

A normal Claude Code session has context about one working directory. It reads files, makes edits, runs commands, all scoped to that folder. Worktrees are just folders. Each session gets its own isolated environment with no awareness of what the other sessions are doing.

This matters because:

  • No merge conflicts mid-task. Each agent works on its own branch.
  • No context bleed. Session 1 working on auth does not pick up changes from session 2 working on the dashboard.
  • Full parallelism. You are not waiting. All agents work simultaneously.
  • Easy review. When each task is done, you get a clean branch and a clean diff.

A Real Workflow Example

Say you have three things to do today:

  1. Add OAuth login
  2. Build a new analytics dashboard
  3. Fix a timeout bug in your API

Without worktrees, these are sequential. You work on one, finish or pause, then start the next.

With worktrees and Claude Code, you set all three up in five minutes. You hand off each task to an agent with enough context, then you review output, test, and merge. Your role shifts from writing to steering and reviewing.

The three tasks that would take a full day become a focused few hours.


Tips

Use descriptive directory names. Name your worktree directories after the branch so you always know what is in each folder at a glance.

Keep a notes file per session. Drop a TASK.md in each worktree describing what the agent is working on. It helps Claude Code stay on track and helps you remember context when you return.

Do not share worktrees between sessions. One Claude Code session per worktree. Sharing a directory between two agents is asking for chaos.

Use git worktree list often. It gives you a clean overview of everything that is active, what branch it is on, and where it lives on disk.

Clean up after merging. Stale worktrees accumulate. Make it a habit to git worktree remove after you merge and delete the branch.


The Shift in How You Work

The real change is not speed, though you do move faster. The real change is that you stop being blocked. While one agent handles something deep and slow, you are reviewing, testing, or steering another. The bottleneck moves from writing and waiting to thinking and deciding.

That is where you should be spending your time anyway.


Quick Reference

# Add a new worktree on a new branch
git worktree add <path> -b <branch-name>

# Add a worktree on an existing branch
git worktree add <path> <branch-name>

# List all worktrees
git worktree list

# Remove a worktree (after merging)
git worktree remove <path>

# Remove worktree references that no longer exist on disk
git worktree prune

If you have not tried this setup yet, the overhead is two minutes. The payoff starts immediately.

Recommendations

HAR Files: Your Secret Weapon for Debugging Production Issues

#debugging

,

#web

,

#har

,

#devtools

,

#performance

How to use HAR files as a practical, zero-setup tool for debugging...

Jan 23, 2026

Building a Practical Backend Error Mapper for Frontend Applications

#React

,

#TypeScript

,

#Error Handling

,

#Frontend Development

,

#Best Practices

Learn how to build a clean, extensible error mapping system that transforms...

Jan 18, 2026

i18n vs l10n: What Developers Need to Know

#i18n

,

#l10n

,

#internationalization

,

#localization

,

#web development

,

#javascript

,

#react

,

#frontend

A practical guide to internationalization and localization for developers. Learn...

Dec 25, 2025

Things to Do as a Frontend Architect: A Complete Guide

#Frontend

,

#Architecture

,

#JavaScript

,

#Web Development

,

#Best Practices

,

#Leadership

,

#Performance

,

#Developer Experience

A comprehensive guide to the responsibilities, tasks, and best practices for...

Dec 15, 2025

Understanding CRDTs: The Magic Behind Collaborative Editing

#CRDT

,

#Collaborative Editing

,

#Distributed Systems

,

#Real-time

,

#Tech Explained

A friendly deep dive into CRDTs and how they power real-time collaborative...

Oct 20, 2025

React Composition Patterns: Beyond Boolean Props

#React

,

#JavaScript

,

#Web Development

,

#Component Design

,

#Software Architecture

Learn how React compound components and composition patterns can help you escape...

Oct 6, 2025

10 Vue Debugging Tips That Will Transform Your Development Workflow

#Vue.js

,

#Debugging

,

#JavaScript

,

#Frontend

,

#DevTools

,

#Development

,

#Web Development

,

#Vue DevTools

Master Vue.js debugging with 10 battle-tested techniques from real developers....

Aug 26, 2025

Building a Cross-Repository Test Automation Pipeline: From Manual QA Nightmares to Automated Excellence

#automation

,

#testing

,

#CI/CD

,

#GitHub Actions

,

#Playwright

,

#SDK

,

#engineering

,

#DevOps

Learn how to build a cross-repository test automation pipeline that reduced our...

Aug 20, 2025

JavaScript Performance Optimization, 10 Techniques That Actually Move the Needle

#javascript

,

#performance

Discover 10 JavaScript performance optimization techniques that deliver real,...

Aug 18, 2025

Building a Blog Publisher MCP Server to Automate Your Content Workflow with Claude

#MCP

,

#Claude

,

#Automation

,

#TypeScript

,

#GitHub

,

#Blogging

,

#Tutorial

,

#AI Tools

Learn how to build a custom MCP server that lets Claude publish and manage blog...

Aug 7, 2025

20 JavaScript Interview Questions You Should Know in 2025

A practical guide to 20 core JavaScript interview questions — with clear...

Jul 24, 2025

Building a Simple, Scalable Feature Flag System

#nextjs

,

#prisma

,

#feature-flags

,

#fullstack

,

#backend

,

#api-routes

,

#clean-architecture

,

#scalable-design

,

#product-rollout

Built a simple yet scalable feature flag system using Next.js API routes and...

Jul 6, 2025

I Refactored Without Changing a Feature — And It Broke Everything

#HyrumsLaw

,

#Refactoring

,

#LegacyCode

,

#CodeSmells

,

#TechDebt

,

#SoftwareEngineering

,

#CleanCode

Understanding Hyrum’s Law with a Real-World Lesson on Porting vs Refactoring

Jul 5, 2025

How to Publish Your First npm Package: Creating Rainbow Highlight with Utilities

#npm

,

#npm-package

,

#web

,

#javascript

Learn how to create and publish your first npm package. This step-by-step guide...

Sep 22, 2024

Google Dorking: Unlocking Hidden Search Capabilities & Insights

#seach

,

#seo

,

#research

Explore 16 advanced Google Dorking techniques to uncover valuable data, security...

Aug 8, 2024

This One HTML Attribute Could Save Your Web App from a Security Nightmare

#web-security

,

#cdn

,

#web

Web security is a critical concern for developers, yet some of the most...

Jun 29, 2024

Are You Still Using Basic CSS? Here Are 7 Tricks to Get Ahead of the Curve

#css

Bored of the same old CSS? Unleash 7 hidden gems to take your designs to the...

Dec 27, 2023

Easiest way to store your logs in a file WITHOUT chaging the source file(node)

#productivity

Often, developers face challenges when dealing with a flood of logs in the...

Dec 21, 2023

Build Your Own Pinterest-Style Masonry Grid: A Step-by-Step Guide

#css

,

#web

,

#layout

Create a masonary grid layout with left to right content flow, supporting...

Dec 10, 2023

Using git diff and git apply to Share Local Changes with Peers

#git

,

#productivity

,

#software_engeneering

,

#dev

git diff and git apply are two powerful Git commands that can be used to share...

Nov 12, 2023

React Portals: Render Components Outside the current DOM Hierarchy

#react

,

#web

The createPortal API in React allows you to render child elements into a...

Jul 27, 2023

Cloning Made Easy: Try degit and Clone Directories within Repos.

#git

,

#productivit

Have you ever faced the dilemma of wanting just a small portion of a repository,...

Jul 19, 2023

Debugging Web Apps with Browser Dev Tools: 6 Amazing Tricks

#browser

,

#debugging

,

#web

Debugging web applications can be a challenging task, with errors like...

Jul 13, 2023

Controlled Versus Uncontrolled Components in React

#react

,

#forms

Understanding State Management Within Forms Comparing controlled and...

Nov 5, 2022

Format Numbers, Dates and Currencies with the Intl Object in Javascript

#javascript

,

#html

,

#web

Intl object can be used to format data into commonly used formats of dates,...

Sep 13, 2022

Image Masking on Hover Using CSS Clip Path and Javascript

#javscript

,

#css

,

#html

Image Masking can be used to add fancy hover highlight effects to images for...

Jul 23, 2022

Recreating CSS Tricks Fancy Grid Hover Effect

#html

,

#css

,

#UI

,

#recreation

CSS Trick had a simple yet cool grid layout which I found dope. So lets try to...

May 21, 2022

File Explorer Recursive React Component

#react

,

#javascript

,

#web

How to create a recursive folder Component using react.

Apr 16, 2022

Add Google Fonts to Your React & NextJS + TailwindCSS Project (Next 14)

#css

,

#tailwindcss

,

#react

,

#nextjs

,

#tailwind

,

#design

Use Google Fonts in Your TailwindCSS Projects

Apr 6, 2022

Event Delegation in Javascript

#javscript

,

#css

,

#html

,

#web

,

#performance

Handling multiple Events in Javascript with minimal CPU Usage

Mar 6, 2022

A Simple Web Accessibility Trick that you most probably missed!

#html

,

#css

,

#web-accessibility

,

#user-experience

Imagine that you cannot use the mouse and have to Navigate a Website with the...

Dec 23, 2021

Top Terminal Commands I Use For Productivity

#linux

,

#cli

,

#terminal

The whole point of development is solving problems. But very often we Developers...

Nov 3, 2021

CSS Logical Properties

#css

,

#html

CSS logical properties are properties which are used to design element on the...

Oct 5, 2021

Fluid Typography in CSS 💧

#css

,

#html

,

#typography

CSS Best Practices in Fluid Typography

Aug 15, 2021

CSS Units in a Nutshell 🐚

#css

,

#html

Are you still writing your css units in pixels and percentages? if you are then...

Aug 8, 2021

Master Markdown in 5minutes ⌚

#markdown

,

#documentation

Markdown is a lightweight markup language for creating formatted text using a...

Aug 1, 2021

What is JAMStack ✨

#jamstack

Jamstack stands for Javascript APIS and Markup and it is based on this idea of...

Jul 31, 2021

+

Check my latest Blog Post

Supercharge Your Workflow with Git Worktrees and Claude Code

Read Now
Oh My Gawwdd!!!!!!!

Wow you have been viewing my site since 20 seconds!

+
+