Intro
In this course, I'm going to be primarily using Claude Code as my agent for driving the lessons, demonstrating things, and showing you how agents in general work.
I'm doing this because it's a very popular harness, you may have used it yourself, and it's the one that I personally use the most right now.
However, this course is harness agnostic. You can choose whatever harness you like, as long as it runs in a CLI. Pick the tool that works best for you.
An Optional Primer Section
For folks who've never used a coding harness before, or who just want to get more out of Claude Code, I've provided an optional primer section so that you can get the basics before we get started.
It will give you a nice grounding of all of the things that you'll need to know about your agent before getting started with the course.
And if you're already experienced with your harness of choice, you'll probably still pick up a few tips - because I'm not just covering the basics. There are a couple of advanced things in there too.
So nice work, and I will see you in the next one.
Managing Your Claude Code Session
Make sure you have Claude Code set up and ready to go. If you haven't completed this yet, head back to the Before We Start section and work through the setup steps to get it installed on your system.
For this entire course, we're going to be running Claude from inside VS Code. We'll talk about the relationship between Claude and VS Code itself, but for now it's perfectly fine to run it in the integrated terminal.
Opening Claude Code And The Input Box
Kick off by simply running Claude in your terminal and bump the zoom level up a little bit for clarity.
VS Code with Claude Code launched in the integrated terminal showing the chat interface
What you'll see is a UI with an enormous text box at the bottom. This is where you'll type all your prompts.
Your First Message
Let's start simple. You can say anything to Claude, just like any chat app you've used.
hello, how are you?
The agent will process your message and respond naturally. This familiar chat-like interface makes it easy to get started.
Claude Code responding to a greeting with friendly acknowledgment
Terminal Setup And Multi-Line Input
Before we go further, there's one important command to run: /terminal-setup.
/terminal-setup
Type the forward slash, then find terminal setup from the autocomplete. The command should turn a nice shade of lilac once you've found the right one.
The /terminal-setup command highlighted in lilac in the autocomplete menu
Press Enter to run it.
This command sets up key bindings for you, specifically for Shift+Enter. Depending on your operating system, you may need to run this manually (like on Windows Subsystem Linux), but most users can just run it and be good to go.
Without this setup, you might experience strange key binding issues. Once installed, Shift+Enter lets you add new lines in your prompt:
hello,
and then press Shift+Enter here
you can write multi-line prompts
This is essential for writing more complex instructions to the agent.
Multi-line prompt in Claude Code using Shift+Enter
Checking Your Usage
To see how much of your plan's allowance you have left, run the /usage command:
/usage
Usage display showing context window limits and current session tokens
This shows you:
- How much usage you have left in your current session
- Your weekly limit
- Your current usage against that limit
The specific numbers and labels may look different depending on your plan, and they may change between agent versions. But this is how you check your remaining allowance at any time.
Once you reach the end of your usage window, you won't be able to continue using the agent until your limit resets.
Press Escape to exit the usage view and return to your chat.
Visualizing Your Context Window
Run the /context command to see what's currently in your context window:
/context
Context visualization showing token breakdown across system prompt, skills, and messages
This display is really useful when you need to debug your setup. You can see:
- System prompt tokens: Instructions given to the agent
- Skills tokens: Custom skills you've added
- Message tokens: Conversation history
- Context window size: The total token capacity (for example, Claude 3.5 Opus has 1 million tokens)
Understanding what fills your context window is key to using agents efficiently. We'll dive deeper into context management throughout this course.
Clearing The Context
To reset your context window and start fresh, run /clear:
/clear
Context window after clearing, showing drastically reduced token count
This removes all messages from your current conversation, giving you a blank slate. You can verify it worked by running /context again.
Compare the token counts before and after:
| State | Approximate Tokens |
|---|---|
| With conversation history | ~9,000 |
After /clear | ~6,600 |
This demonstrates that models are stateless. Once you clear the context, the agent has no knowledge of your previous conversation.
Alternatively, you can press Ctrl+C twice to exit and open a brand-new session. This also gives you a clean context window with no memory of the previous conversation.
Interrupting The Agent
Sometimes you'll need to stop the agent mid-run. Press Escape to interrupt:
explore the code base
If the agent starts working and you decide you want it to stop, just press Escape. The agent will cancel everything it was doing.
Claude Code showing an 'interrupted' message after pressing Escape
After interrupting, the context window shows an interrupted message asking what Claude should do instead. You can then redirect it or ask it to continue.
You might accidentally trigger this by pressing Escape at the wrong moment. If that happens, just type:
carry on
And the agent will resume where it left off.
Summary
You've now learned the essential commands for working with Claude Code:
- Open and chat: Launch the agent in your terminal and type messages like any chat app
- Multi-line input: Use Shift+Enter to write complex, multi-line prompts
- Check limits: Run
/usageto see your remaining allowance - Inspect context: Run
/contextto visualize what's filling your context window - Reset: Run
/clearto start with a fresh context - Interrupt: Press Escape to stop the agent mid-run, then redirect it
You're ready to start working with the agent. Nice work, and I'll see you in the next one.
You have finished one task and want to start something unrelated in the same terminal, with none of the earlier conversation influencing the agent. What do you do?
- Run /clear to empty the conversation history
- Run /context to inspect the token breakdown
- Ask the agent to ignore the earlier messages
- Press Escape to interrupt the current run
The agent is midway through a job and is clearly heading in the wrong direction. What is the cheapest way to stop it and put it back on track?
- Press Escape to stop it, then redirect it
- Run /clear and set the whole task up again
- Press Ctrl+C twice to open a fresh session
- Wait for it to finish, then correct it
You want to see the token breakdown of what is loaded right now: system prompt, skills and conversation history. Which command shows it?
- /context
- /usage
- /clear
- /terminal-setup
Prompting in the Terminal
Now that you understand the basics of prompting, here are some built-in features you can use to improve how you work with agents.
Referencing Files With @
You may want to reference individual files in your agent. To do this, press @ to open the file picker.
Claude Code interface showing the @ file picker with fuzzy search filtering through project files
You can then:
- Use arrow keys to browse through files
- Type to fuzzy search for specific files like
routes.ts - Press return to pull that file into your text box
You can add multiple files this way - just repeat the process. For instance, you might add components.json after drizzle.config.ts. You can also use tab to pull files into your text window.
Once you press enter, both files get read into the context window immediately. The agent reads the files directly on the first request without needing extra tool calls.
This is especially useful when you need to pass in a spec or specific configuration file that the agent should reference directly.
Stashing A Prompt With Ctrl+S
Sometimes you're not ready to send a prompt, but you don't want to lose it. You can stash it instead.
Type your prompt - for example: "hello, how are you"
If you're not ready to send it, press Ctrl+S to stash it.
The agent interface showing a stashed prompt marker
You'll see a "stashed" indicator. Now you can type something else into the text box. When you're ready, the stashed prompt will rehydrate back into your input.
For example:
- Stash: "hello, how are you"
- Type something new: "hello"
- Press return
- The original stashed prompt gets restored into the text box
This is really useful when you're giving the agent feedback. You might send something, realize you're not ready, pull back, insert something else in the middle, and then finalize your prompt before sending it.
Pasting In Images
You can copy and paste images directly into the agent - even screenshots.
A browser showing a Wikipedia image of Lake Bled in Slovenia
For example, here's an image of Lake Bled in Slovenia. Right-click on an image and copy it. Then paste it into the text box. You'll see a "pasting" indicator in the bottom left, and the image appears in your input.
The agent interface with an image pasted into the text box
You can now ask the agent about the image. It will analyze it and respond.
The agent responding with details about Lake Bled, mentioning the Church of the Assumption and its bell tower
Images become part of your prompt, so you can reference screenshots, mockups, and other visuals directly without uploading them separately.
Summary
You now know three powerful prompting techniques:
- Reference files using
@to pull specific files into context - Stash prompts with
Ctrl+Sto save half-written prompts and rehydrate them later - Paste images from your clipboard to include screenshots and visuals in your prompts
You already know the exact config file the agent has to follow. What happens when you pull it in with @ rather than describing it in words?
- Its contents are in the context window on the first request
- The agent opens it in your editor for you to review first
- The agent is told to read it later if it turns out to matter
- A link to the file is stored and resolved only when needed
You are halfway through a long prompt when you realise the agent needs one quick correction first. What do you do with the draft?
- Press Ctrl+S to stash it, send the short one, and it returns
- Copy the draft into a scratch file, then paste it back after
- Send the half-written prompt now and finish your thought after
- Delete the draft, send the short message, and type it out again
Claude and Your IDE
Claude Code integrates with your editor of choice through the /ide command. You don't have to use VS Code like this course does - you can use Cursor, Windsurf, Antigravity, or whatever tools are available to you.
The /ide command lets you manage your IDE integrations and check their status.
/ide
When you run this command, it shows you which editor you're connected to.
Terminal showing Visual Studio Code connection status
In this case, we're connected to Visual Studio Code because the Claude Code for VS Code extension has been installed.
Claude Code for VS Code extension installed in the editor
If you run /ide in your terminal, it will show you how to install the matching extension for whatever IDE you're using.
Once you confirm and exit the command, you're ready to start using the integration.
Reviewing Diffs in Your Editor
The main reason to connect your editor is for diff management. This comes up constantly when working with agents.
For example, if you prompt the agent to "remove the test watch command from package.json," it will read the file and make updates to it.
Without an editor connection, the diff would display in the terminal as text, which is awkward and hard to review. But with your editor connected, you see the diff displayed right inside your IDE.
This is much better. You can:
- Scroll through the file to see context
- Review the exact changes the agent made
- Accept all changes with the "Accept Proposed Changes" button
- Click into the diff and make manual tweaks before saving
- Save the file to confirm the changes
Reviewing the decent edit in VS Code's diff view
Being able to dive in and tweak the agent's output directly in your editor is powerful. And reviewing diffs in a proper IDE instead of the terminal makes the whole workflow much smoother.
Why Use an Editor?
There are more features and more ways your editor can integrate with agents, but the diff feature is the one you'll use 99% of the time. It's the primary reason to run your agent inside your editor rather than just in the terminal.
If you're following along, feel free to go back through the video if you get stuck, or ask questions in the Discord if you run into trouble.
Nice work - see you in the next one.
Going Forwards and Backwards in Time
One really important thing that an agent allows you to do is go backwards and forwards in the conversation. This is essential when you're trying something out that you later want to revert.
Reverting Changes
In a previous video, you made a change where you removed a dev script. Now you can simply say to the agent:
revert that, please
The agent will undo the change by rewriting and re-adding it back in. You accept this by pressing Control S to save the diff.
But there's a more powerful option available - rewind mode.
Using Rewind Mode
Press Escape twice in quick succession to enter rewind mode. In this mode, you get to restore your code and conversation to any earlier point in the session.
For instance, if you want to revert the command you just did, you can select the previous checkpoint. The one at the bottom is your current state, and the one above it is the point at which you said "revert that please".
Select it with Enter.
Rewind mode interface showing checkpoint history
Choosing What to Restore
Now you have a few different options:
| Option | What It Does |
|---|---|
| Restore the code and the conversation | Rewind your entire session to the point before this code edit was made |
| Restore the conversation but keep the code | Keep your current code state while reverting the conversation |
| Restore the code but keep the conversation | Keep your conversation history while reverting the code |
The option you'll use most often is to restore the full code and conversation. Once you do, the code is reverted and you're back to the point where you had the previous state.
If you want to go back further, open the rewind mode again with Escape twice and choose an earlier checkpoint. You can step backward through the entire history of your session.
There's also a summarize from here command available, but that's a topic for another time. If you want to cancel rewind mode, simply choose "nevermind" and stick to your current state.
Rewind mode showing multiple checkpoints to navigate through
Persisting and Resuming Sessions
One other thing that's really important is the fact that an agent actually persists its sessions locally. This means you can quit out by pressing Ctrl C twice, and then you can resume it in multiple ways.
Option 1: Resume with UUID
When you quit, you'll get output that shows a command you can run directly:
claude --resume [UUID]
Just run this command and you'll go back into the exact state you left previously.
Option 2: Resume in a Fresh Session
Alternatively, you can Ctrl C twice to exit and open a new session by typing:
claude
This opens a totally fresh session. Inside, you can press:
/resume
Now you'll see all of the conversations you've had in this repository. You can even search through all of the sessions if you want. Select the one you were just using and press Return to go back into that same session.
Resume menu showing list of previous sessions
Option 3: Continue the Previous Session
If your session is interrupted for any reason, you can always resume it because the agent persists sessions locally.
Another way to pick up where you left off is to run:
claude --continue
This pulls you directly into exactly where you were, without needing to go through the resume menu.
Summary
The agent allows you to navigate backwards and forwards in your conversation in several ways:
- Enter rewind mode - Press
Escapetwice to zoom through all checkpoints - Choose what to restore - Pick whether to rewind code, conversation, or both
- Persist sessions locally - Quit and resume without losing progress
- Multiple resume methods - Use
--continue,/resume, or the UUID command
With these tools, you can experiment freely knowing you can always step back to any previous point in your session.
You tried an approach, the agent edited files, and you want the whole attempt gone: the edits and the messages that produced them. Which rewind option do you pick?
- Restore both the code and the conversation
- Restore the conversation but keep the code
- Restore the code but keep the conversation
- Choose nevermind and undo the files by hand
You are back in a repository you worked in last week and want a particular older conversation, not the one you were in most recently. How do you get to it?
- Run /resume and search the list of past sessions
- Run claude --continue and steer it back yourself
- Press Escape twice and pick an earlier checkpoint
- Start a new session and describe the old one to it
Running Bash Commands
One super important part of working with Claude Code is running bash commands. Bash commands turn your agent from just a passive code writer into something that can actually seek feedback loops, can actually work with your project and can use all the power of bash at its disposal to find information and to do stuff.
Now we can't just manually ask Claude "OK, run the dev server for me", and because it's quite smart it will understand "OK, I need to read the package.json, I need to find where the dev server is, and then I need to run it like this." But suffice to say, there are some times when you just know what command you want to run, and you just want to run it, and then put the result into the agent's context.
There are really three main approaches to running bash commands in an agent:
- Run commands directly and let the agent see the output
- Background long-running processes and monitor them
- Suspend the agent to run commands it won't see
Running commands with bash mode
The way you run commands that the agent can see is by using bash mode. I've just restarted my agent instance. I'm going to just put an exclamation mark and now I've entered bash mode.
Terminal showing the ! prefix to enter bash mode
!
Anything you put in here will be turned into a bash command and actually run for the agent. For instance, you can run npm run typecheck inside here and now it just runs the command after you press enter.
Terminal showing npm run typecheck being executed with the ! prefix in bash mode
Now because I haven't run npm install in my setup here, I'm getting a lot of errors. These errors are now present to the agent in its context. So I'm going to get it to help me solve these errors and it will be able to see the errors and actually work with them.
It figures out that Zod is in package.json, but not installed. So it suggests that you should run npm install. There we go.
Backgrounding long-running processes
This works well for commands that essentially have a start and an end. But what about commands that are supposed to persist, like long-running dev servers?
For that you can run npm run dev inside bash mode here:
! npm run dev
And while it's running you can actually press Ctrl-B to run it in the background. In this version of Claude Code, something appears that says "command was manually backgrounded with userID this."
Message confirming the command was manually backgrounded with a userID
Any output from that task goes into a local file. You can see that underneath your status line there is a little background task showing. You can zoom downwards with the down arrow there, and you can press return to see it. Now you can actually view the shell and see what's going on.
Background task panel showing the dev server running on localhost 5175
You've got lots of options here. You can stop it with X if you want to, or you can just press left to go back and now you're back in your agent instance.
This is really useful when you're debugging a problem with your dev server, because the agent can see where all of the logs are being written to. It can try something out in the UI, maybe, or send a curl request, and then it can actually see the output of the dev server.
Suspending the agent to run hidden commands
I've just reset my instance here so we can see another feature which is suspending the agent. If, for instance, you want to run something that you don't want the agent to see the results of, or you don't care to show it, and you have some state inside the agent that you want to preserve, then you can use suspend.
You can press Ctrl-Z inside here and the agent has been suspended. This means you can now run any command you want to.
Running echo foo in a suspended terminal session
echo foo
This is not visible to the agent.
Running fg to bring the agent back with its state intact
If you want to bring the agent back, you can just run fg here, and you get your agent instance back with all of its state.
This is great if you just want to say "OK, don't care about the agent, do something like whatever command I want, and then fg to bring it back."
When to use each approach
The decision tree for this really looks like this:
| Goal | Approach | Shortcut |
|---|---|---|
| Agent needs to see the output | Use bash mode | ! prefix |
| Long-running process (dev servers) | Background with Ctrl-B | After ! command |
| Command should be hidden from agent | Suspend the agent | Ctrl-Z, then fg to return |
If you want the output of the bash command you're running to be visible to the agent, then you can use bash mode by using the exclamation mark, and you can background that with Ctrl-B and then manage those backgrounded tasks.
Really, really useful for dev servers. You don't use it every single time, but when you do use it, it's usually for debugging some kind of dev server issue.
But if you want the command to be totally hidden from the agent, you can just suspend it quickly with Ctrl-Z.
Note: these are keyboard shortcuts that work on most systems, but you might need to do something different if you're on Mac.
So those are all the different ways that you can manage bash commands in your agent setup.
You want to run your type check yourself and then have the agent fix whatever it reports. How do you run it?
- Prefix it with ! so the agent sees the output
- Suspend with Ctrl-Z, run it, then return with fg
- Run it in a second terminal and paste the errors
- Background it with Ctrl-B and watch the panel
You start the dev server in bash mode and it never hands the prompt back, because it is not going to exit. What do you do?
- Press Ctrl-B to background it and carry on
- Press Ctrl-Z to suspend, then fg to come back
- Press Ctrl-C to kill it and let the agent start it
- Wait for it to finish before prompting again
You need to run a command whose output the agent must not see, and you want the agent's state intact afterwards. What do you do?
- Press Ctrl-Z, run the command, then fg
- Run it in bash mode and ignore the output
- Ask the agent to disregard what it sees
- Quit the agent and run it afterwards
Permissions
When working with an agent, you always need to think about risk versus reward, especially in how much power you give over to it. If you give an agent infinite power, it could do something dangerous by accident, like delete your entire file system.
To mitigate this risk, Claude Code has a very detailed permissions model. By default, it's very strict with itself about what it allows the agent to actually go and do.
The Approval Flow
Let's say you ask an agent to run a simple command like echo hello. Because echo is an extremely safe command, the agent thinks this command is fine for it to run without asking.
Echo command running without permission
But if you ask it to do something like run a type check on the project, it might do something different. Instead of running it automatically, the agent requests permission first.
Permission request for pnpm typecheck command
When the agent asks for permission, you'll see:
- The exact command it's going to run
- The reason it wants to run it
- Three options for how to respond
For example, when asking to run pnpm typecheck, you might see that it wants to run a type check using react-router-typegen and tsc.
Three permission options: allow once, allow always, or reject
Your three options are:
- Allow once - Yes, you're allowed to do this this time
- Allow always - Yes, and you're allowed to then from now on run any
pnpm typecheckcommand inside this project - Reject and suggest - No, and you can suggest a different command instead
If you don't want the agent to run a specific command, you can reject it and suggest an alternative. For instance, if you'd rather use npx tsc instead of pnpm typecheck, you can press Tab and give that reason.
Suggesting an alternative command with npx tsc
The agent will then ask if it can run npx tsc instead. If you approve it with "allow always", you'll see something like Bash(npx tsc *) added to your permissions.
Editing Permissions in Settings
Your permission preferences are recorded in a file at .claude/settings.local.json.
The .claude folder showing settings.local.json file
The syntax is important to understand here. You can actually edit this file yourself ahead of time to allow things to happen in the repo without needing to approve them each time.
If you want to allow a specific command, you can add it to the allow array:
{
"permissions": {
"allow": [
"Bash(pnpm typecheck)"
]
}
}
If you want to say that all pnpm commands are available, you can use a wildcard:
{
"permissions": {
"allow": [
"Bash(pnpm *)"
]
}
}
You can also disallow the agent from doing things by using the deny array.
For instance, if you don't want it to run git push, you might deny all git push commands:
{
"permissions": {
"deny": [
"Bash(git push *)"
]
}
}
Permissions Beyond Bash
It's not just bash commands that the agent needs permission to run. An agent can also search the web and fetch web pages to back up what it's seeing locally.
For example, you might ask it to fetch information about react-router-typegen from the web. The agent will ask you to approve a web search for "React router typegen".
Permission request for web search
If you say yes and don't ask again, the agent adds it to settings.local.json and fetches from websites like ReactRouter.com.
Fetching from ReactRouter.com website
The permission is added as WebFetch(domain:reactrouter.com) in your settings file.
Once it fetches the information, it can give you a summary of how React Router typegen works based on the actual documentation.
Sharing Permissions With Your Team
By default, settings.local.json is in your project and ignored by version control. This means the permissions apply only to you.
But if you want to share these permissions with your team and have a specific set of things always allowed within the repo, you can rename settings.local.json to settings.json.
This file can then be checked into version control and shared with your team.
When anyone on your team runs the agent on the repo, it will pick up these permissions automatically. This is incredibly powerful for anyone starting on your repo for the first time. They just run the agent, and it already knows what's allowed for that repo. This is a lot faster than having to manually set up the permissions yourself each time.
Auto Mode vs Manual Permission Handling
There's another way to work with permissions: auto mode. You can see the mode selector in the bottom left of Claude Code and cycle between them using Shift+Tab.
Mode selector showing manual, edits, plan, and auto modes
The available modes are:
- Manual mode
- Edits mode
- Plan mode
- Auto mode
Auto mode uses an LLM classifier to look at your conversation and check if the thing the agent is about to run is safe. For example, you can run npm run typecheck and the agent will run the shell command without asking for permission first.
Running npm run typecheck in auto mode without permission prompt
This is different from manual mode. The agent is able to classify itself whether the command is dangerous or not. This does mean some tokens are spent to check whether the command is safe, which costs a bit of time. So auto mode is a little bit slower, but it means you can run these things pretty much without needing to intervene.
The main classifier model is probably Claude Haiku. However, the classifier isn't perfect. It does allow some things you don't want to happen (like migrating databases sometimes), and it blocks some things you do want to happen (like creating GitHub issues).
But for most use cases, it's on the right side of OK. It does block most of the bad things that would happen, especially the stuff that's always bad like rm -rf on your file system. It also doesn't drive up your usage limits too much, making it a pretty good trade-off.
The settings.json file is still really useful with auto mode. The agent checks settings.json first, before running the command through the classifier. This means you can speed up common operations and not have to worry about the classifier by just having something in settings.json.
To set auto mode as your default, go into config and select default permission mode. You can choose this by pressing Enter or Space.
Config menu showing default permission mode setting
You switch to auto mode so the agent decides for itself whether a command is safe. What does that cost you?
- Each command is a little slower while it is checked
- Permissions in settings.json stop being consulted
- Every command runs, including rm -rf on your disk
- Your usage limits climb sharply as it checks
There is one command you never want the agent to run in this repo, whatever it judges at the time: git push. What do you set up?
- A deny entry of Bash(git push *) in settings
- An allow entry for every command except push
- Auto mode, which classifies pushes as unsafe
- A note in your prompt telling it not to push