Vibe coding with Claude Code course Β· Module 1: Claude Code and Cursor
How Claude Code works: the agent loop, permission modes and plan mode
In this lesson9
Ahoj! Your crew already writes files and runs commands, and you can read its orders in the terminal. Before you hand out a bigger job, you need to know what Claude sees, what it does not know and what it may do without asking. You will also meet the mode in which Claude first draws the map and only then grabs the oars.
The problem: Claude did something you did not expect
You ask for a "crew section", and a moment later there is a new file with styles in the folder, the heading has a different colour and the page shows three pictures that were never there. Claude did not act out of malice: it filled the gaps in your request its own way, and it did so without asking, because the session mode allowed it. To steer an agent instead of just watching it, you need to understand two things: what Claude sees while it works and what permissions it has.
What Claude sees
In lesson 0_1 you met the agent loop: Claude gathers context, acts and checks the result, and you can interrupt it at any moment. Context is everything Claude has in front of its eyes in a given conversation. It comes from several sources:
- project files: Claude reads them on its own when it decides they are needed, so you do not have to paste them into the conversation;
- command output from commands it ran, for example a list of files from
ls; - Git state, when the project uses it: the changes since the last save and the history (you will meet it in lesson 0_6);
- your requests and the whole conversation so far.
Thanks to this Claude quickly finds its way around a project: it will find the layout of the files and the styles that already exist faster than you could describe them.
What Claude does not know
Much more important is what the project does not contain. Claude does not know:
- your goal: who the page is for, why it is being built and how big an effect you imagine;
- decisions made outside the folder: if you and a friend agreed that the page would wear the colours of the Black Pearl, Claude will only learn about it from you;
- the browser screen: it sees the code of the page, but not how the page looks once opened, until you describe it or show a screenshot.
The Claude Code documentation names this as a common reason for a failed session: when Claude built something other than what you had in mind, it usually lacked information that cannot be read from the repository, that is, from the project folder and its history. The lesson for a captain: in your request you write first of all what Claude will not find in the files.
Hallucinations: a confident tone is not proof
A language model can state something untrue in a confident tone. Such an invention is called a hallucination. Claude may report that it added an image ship.png, although there is no such file in the folder, or write the address of an image that does not exist. The cure is to ask for proof: a command and its output, or a fragment of a file. When the report does not match what you see in Cursor, write for example:
Show me the output of ls and the fragment of pirate.html where this image is.If ls does not list ship.png, you have it in black and white that the image is not there, and you ask for a fix. Asking for proof changes nothing in the files: Claude only reads and shows, so it will not ask for permission even in Manual mode.
Permission modes
The permission mode decides what Claude may do without asking. In lesson 0_2 you switched the session from auto to Manual. Here is a cheat sheet of the four modes you will use; the label from the second column is visible on the status bar under the request field:
| Mode | Label on the bar | What Claude does without asking | When to use it |
|---|---|---|---|
| auto | auto mode on | everything, while a separate model in the background judges actions and blocks risky ones | long tasks, once you can read changes |
| Manual | manual mode on | only reads; asks before file edits and commands that change something | the first locations and sensitive work |
| acceptEdits | accept edits on | changes files and runs simple file commands inside the project folder, such as mkdir, touch, mv, cp and rm; asks about other commands | when you prefer to read the changes in Cursor afterwards |
| plan | plan mode on | reads and explores the project but changes no files until you accept the plan | before every bigger change |
The Shift+Tab key switches modes one by one. A terminal session starts in auto mode, so successive presses give this cycle:
auto β Manual β acceptEdits β plan β autoThe cycle closes: after plan mode you return to auto. You can also choose the mode right when the session starts, by adding the --permission-mode flag, an extra option of the claude command:
claude --permission-mode planThis command starts the session straight in plan mode. Instead of plan you can write manual or acceptEdits. The flag applies to that one session only: the next ones start in auto mode again.
There is also a bypassPermissions mode that approves almost everything without asking: the documentation reserves it for isolated containers and virtual machines that you can throw away, so you do not turn it on on your own computer.
Captain's tip: stay on Manual until reading changes becomes second nature, and switch to plan before a bigger change. Watch out for the trap the documentation itself warns about: after the tenth request for permission it is easy to start picking Yes without reading. When you notice it, take a break or switch to acceptEdits and read the changes in Cursor.
Plan mode
In plan mode Claude explores and proposes but changes nothing. It reads files, may run commands to look around, and writes a plan. It does not edit files until you accept the plan. It is a council over the map before the ship sails.
You enter plan mode in three ways: by pressing Shift+Tab until the bar shows plan mode on; by starting a single request with /plan; or by starting the session with the --permission-mode plan flag. You leave it with another Shift+Tab, which, following the cycle, takes you to auto mode; if you prefer Manual, press Shift+Tab once more.
Switch the session to plan mode and give the order:
Request for Claude Code:
Plan an extension of pirate.html with a "Our Crew" section with three
character cards: the captain, the helmsman and the ship's cook. Each card
has a name, a role and one sentence of description. Do not change any
files yet. Write which files you will change, what you will add and how
we will check that the section works.The request says what should be created, where and how we will know it is done. The sentence "do not change any files yet" is a spare safeguard here, because plan mode blocks edits anyway.
What Claude prepared
After a moment Claude will show a plan. Yours may use other words, but it should look similar. The plan uses a few new names from HTML and CSS: h2 and h3 are second and third level headings, <section> groups one part of the page, and <article> is a self-contained piece of content, here one card. A class is a name given to elements so that one CSS rule can style them all at once:
Plan: "Our Crew" section in pirate.html
1. In <body>, under the welcome paragraph, I will add a <section> with
an h2 heading "Our Crew".
2. In the section, three <article> elements with the class crew-card:
an h3 with the name, a paragraph with the role and a paragraph with
the description.
3. In <style> I will add a .crew-card rule: a border and spacing
between the cards.
4. I am not creating new files or adding libraries.
Check: open pirate.html in the browser; under the greeting you will see
three cards, and the "Ahoj Piraci!" heading will not change.The plan names one file, three build steps, what Claude will not do and a way to check the result. Nothing has changed yet: pirate.html in Cursor looks the same as before the request.
Under the plan Claude will ask what next. You can choose:
- Yes, and use auto mode: you approve the plan, the session switches to auto mode and Claude builds without asking;
- Yes, manually approve edits: you approve the plan, but you approve every file change yourself;
- No, keep planning: you stay in plan mode and write what to fix in the plan.
You can also fix the plan yourself: Ctrl+G opens it in your default text editor, where you can add or strike out points before Claude starts. If you do not know which editor will open, simply choose No, keep planning and describe the fix in words. Beware of a trap: when Claude is waiting for a decision, Shift+Tab approves the plan. To leave planning without accepting, press Esc first and only then Shift+Tab.
Captain's review
Before you approve the plan, check four things:
- Files: the plan changes only
pirate.html. Every new file needs a good reason. - No ballast: the plan adds no libraries or frameworks. A typical agent mistake is a plan "just in case", for example a framework or a separate components folder for a single HTML page. You will spot it by the words "I will install" and "npm install" or by a long list of new files.
- Check: the plan says how you will verify the result.
- Untouchable places: the plan does not touch what already works, that is the "Ahoj Piraci!" heading and its colour.
If something does not fit, choose No, keep planning and write for example: "No new files, styles only in the style tag".
Next step
When the plan passes the review, choose Yes, manually approve edits. Claude will start building and you will approve every change just as in lesson 0_2. Then open pirate.html in Cursor and in the browser: three cards should stand under the greeting. In lesson 0_5 you will learn to write requests so that Claude hits the mark the first time.
Remember: map first, voyage second; plan mode is the map you read before the crew grabs the oars.
Code for this lesson: index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ahoj Piraci!</title>
<style>
h1 {
color: red;
}
.crew-card {
border: 2px solid #333;
padding: 12px;
margin: 12px 0;
}
</style>
</head>
<body>
<!-- This is how pirate.html may look after you approve the plan from lesson 0_4. -->
<!-- Your file from Claude Code may have different names and descriptions. -->
<h1>Ahoj Piraci!</h1>
<p>Welcome aboard! Our adventure begins here.</p>
<section>
<h2>Our Crew</h2>
<article class="crew-card">
<h3>Redbeard</h3>
<p>Captain</p>
<p>Sets the course and reads every map before raising the anchor.</p>
</article>
<article class="crew-card">
<h3>Ola Compass</h3>
<p>Helmsman</p>
<p>Holds the helm steady even when the waves reach the mast.</p>
</article>
<article class="crew-card">
<h3>Bartek Ladle</h3>
<p>Ship's cook</p>
<p>Cooks a fish soup that puts the whole watch back on its feet.</p>
</article>
</section>
</body>
</html>Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. What does Claude Code not know until you tell it?
2. Claude reports that it added an image ship.png to the page, but you see no such file in the Explorer. What do you do?
3. What does Claude Code do without asking in acceptEdits mode?
4. What does Claude Code do in plan mode?
Hands-on tasks in the game
- Horizontal ordering
Assemble the command that starts a Claude Code session straight in plan mode (on one line):
- Vertical ordering
Arrange the steps of working with plan mode in the right order: