1
00:00:00,000 --> 00:00:03,360
So, uh, I was looking at this classic
monorepo problem, right?

2
00:00:03,380 --> 00:00:07,360
You, you spin up Claude Code in a massive
project, and everything is,

3
00:00:07,440 --> 00:00:11,280
is sweet until you dynamically load a new
subdirectory mid session.

4
00:00:11,373 --> 00:00:18,000
Maybe you, you run slash add dir, or, or
some SDK register_repo_root control

5
00:00:18,050 --> 00:00:19,040
request kicks in.

6
00:00:19,200 --> 00:00:24,000
And, and boom, your agent is suddenly
completely, like, blind to that local

7
00:00:24,064 --> 00:00:24,720
toolchain.

8
00:00:24,853 --> 00:00:28,000
It, it has no idea it just walked into a
different world.

9
00:00:28,179 --> 00:00:33,000
Wait, so why do the usual hooks like
SessionStart or CwdChanged not,

10
00:00:33,539 --> 00:00:34,960
uh, why do they not just handle that?

11
00:00:35,139 --> 00:00:38,199
Like, if the working directory changes,
why does it not pick it up?

12
00:00:38,390 --> 00:00:40,429
Ah, well, that is the catch, mate.

13
00:00:40,909 --> 00:00:44,690
See, when you add a directory dynamically,
the session has already started,

14
00:00:44,769 --> 00:00:44,969
right?

15
00:00:45,569 --> 00:00:47,909
So SessionStart is completely useless.

16
00:00:48,829 --> 00:00:54,489
And, and CwdChanged, well, that only fires
if you literally cd to a different path,

17
00:00:55,010 --> 00:00:56,529
not when a new root is registered.

18
00:00:57,129 --> 00:01:00,809
So the agent is just standing there trying
to build a Svelte project using npm,

19
00:01:01,250 --> 00:01:04,329
completely unaware that this specific
subproject is strictly,

20
00:01:04,989 --> 00:01:06,449
uh, strictly a bun setup.

21
00:01:07,209 --> 00:01:11,250
I actually had a, a proper nightmare shift
once where a global script ran and

22
00:01:11,270 --> 00:01:15,749
completely trashed a Svelte workspace
lockfile because of this exact blind spot.

23
00:01:15,790 --> 00:01:17,049
It, it was a total mess.

24
00:01:17,704 --> 00:01:21,724
Oh man, lockfile corruption is the
absolute worst.

25
00:01:22,324 --> 00:01:26,784
But, okay, so they, they just solved this
in version two point one point two one

26
00:01:26,784 --> 00:01:27,744
nine, right?

27
00:01:27,804 --> 00:01:29,784
They introduced the DirectoryAdded hook?

28
00:01:29,952 --> 00:01:30,552
Spot on.

29
00:01:30,992 --> 00:01:35,152
It is a brand new lifecycle hook in your
user settings dot json.

30
00:01:35,192 --> 00:01:40,812
Basically, the, the moment a new root is
registered, this DirectoryAdded hook fires.

31
00:01:40,833 --> 00:01:44,492
And if you pair it with, say, direnv and
that CLAUDE_ENV_FILE variable,

32
00:01:45,012 --> 00:01:48,652
you can automatically load the correct
environment variables for that newly added

33
00:01:48,712 --> 00:01:50,433
subdirectory, like, instantly.

34
00:01:50,637 --> 00:01:52,078
That makes total sense!

35
00:01:52,617 --> 00:01:57,197
So the moment slash add dir is called, the
hook runs, pulls in the local

36
00:01:57,237 --> 00:02:01,937
environment, and Claude suddenly knows,
oh, I should be using bun instead of npm

37
00:02:02,017 --> 00:02:02,197
here.

38
00:02:02,838 --> 00:02:03,977
But wait, what about security?

39
00:02:04,017 --> 00:02:08,417
Like, what if I pull down a random open
source repo and it has some malicious hook

40
00:02:08,458 --> 00:02:09,318
configured in the folder?

41
00:02:09,452 --> 00:02:11,912
Aha, you, you have hit the nail on the
head.

42
00:02:12,793 --> 00:02:17,132
That is where workspace trust comes in,
which, uh, actually got a massive security

43
00:02:17,192 --> 00:02:20,312
enforcement boost back in version two
point one point two one eight.

44
00:02:21,152 --> 00:02:25,273
Claude Code will straight up refuse to run
any hooks from folders that you haven't

45
00:02:25,372 --> 00:02:28,013
explicitly, you know, granted workspace
trust.

46
00:02:28,652 --> 00:02:30,892
If it is untrusted, the hook is blocked.

47
00:02:30,952 --> 00:02:34,833
And, and speaking of execution, if your
hook script fails, you have to be clever

48
00:02:34,932 --> 00:02:35,972
with your exit codes.

49
00:02:36,532 --> 00:02:39,712
If you exit with, with code two, you are
telling the model,

50
00:02:39,812 --> 00:02:42,252
hey, this is a blocking error, stop
everything.

51
00:02:42,952 --> 00:02:47,353
But if you exit zero with some structured
JSON, you can pass clean user messages

52
00:02:47,392 --> 00:02:51,212
back without, uh, without creating those
awful recursive execution loops.

53
00:02:51,449 --> 00:02:55,249
Oh, man, that recursive loop is a
hilarious mental image.

54
00:02:55,710 --> 00:02:59,689
Just Claude trying to fix a broken
environment forever, looping on itself.

55
00:03:00,170 --> 00:03:05,149
Hey, speaking of quality of life, did you
see they also patched that annoying GNU

56
00:03:05,210 --> 00:03:08,729
screen copy on select bug in two point one
point two one nine?

57
00:03:09,430 --> 00:03:10,729
Oh, mate, finally!

58
00:03:11,450 --> 00:03:16,269
No more terminal buffers corrupting into
raw base64 garbage when you highlight text.

59
00:03:17,010 --> 00:03:21,129
And, and they patched the Vim normal mode
left arrow escape issue too.

60
00:03:21,710 --> 00:03:24,409
It, it is the little things that keep you
sane, honestly.

61
00:03:24,739 --> 00:03:25,539
It really is.

62
00:03:26,559 --> 00:03:29,380
Though, I mean, it makes you wonder...

63
00:03:30,239 --> 00:03:35,159
as these agentic tools get more and more
integrated, will we ever get to a point

64
00:03:35,260 --> 00:03:39,319
where workspace boundaries and trust are
just fully automated?

65
00:03:40,219 --> 00:03:43,100
Or are we always going to need a human
standing guard at the gate?

66
00:03:44,444 --> 00:03:46,804
That is the, uh, the million dollar
question, isn't it?

67
00:03:47,844 --> 00:03:51,244
For now, look, I am just happy my
lockfiles are safe.

68
00:03:52,204 --> 00:03:52,804
Good chatting, mate.

69
00:03:52,875 --> 00:03:53,675
Yeah, talk soon.

