HomeVideos

How I use Claude Code for real engineering

Now Playing

How I use Claude Code for real engineering

Transcript

326 segments

0:00

What's up, friends? Uh, we're going to

0:01

do a little bit of a different kind of

0:02

video. I've been working a lot with

0:04

Claude Code recently. I've been getting

0:05

a lot of questions on how I use it. And

0:07

so, I just sat down to do a little bit

0:08

of work and I realized this is actually

0:10

a really good opportunity to show a

0:12

complicated multi-phase plan with Claude

0:15

Code. The only thing I've done so far is

0:17

I've written this prompt here. I'm doing

0:19

a bit of work to add a CLI command to an

0:22

internal CLI that I have to do with my

0:24

AI hero courses. But what I'm doing is

0:26

less important than how I'm doing it.

0:28

All you really need to know is this is a

0:30

pretty large feature that will go

0:32

probably beyond a single context window.

0:35

I have here an initial prompt that I've

0:37

put in. I haven't really put too much

0:39

thought into this. The way I produced

0:40

this was I just talked into my

0:42

microphone and used a dictation tool to

0:44

dictate it in. And I've also activated

0:46

plan mode here by tabbing or shift

0:48

tabbing through until I hit plan mode in

0:50

the bottom left. Whenever I embark out

0:52

on a big piece of work, I'm always

0:55

thinking about creating a plan first.

0:57

Let's get this running. and I can

0:58

actually talk through while it's going.

1:00

So this plan is basically is sort of

1:02

forcing Claude code to explore the

1:05

codebase first. We can see it's kicked

1:06

off an explore sub agent task to explore

1:09

the current CLI structure in the

1:11

codebase. It's also doing some searching

1:13

here, just searching different files,

1:15

searching different patterns. And what

1:16

I'm waiting for it to do is to figure

1:18

out anything that's unclear from my

1:20

specification and give me back some sort

1:22

of plan. Again, we can see it's doing a

1:24

lot of stuff here. It's reading

1:25

different files. It's doing some other

1:27

stuff. Let me check the structure for

1:28

explainer solution folders. And now this

1:30

is really cool. It's come back with some

1:32

clarifying questions. What is the part

1:34

of the project repo where you want to

1:35

get commit diffs from? I'm going to make

1:36

it a CLI option. I just pressed return

1:39

to choose that one. It's asking whether

1:40

I wanted to use a positional argument or

1:42

a required option. I'm going to choose a

1:44

required option. And it's now asking me

1:45

a really specific question about my

1:47

implementation like should it match

1:48

exercise numbers strictly or flexibly?

1:50

I'll choose flexible. And again, it's

1:52

asking a clarifying question here. What

1:54

does the 01 represent? It represents the

1:56

sequence of the diff. This is basically

1:57

a multi-step form and then I end up with

1:59

the submit. I'm ready to submit my

2:00

answers. Let's go. All right. It has now

2:02

come back with a plan. Now, this plan

2:05

might look a little bit different from

2:06

the plans that you tend to get from

2:08

Claude code. The first thing is it's

2:10

extremely concise. Here we have a fair

2:12

few sections, but the stuff inside those

2:14

sections is pretty easy to read. This is

2:16

because I have this configured like that

2:18

in my rules, which we'll look at in a

2:19

moment. We have a new file, get

2:21

diffs.ts, ts and in updated file that

2:23

seems fine and it's created some

2:25

implementation steps here too. The

2:27

crucial thing though and I have this set

2:28

up in my rules too is it's given me some

2:30

unresolved questions and I get to choose

2:32

whether I want to auto accept the edits

2:34

uh manually approve the edits or keep

2:35

planning. I'm going to escape out of

2:37

this for now just so I can show you

2:38

what's in my rules file. You can call

2:40

this command memory and you can

2:42

basically be taken to your user memory

2:44

or project memory. This is what my user

2:46

memory looks like. It's really not very

2:48

long, only about 43 lines. I've given it

2:50

just some very light hints about what I

2:52

want. The crucial thing though is to say

2:55

in all interactions and commit messages,

2:56

be extremely concise and sacrifice

2:58

grammar for the sake of concision.

3:00

That's why that plan is so concise and

3:02

easy to read is because of this topline

3:05

rule. And it's 100% my favorite thing

3:07

I've added to rules and I'm never taking

3:09

it out. There's some stuff in here

3:10

that's specific to my workflow like PR

3:12

comments, like change sets as well,

3:14

which I use in quite a few repos. I've

3:16

already said that your primary method

3:18

for interacting with GitHub should be

3:19

the GitHub CLI. When creating branches,

3:21

prefix them with Matt to indicate they

3:23

came from me. Very, very light stuff,

3:24

but here's the one we're seeing here,

3:25

which is at the end of each plan, give

3:27

me a list of unresolved questions to

3:29

answer, if any, and again, make the

3:30

questions extremely concise. Sacrifice

3:32

grammar for the sake of concision. This

3:33

is why then we're getting this list of

3:35

unresolved questions right at the point

3:37

where we can see them. So, I'm now going

3:38

to dictate my answers to these questions

3:40

into this box. I'll just do the first

3:42

question just so you get the idea. Yep,

3:44

you can overwrite existing diff files.

3:45

That's absolutely fine. And thanks to my

3:46

dictation tool, this ends up there.

3:48

Okay, I've now got my full answers to

3:50

those questions. Let's submit it. And

3:51

it's going to continue creating another

3:53

plan. Notice how we haven't written any

3:55

code yet. This is all just planning

3:57

before we dive into code. Okay, it's now

3:58

given me a plan without any unresolved

4:00

questions. But my Spidey senses are

4:02

tingling here. And I've got a feeling

4:04

this is a pretty large piece of work.

4:06

And if this piece of work is too large,

4:07

it's going to overrun the context window

4:10

of the LLM. It's going to be much better

4:12

going forward if I break this into a

4:14

multi-phase plan that I can split over

4:16

multiple context windows. So, I'm

4:18

actually going to say no, keep planning,

4:19

and then make the plan multi-phase. Make

4:22

the plan multihase is really, really

4:24

nice because it's going to tell Claude

4:26

to break this down into a set of

4:28

implementation steps. And now we have

4:30

our multi-phase plan. Beautiful. Now, at

4:33

this point, I'm starting to get a little

4:34

bit nervous about my context window.

4:36

Like, that's a paranoia that I have. And

4:38

I'm just going to go and exit out of

4:39

there and just check my context and see

4:41

how it's doing. We can see that so far

4:43

we have 83.7 free space. That's feeling

4:46

pretty good. We've only used about 33k

4:48

tokens. Lovely. So I think having had

4:50

all the exploration and now having this

4:52

plan in memory, we can then start

4:55

executing the plan. So I'm going to swap

4:57

to autoaccedit and I'm going to say uh

5:00

execute phase one. Let's go. Okay, we've

5:03

had our first little paper cut which is

5:05

it still thinks it's in plan mode. I

5:07

just say crack on please with phase one.

5:11

Lovely stuff. While it's doing its

5:12

thing, we should talk about this little

5:14

status line down the bottom. I have this

5:15

customized so it shows which repo I'm in

5:18

relative to my repos folder. It also

5:20

shows which branch I'm on and how many

5:22

staged, unstaged, and new files I have

5:25

inside the current repo. It's already

5:27

asking me to build the project. That's a

5:28

good sign. And I'm going to say yes and

5:30

don't ask again for PNPM build commands.

5:32

I'm not going to review it as it's

5:33

going. I'm just going to review it ah

5:35

when it gets to the end. So, what I want

5:36

to do now is open it up in VS Code to

5:38

have a look at the files and just see if

5:40

there's anything I need to tweak. I'm

5:41

actually going to exit out of Claude

5:43

here by pressing control C twice. I'm

5:45

just going to run code dot. And now I do

5:47

want to get Claude back into this

5:49

terminal. So, I'm just going to say

5:50

Claude continue. And Claude will now

5:52

pick up our conversation where we left

5:54

off. It's a really nice little flow if

5:56

you just want to X out of Claude, run a

5:58

CLI command, and then go back. So, now I

5:59

can just use the, you know, standard git

6:01

diff viewer that we're all used to just

6:03

to see what's going on here. I can see

6:04

that it's added get diffs.js. That's

6:06

nice. And it's added this to internal.

6:08

There is a TypeScript error there, but

6:09

shocker, it was actually there before.

6:11

And I'm not entirely sure how to fix it,

6:13

and I can't be asked. You can also see

6:14

it's left in here a to-do for phase 2,

6:17

which is really nice. It means that when

6:18

we go to phase 2, we actually have a

6:20

hint in the code where it's going to

6:22

execute it. So, this all looks good.

6:23

What I like to do is either commit these

6:25

changes or just stage them so it's

6:27

really clear between phases what's been

6:29

added. If we go back to Claude, let's

6:30

have a quick check on context. Yeah,

6:33

phase one only used like 3k tokens. So,

6:35

we can absolutely crack on with phase

6:38

two and I'm going to leave it accept

6:40

edit on. Now that we've done the

6:42

planning, we can be pretty aggressive

6:43

with accept edits on because we

6:45

understand the implementation a bit and

6:47

we kind of get what's going on. Phase

6:48

two is complete and I'm reviewing it and

6:50

it looks pretty nice. A quick check on

6:52

context. We are in a very healthy place.

6:54

Let's do phase three, please. Something

6:56

I really wish that Claude code would add

6:58

is to just add the amount of tokens that

7:00

I've used so that I can put it in my

7:02

status line. That would mean I wouldn't

7:03

need to keep running context. I would

7:05

just have it right there, which is

7:06

something that cursor does really really

7:08

well actually. So phase three is

7:09

complete and what I accidentally did was

7:11

went into the file and pressed save and

7:13

an auto formatter ran and it did a

7:15

little couple of changes. When that

7:16

accidentally happens, the claw code

7:18

doesn't know anything about it. So I do

7:20

like to tell it and being very direct

7:21

with it as well. pull the files into

7:23

your context. And note how it in

7:25

followed my instructions really well. It

7:27

didn't do anything. It just literally

7:28

read a file again. So, our context is in

7:31

a pretty healthy place. And I'm pretty

7:32

sure we're going to be able to get to

7:34

the end of this feature without actually

7:36

needing to reset the context window. But

7:38

I want to show you what it's like when

7:40

you do reset the context window. The

7:41

cool thing about having a multi-phase

7:43

plan is that we can preserve it between

7:45

different context windows and the LLM

7:47

should have all the information it needs

7:48

to carry it on. But the question is

7:50

where do we actually store it? Do we put

7:52

it in a local file or do we do something

7:54

else with it? What I like to do is

7:56

actually keep these as GitHub issues and

7:58

I've said to it make a GitHub issue

8:00

containing the current plan including

8:01

all of the items that you've checked off

8:03

the plan list. This is calling GH issue

8:05

create with this plan in the description

8:07

of the issue. Everything's been checked

8:09

off for all of these phases except for

8:11

phase four and five. I'm happy with this

8:13

so I'll accept this. And now that I have

8:15

this asset outside of my context window,

8:18

I can feel happy clearing it. And this

8:20

means if I run context now, we now have

8:22

virtually nothing in the context window.

8:24

No messages whatsoever. We're down to

8:26

16K tokens just from our memory files,

8:29

the system tools, and the system prompt.

8:30

So I'm now going to ask it get the

8:33

GitHub issue 24 and enact phase 4 of

8:36

that plan. Now I'm deciding in my head,

8:38

do I want to go for accept edits on or

8:41

do I want to go for plan mode? because

8:43

plan mode basically forces it to do a

8:45

little bit of exploration and the

8:46

exploration might be necessary because

8:48

we've completely cleared out the

8:50

context. I think though I'm going to go

8:51

for accept edits on and basically just

8:54

get it to take the information from the

8:56

plan and get going. You can see it's

8:57

asking to view an issue and I'm happy to

8:59

say don't ask again. Issues are fine to

9:01

view. Okay, it hasn't done so much

9:03

planning or like codebase exploration

9:05

here, but it has read the correct file

9:07

and it's now implementing the correct

9:08

stuff, I think. Yep, that's actually

9:10

looking really nice. Let's now do phase

9:12

five. And of course, because it's

9:13

already fetched the GitHub issue, it

9:15

doesn't need to fetch it again. It's

9:16

still just in the context window. So

9:18

this process then of splitting work into

9:20

phases is really, really important. You

9:22

don't have to put each phase into a

9:24

separate context window. You can do as

9:26

many phases as you like, checking the

9:28

context window as you go. And I really

9:30

like keeping these assets in the cloud

9:32

because then actually people can comment

9:34

on them, add stuff overnight, add stuff

9:36

async. And I find this flow is a really

9:38

nice combination of letting the AI go

9:41

and do its work on accept mode and

9:43

having a lot of upfront thinking, doing

9:45

lots of thought via planning. And this

9:48

is currently how I'm doing all of my

9:49

coding, not only for AI hero stuff, but

9:51

also for Everite. And I think my top

9:53

tips are make sure that in your memory

9:55

file you have a tip to be extremely

9:57

concise. Get it to produce unresolved

9:59

questions at the end of each plan. And

10:01

get it to use the GitHub CLI to create

10:02

issues so you can share context across

10:05

multiple context windows. Thanks for

10:06

watching. This ended up being a pretty

10:08

chunky video and I will see you in the

10:10

next one.

Interactive Summary

The video demonstrates an efficient workflow for managing complex coding tasks using Claude Code. The creator emphasizes the importance of 'plan mode' for upfront architectural thinking, maintaining concise custom rules to keep LLM responses readable, and breaking large features into multi-phase plans to avoid context window exhaustion. A key part of the workflow involves persisting these plans in GitHub issues to allow for context resetting, ensuring the AI can pick up tasks across different sessions effectively.

Suggested questions

4 ready-made prompts