シャドーイング練習: How to actually force Claude Code to use the right CLI (don't use CLAUDE.md) - 動画で英語スピーキングを学ぶ

レッスンを作成中...
1
One of the most common questions I get about agents
2
and about claw code is how do I force it to use the right CLI command?
3
How do I force it to adopt my workflow instead of the workflow that it knows best?
4
For instance, how do I get it to use PNPM instead of NPM?
5
How do I get it to call this wrapper script that we wrote instead of calling the thing directly with NPX?
6
How do I prevent it from using certain commands and only allow it to use other commands?
7
If you're interested in these kind of questions, this is the stuff that I answer on my newsletter.
8
I'm working on a Claude code course right now for real engineers, not Vibecoders.
9
So if you dig that stuff, the link is down below.
10
The first thing that you probably think about
11
when you think about steering Claude in one direction but not another is to put information in a Claude.md file.
12
In other words, to proactively tell it to use PNPM, not NPM.
13
Now, this will be pretty effective most of the time, especially if like this, you have a Claude.md file that is nearly empty apart from that one instruction.
14
However, in various places, including in the previous video I just posted, I've advocated almost always deleting your claw.md.
15
Because if you think about it, this instruction here is only relevant for certain tasks, and putting it in claw.md makes it global for every action that you're going to do in the repo.
16
LLMs have an instruction budget
17
that you can really only put about 500 instructions in before it starts getting less
18
and less powerful and more and more confused.
19
And we want our LLM thinking about the complicated plans and the implementation that it's going to put together, not having irrelevant instructions about using NPM or PNPM.
20
And the final thing that makes me uncomfortable about this is the fact
21
that it's not a deterministic way of preventing a command.
22
For instance, we may want to disallow it from running destructive commands.
23
For instance, we never want it to git push.
24
These kind of negative instructions to the LLM are really bad,
25
I think, because they burn instruction budget in something that we're not actually using the instruction budget to prevent deterministically.
26
By adding this, we're reducing our chances of running git push or reducing our chances of running NPM, but we're not preventing it.
27
So instead, I'm going to show you an approach that prevents it deterministically and guides the LLM towards the correct solution.
28
The way to do this is via Claude Code hooks.
29
Hooks allow you to run deterministic code at certain points during Claude Code's execution cycle.
30
When one of these events fire, all matching hooks run in parallel.
31
So for instance, you can run a hook when the session starts.
32
You can run a hook when a permission dialogue appears to automatically approve things.
33
The one that we're interested in is pre-tool use before a tool call executes can block it.
34
Our plan here is to use this pretool use hook to before it calls npm to use pnpm instead.
35
And the cool thing about this is that Claude code already knows how to do this.
36
And I've actually prepared a prompt inside this file to take the Claude.md, turn it into deterministic hooks, and then put those hooks into your project.
37
Here's what it looks like.
38
Take the instructions in your Claude.md file, turn them into deterministic Claude code hooks in this project directory.
39
Not Once all the instructions will be deterministic, only do the ones you can, such as instructions to use one CLI command over another or disallowing certain CLI commands.
40
Use separate bash scripts for running the hooks, in other words this is its own .sh file and it gives some syntax here for how to construct that.
41
This is directly lifted from the Claude code docs.
42
And then finally below here, first confirm with the user which hooks will be created,
43
second implement the hooks, third provide the user with instructions on how to test the newly created hooks.
44
I'll include this in an article which is linked below for you.
45
So I'm going to copy and paste this, I'm going to go into a fresh Claude Code session here, I'm going to zoom up the terminal a bit, I'm going to paste it in and see what happens.
46
Alright, it's given me two options here.
47
It says there are two rules that can be enforced deterministically, block NPM commands or block git push.
48
Now I've actually it already got some git push blockers in my global setup so I'm just going to say, yeah, do the npm one only.
49
So that sounds good.
50
Let's run this and see what happens.
51
So it's now given us something to review.
52
It's given us a nice version of the bash command that we saw earlier, except it just checks if it's npm.
53
Crucially it's checking if the command starts with npm as a command.
54
It echoes use pnpm not npm and then it exits with an exit code of 2.
55
So that is looking good to me.
56
Let's accept that.
57
It's then going to make it executable by running chmod plus x, so I'm happy with that.
58
It's then created the configuration inside settings.json here, where we've got now hooks, which is a property on the settings, pretool use, which is the one we saw earlier.
59
It's matching any bash tools here.
60
And then when it matches any bash tool, it runs this command, block npm.sh.
61
So that looks good to me.
62
We're in a good spot.
63
And it's now appearing to verify that the hook works in line.
64
I'm just going to try and run this to see what happens.
65
And you can see here just up there it said blocked use PNPM not NPM.
66
So we're definitely getting somewhere.
67
And finally it's given us some instructions here to test it.
68
To restart claw code in this project try asking it to run something like NPM install foo.
69
Alright the first thing I'm going to do is actually remove the instruction from claw.md here.
70
And then we're going to pull open a fresh clawed code instance
71
and we're going to say npm install let's say React query.
72
Okay, let's give it something kind of juicy.
73
And we can see that the pre-tooled use here,
74
it said bash hook error blocked use pnpm not npm and now it's running pnpm install tanstat react query instead.
75
So that's it.
76
We have prevented one command and we've automatically steered it to use another command.
77
And crucially we've managed to kill an instruction inside our global clawed.md file.
78
This is what I love so much about this approach.
79
You get to take instructions out of your instruction budget and enforce them deterministically.
80
This means that the instructions that we have in clawed.md, they are available just in time.
81
They get to hover in the background until clawed actually progressively kind of discovers them.
82
And this idea of these rules just being enforced just in time, you can take this and apply it to lots of different things.
83
For instance, I've been turning my style rules, like I really hate positional parameters in functions, and turning them into ESLint rules so
84
that I can lint Claude into the right thing without needing to warn it or instruct it.
85
So creating these feedback loops for Claude is so, so powerful.
86
Now if you dig this, then this and all of my ideas are going to be in my newsletter, so you never miss a trick.
87
And the link for that is below if you want to click it and sign up.
88
But thank you so much for watching.
89
I've been having a blast making these videos and discovering lots of new ideas about Clawed.
90
What else do you think you can do with Hooks?
91
What else do you want to see me cover with Clawed Code?
92
And now of course Clawed is not the be all and end all, right?
93
Like I'm pretty keen to try out other coding agents too.
94
And the Hooks idea is not exclusive to Clawed too, so you can take this knowledge and probably take it to Codex or whatever you're using.
95
But anyway, that's enough rambling.
96
Thanks for watching and I'll see you in the next one.

なぜこのビデオで話す練習をするべきか?

このビデオでは、Claude Codeを適切に操作する方法について説明されています。このようなテクニカルな内容は、技術用語を用いた会話力を鍛えるのに最適です。特に、英語を使って問題解決や説明を行うことが求められる場面での実践が得られます。YouTubeで英語学習を行い、実際の話し方や相手に伝える技術を体感することで、コミュニケーション能力を向上させることができます。また、ビデオを通じて英語シャドーイングを行うことで、発音や流暢さを改善することができます。

文法と文脈における表現

このビデオには、いくつかの重要な構文や表現が含まれています。以下はその一部です:

  • 使う方法を強制する - “force it to use”という表現は、何かを強制的に行わせるという意味合いがあります。これにより、主語と動詞の関係に注意が必要です。
  • 特殊なコマンドを呼び出す - “call this wrapper script”のように、特定のスクリプトを実行することを指示する表現は、技術的な説明において便利です。
  • 明確に指示する - “prevent it from using certain commands”のような指示方法は、条件をつけた文の構造を学ぶのに役立ちます。

これらの表現は、特にIELTSスピーキング対策や実務英語において、進行形の使い方や条件文の構造を深く理解する助けになります。

一般的な発音の罠

ビデオ内にはいくつか発音に注意が必要な語句があります。例えば、”deterministically”や”workflow”といった言葉は、発音が難しいため練習が必要です。また、技術的な内容のため、特定のアクセントや語調に慣れることも重要です。英語シャドーイングを取り入れ、これらの語彙を声に出して繰り返すことで、より自然な発音を身につけられます。

このように、YouTubeで英語学習をすることで、専門用語や日常的な会話の中で必要な言語能力を磨くことができます。shadow speakのテクニックを用いて、効果的にスピーキングスキルを向上させましょう。

シャドーイングとは?英語上達に効果的な理由

シャドーイング(Shadowing)は、もともとプロの通訳者養成プログラムで開発された言語学習法で、多言語習得者として知られるDr. Alexander Arguelles によって広く普及されました。方法はシンプルですが非常に効果的:ネイティブスピーカーの英語を聞きながら、1〜2秒の遅延で声に出してすぐに繰り返す——まるで「影(shadow)」のように話者を追いかけます。文法ドリルや受動的なリスニングと異なり、シャドーイングは脳と口の筋肉が同時にリアルタイムで英語を処理・再現することを強制します。研究により、発音精度、抑揚、リズム、連音、リスニング力、そして会話の流暢さが大幅に向上することが確認されています。IELTSスピーキング対策や自然な英語コミュニケーションを目指す方に特におすすめです。