HomeVideos

I'm using claude --worktree for everything now

Now Playing

I'm using claude --worktree for everything now

Transcript

237 segments

0:00

introducing built-in Git work tree

0:02

support for claude code. Now agents can

0:04

run in parallel without interfering with

0:06

one another. Each agent gets its own

0:07

work tree and can work independently.

0:09

Now this is really really sweet and I'm

0:12

kind of excited to show you my first

0:14

impressions, my first time trying this

0:16

and the thoughts I immediately have as

0:18

soon as I see this post. I've known

0:19

about work trees for many many years but

0:22

rarely actually ever use them. Probably

0:24

quite similar to you but I've never

0:25

actually taken the leap to integrate it

0:27

with clawed code. So having it built in

0:29

in theory just makes it super duper

0:31

easy. So let's test it out and see

0:32

what's going on with it. So I am now

0:34

inside my main work repo which is my

0:36

course video manager. And inside here

0:38

I'm going to run git status. And you can

0:40

see here I'm on my main branch. Now I'm

0:42

going to run a second command which is

0:43

get workree add UI updates. And when I

0:47

run this and we can see actually inside

0:49

the explorer here that a new folder has

0:53

been created called UI updates. And now

0:55

if we cd into there, if we see cd UI

0:58

updates inside here and run git status,

1:01

we can see it's on a branch called UI

1:04

updates. So this new folder has a

1:06

separate git state essentially like it

1:09

can be on a separate branch from the

1:11

main branch. Now inside this UI updates

1:13

folder, I'm going to call touch fooar.md

1:16

here and create a new file called

1:18

fooar.md. And one thing you'll notice is

1:20

if you're inside VS Code or probably

1:22

cursor too, is that inside your source

1:24

control panel, you now have the main

1:26

repo for the course video manager,

1:28

that's the main branch. And then this

1:30

one, you actually see your work tree

1:32

too. And we can see that there are some

1:34

changes inside the UI updates. I can

1:36

then stage this and actually commit it

1:38

to the UI updates branch. New fooar.md

1:42

inside here with VS Code. Of course, I

1:44

can publish the branch up here and even

1:46

make a PR to the original branch all

1:49

within this same nice UI and without

1:51

ever leaving my IDE. Once I'm done with

1:54

this, I can then just Okay, maybe we

1:56

merge this pull request. That looks

1:58

really nice. Now, I can open up source

2:00

control again and I can refresh inside

2:03

here and attempt to pull down any

2:05

changes. So, if I go I'll just cd back

2:08

into the main directory. I'll go get

2:11

pull and I should now have a fooar

2:14

inside my actual main directory which is

2:17

just

2:19

where's it gone? Where's it gone?

2:20

Where's it gone? There it is. fooar.md

2:22

inside the main branch of my repo. Now

2:24

that I'm done with that work tree, I can

2:26

either simply remove it just by running

2:29

uh rimf UI updates or I can run git

2:32

workree remove UI updates as well. I'm

2:36

fairly sure that does kind of the same

2:37

thing. Now, if we go back in and we look

2:39

inside the source control again, we now

2:41

just have a single um work tree

2:43

available, which is our main work tree.

2:45

So, work trees are a super convenient

2:46

way that you can have multiple branches

2:49

of something checked out on your machine

2:50

at once. And the tooling in your IDE, if

2:53

it's good, like VS Code is, will pick it

2:55

up and allow you to modify them

2:56

independently or of course you can do it

2:58

from the terminal as we were doing

2:59

there. So, let's now test out the clawed

3:01

version of this where we're going to run

3:02

clawed

3:04

workree like this. Now what this does is

3:06

it creates the work tree

3:08

atclaude/worktrees

3:10

cheerful coalescing worth. So it has

3:12

created the the work tree with a kind of

3:14

random funny name. Here we can see the

3:17

work tree in the same way that we did

3:18

before. So it's just using git work tree

3:20

under the hood. And now inside here we

3:22

can actually tell it uh delete the

3:24

fooar.md file. It's now searching for

3:27

the file and it's going to run remove on

3:30

it to get rid of it. fubar.mmd has been

3:33

deleted which we can see on the work

3:35

tree. That's very nice. Commit this.

3:37

That looks good. Again, it's doing some

3:39

git status, doing some git log. It's

3:41

adding the file, then committing the

3:43

file, and then I'm going to push it up

3:44

and make another PR to remove it.

3:46

Though, to be honest, you can kind of

3:47

see by now that Claude is really just

3:48

doing the same setup as we had before.

3:51

It's just automatically naming you a

3:53

branch and things like that. When I quit

3:55

out of here, so let's say I do Ctrl + C

3:57

a couple of times, I then get the option

3:58

to keep or remove the work tree. If I

4:01

remove the work tree and I haven't

4:02

pushed my work, then all of my changes

4:03

or my commit history will be lost. But

4:05

instead, I'm actually going to push this

4:07

up. So, it's going to actually push up

4:09

the work. And then I should get the

4:11

option to let's say let's say I'll

4:14

remove the work tree for now. That makes

4:15

sense. Okay, I've just had my first

4:16

paper cut with this actually, which is

4:18

it's not behaving how I expected on the

4:20

branch. It seems that when it created

4:22

the work tree, it actually made the

4:24

commit against main. Look, if I run get

4:27

status here, you can see we're on main.

4:29

And then when I run git log, you can see

4:30

the commit in the history where it

4:32

deleted fooar on main. So it seems like

4:34

git work tree doesn't behave in quite

4:36

the same way as the clawed work tree

4:38

does because on clawed hyphen work tree,

4:41

it seems like I might have to specify

4:43

something else in order to get it to

4:45

work on a separate branch. Okay, I've

4:47

just been doing some more experiments

4:48

here and hopefully I've landed on a

4:50

solution or at least I understand more

4:52

what's going on. Now I started a new

4:53

session and I said add a new file called

4:55

fubar.mmd. Commit it and push it to the

4:57

branch. It wrote the file. It then did

4:59

some git status. We can see it's on a

5:01

branch work tree delightful dazzling

5:03

sketch and the branch is up to date with

5:06

origin main. So it looks like the source

5:08

of the branch or at least sort of what

5:09

it thinks it is is main even though

5:12

we're on a different work tree. People

5:14

who understand work trees better than I

5:16

do probably can understand this uh more

5:18

than I can. But that's what I'm seeing

5:20

at least. It then get added and get

5:22

committed and it attempted to get push.

5:24

I have a safety hook that blocked the

5:26

push here, but it gave me a command to

5:28

run. It said, should I proceed with git

5:30

push origin workree delightful dazzling

5:32

sketch. I then ran this. So, I ran git

5:34

push origin work tree delightful

5:36

dazzling sketch. And it created a new

5:39

branch here with that name. So, this is

5:40

a really important thing. If you're

5:42

using claude work trees, your agent

5:44

needs to push with a specific uh name

5:47

branch. Otherwise, by default, it's

5:49

going to be the one that it created the

5:52

work tree from. in this case main. To

5:54

put that another way, if your main

5:55

branch is not protected and you create a

5:56

work tree from it, you might end up

5:58

accidentally pushing commits to main

6:00

when you wanted to push them to a

6:01

separate branch. Either way, this is

6:02

fine and something you can probably

6:04

prompt for as well. So, I don't hate it.

6:05

Overall, I really like the way that git

6:07

work trees are like totally managed by

6:09

Claude here. It means that the life

6:11

cycle of each work tree can be tied down

6:13

to a single agent and its work, which is

6:15

very, very appealing. I'm not sure why

6:16

you wouldn't want to use git work trees

6:19

like every single time you use claude

6:21

because it just means that you can

6:22

guarantee that every single time you

6:24

have an idea or you want to do something

6:26

you can just like instantly ping up a

6:29

new work tree get things working and

6:31

just like ping that back to main as a

6:33

PR. It basically makes parallelization a

6:35

lot more free than it was before which I

6:38

really like. Another thing I'm intrigued

6:40

by from the announcement is the fact

6:41

that sub agents now support work trees

6:43

as well. So you can just very simply

6:45

spin up a sub agent, get it to make a PR

6:47

back to main and just have that kind of

6:49

orchestrated from above, which just

6:50

seems really really nice. Though it does

6:52

seem like something you have to opt into

6:54

to say ask claw to use work trees for

6:56

its agents. It won't do this

6:57

automatically. It seems like I'm really

6:59

really excited to try this and work with

7:00

this more. And I think it's just going

7:03

to offer so many free parallelization

7:05

opportunities. And I just love it when a

7:07

tool kind of absorbs the complexity of

7:09

another tool into itself and helps you

7:11

manage its life cycle. That's great.

7:13

Love all that. Right now, I'm working on

7:15

a Claude Code course, which the landing

7:17

page and the price and stuff and all of

7:19

the syllabus is going to come up pretty

7:21

soon. And this is definitely going to be

7:23

on it. I really believe that AI coding

7:25

is not that different from human coding.

7:27

It's just that you need to be a lot more

7:29

aware of the constraints and you need to

7:31

be able to teach the AI about all the

7:33

fundamentals that we've known for 30

7:34

years. And so the course is going to be

7:36

about reintroducing those fundamentals

7:38

like TDD, like uh effective

7:40

parallelization, like planning in a

7:42

decent way where you get feedback

7:43

quickly, all of that stuff and just

7:45

taking that into the AI era. So thanks

7:47

for following along and I will see you

7:49

very soon. Anyway, if you like the sound

7:50

of all that, I talk about all that on my

7:52

newsletter as well, which is free, which

7:53

is great obviously, and you can find

7:55

that at the link below.

Interactive Summary

The video introduces Claude Code's new built-in Git work tree support, enabling multiple agents to work in parallel on independent branches without interference. The speaker demonstrates manual Git work tree creation and management in VS Code, then explores Claude's automated integration. A notable 'paper cut' is identified: Claude's work trees, by default, might commit to the 'main' branch if not explicitly instructed to push to a separate branch. Despite this, the speaker is highly positive, emphasizing the feature's benefits for parallelization, agent workflow management, and sub-agent support, which simplifies complex Git operations for AI-driven development.

Suggested questions

5 ready-made prompts