Software 3.0 and Agentic Engineering / Module 06

Module 6: From Vibe Coding to Agentic Engineering

Run a coding agent as an engineer: vibe coding and agentic engineering, how Claude Code works, permission modes, plans, and small tested steps.

Omar showed the team his new discount codes on Friday. He had typed one prompt to Claude Code and accepted every change, and the demo took 10% off. Nina asked whether the booking fee got 10% off too, and Omar didn’t know.

“Did the robot write this?” Leo asked.

Maya, Leo and TinyTickets are invented, and so are the numbers in their story.

In Modules 4 and 5 you built a small coding agent and gave it tools. This module moves to a real one, Claude Code, and asks how you let it write most of the code while you still ship code you understand. Andrej Karpathy named the two ways of working vibe coding and agentic engineering, and this module teaches the second on a small TinyTickets repo.

After this module, you can:

  • say what Karpathy meant by vibe coding and by agentic engineering, and when each one fits
  • explain what Claude Code does underneath, part by part, next to your own agent.ts
  • pick a permission mode for a task, and say what each mode lets the agent do without asking you
  • run a change as a generate and verify loop: tests first, a plan, then small steps you review and commit
  • undo an agent’s work with checkpoints and Git, and say what neither of them can undo

A discount feature that works in the demo

Start with what Omar did, before any new words. The TinyTickets repo has an endpoint that prices an order, POST /orders/quote. Omar started Claude Code in the repo and typed one prompt:

Add discount codes to POST /orders/quote, in a new field discountCode.
SPRING10 gives 10% off and FRIEND5 gives 5% off. Make it work.

Claude Code read some files, changed several, ran the tests and said it was done. Omar didn’t read the changes. He started the server and asked for two $12 tickets with SPRING10:

curl -s -X POST localhost:3000/orders/quote \
  -H 'content-type: application/json' \
  -d '{"showId":"songs-of-spring","lines":[{"type":"standard","quantity":2}],"discountCode":"SPRING10"}'

The total came back lower than $25.50, which is what two tickets and the $1.50 booking fee cost without a code. The demo worked. If you try the prompt, your run will differ, because a model’s output is sampled (Module 2).

Then Nina asked three questions:

  • Does the booking fee get 10% off too?
  • What does a buyer who types SPRNG10 by mistake pay?
  • Does a student, who already gets 20% off, get the code’s 10% as well?

Pause and predict. Can you answer any of Nina’s questions from Omar’s prompt?

Answer

No. The prompt doesn’t decide any of them, so the model decided each one while it wrote the code. The answers are in the diff, and nobody read the diff.

Each answer costs something if it’s the wrong one. A discounted fee loses 15 cents on every small order. A typo that falls back to full price makes a buyer pay more with no warning. Stacked discounts sell a $12 student ticket for $8.64.

The code may even be right. But nobody on the team decided its rules, and nobody can explain it, so nobody can say whether it’s right.

Simon Willison has a rule for code from a model (Not all AI-assisted programming is vibe coding, March 19, 2025). It reads: “I won’t commit any code to my repository if I couldn’t explain exactly what it does to somebody else”. Omar’s change fails it.

So this module answers one question. When an agent writes most of the code, how do you keep the result code you understand and trust, and which controls in Claude Code help?

Vibe coding: forget that the code exists

On February 2, 2025, Karpathy wrote about “a new kind of coding I call “vibe coding”” (his post on X). In it, you “fully give in to the vibes, embrace exponentials, and forget that the code even exists”.

He said how he worked. He always accepted every change, and he no longer read the diffs. When a bug wouldn’t go away, he worked around it or asked for random changes. He also named the limit: the method was fine for throwaway weekend projects.

Vibe coding is building software by telling a model what you want and accepting its code without reading it. Willison defines it the same way: “building software with an LLM without reviewing the code it writes” (his post of March 19, 2025).

Omar vibe coded. He wrote one prompt, accepted every change, and used the demo as the only check.

Vibe coding isn’t wrong in itself. Willison defends it for low-stakes projects and prototypes, and Karpathy’s own limit was throwaway projects. It fails when other people depend on the code, because buyers pay the prices it computes and the team must change it next month.

Agentic engineering: agents write, you oversee

A year later, on February 4, 2026, Karpathy quoted his own post and looked back (his post on X). In early 2025, he wrote, models were weak enough that vibe coding was mostly for “fun throwaway projects, demos and explorations”. By 2026, programming with agents was becoming “a default workflow for professionals, except with more oversight and scrutiny”.

He wanted a name for that work, and picked one that others had proposed, “agentic engineering”, as his current favorite. He explained both words:

  • Agentic, because most of the time you no longer write the code yourself. You direct the agents that do, and you oversee them.
  • Engineering, because doing it well takes skill, method and expertise.

Agentic engineering is building software with coding agents while you stay responsible for the result. You direct the agents, and you check their code as carefully as code a person wrote. The goal, in the same post, is to get what agents offer with no drop in the quality of the software.

The term is shared. Simon Willison started a guide called Agentic Engineering Patterns on February 23, 2026, 19 days after Karpathy’s post (launch post). His definition stresses a different part: coding agents “can both generate and execute code”, so they can test their own work.

Karpathy stresses that you orchestrate and oversee. Both describe the same practice.

Vibe coding Agentic engineering
Who reads the diff Nobody You, at every step
What says “done” The demo works The checks pass, and you can explain the change
Size of one step The whole feature in one prompt One small step per prompt
What the agent does alone Everything, accepted unread As much as the task’s risk allows
Fits Prototypes and throwaway tools Software other people depend on

Figure 1: vibe coding and agentic engineering can use the same agent; what differs is what you check, and how much you let the agent do alone.

Why did the name arrive in 2026? On February 25, 2026, Karpathy wrote that “coding agents basically didn’t work before December and basically work since” (his post on X).

In the same post he gave the limits. The agent still needs a person’s direction, judgement, taste and oversight. It works best, he wrote, on tasks that are well specified and whose results you can test. That condition is the center of this module’s lab.

Rule: Vibe coding and agentic engineering can use the same agent; the difference is whether you decide, check and can explain what it writes.

Karpathy at AI Ascent 2026: the floor and the ceiling

On April 29, 2026, Sequoia published Karpathy’s conversation with Stephanie Zhan at its AI Ascent 2026 event, under the title From Vibe Coding to Agentic Engineering. It’s the same title as this module, and the talk is the clearest statement of the idea. The next day he posted a summary and a cleaned-up transcript (Sequoia Ascent 2026 summary, April 30, 2026).

His post says Codex 5.5 wrote both from the video, and that he read them and found no “glaring mistakes”. So the quotes in this section come from that posted text, not from his exact spoken words.

Two ways to build with agents

The summary puts the two ideas side by side:

“Vibe coding raises the floor. It lets almost anyone create software by describing what they want.”

“Agentic engineering raises the ceiling. It is the professional discipline of coordinating fallible agents while preserving correctness, security, taste, and maintainability.”

The literal claim is about who gains. Vibe coding lets people who can’t program build small things. Agentic engineering lets engineers build larger things with agents, without losing quality.

The summary is plain about where each belongs: “Vibe coding is fine for prototypes and personal tools. Agentic engineering is what serious teams need.”

The transcript adds what doesn’t change: “You are still responsible for your software, just as before.” And: “You are not allowed to introduce vulnerabilities because of vibe coding.”

Why the agent still needs you

He calls agents “spiky entities. They are fallible and stochastic, but extremely powerful.” “Spiky” is the jagged intelligence of Module 2, in which a model is strong at some tasks and weak at others that look close to them. His conclusion follows from it: “To the extent models remain jagged, it means you need to be in the loop.”

He also used an analogy: “Right now the agents are like interns. You still have to be in charge of aesthetics, judgment, taste, and oversight.” The literal fact is that the agent writes code that runs, and a person decides whether it’s the code the project needs.

About the code he sees, he said it “can be bloated, copy-pasted, awkwardly abstracted, brittle. It works, but it is gross.”

What changed, in his account, was December 2025: “with the latest models, the chunks just came out fine.” He kept asking for more, and “I couldn’t remember the last time I corrected it.” That’s one person’s experience, not a measurement.

A mistake agents still make

Module 1 told the 2025 version of this story, from his MenuGen app. At Ascent he told it as an agent’s mistake: “My agent tried to assign purchased credits by matching the Stripe email address to the Google email address. But those can be different emails.” A buyer could pay and never get the credits.

The fix was a persistent user ID, and he added: “This is the kind of mistake agents still make.” The summary calls it “plausible code, but bad system design”.

How would you catch it? Every test that uses one email address passes. Only someone who knows that a buyer can pay with one address and sign in with another writes the test with two addresses, and that test fails. Knowing what the system must do is the part that stays with you.

What an agentic engineer does

The summary lists the work:

“The agentic engineer does not blindly accept generated code. They design specs, supervise plans, inspect diffs, write tests, create evaluation loops, manage permissions, isolate worktrees, and preserve quality.”

That list is close to the plan of the rest of this course. Figure 2 shows where each item is taught.

Karpathy’s list Where this course teaches it
Design specs, supervise plans This module: plan mode, small steps, tests as the spec
Inspect diffs, write tests This module’s lab, then Module 8 (reviewing agent code)
Create evaluation loops Module 8 (evals for prompts and agents)
Manage permissions This module (permission modes), Module 7 (rules and hooks), Module 9 (sandboxes)
Isolate worktrees Module 10 (parallel agents in Git worktrees)
Preserve quality Every module from here on

Figure 2: the agentic engineer’s work, from Karpathy’s posted summary, and the module that teaches each part.

Two more points from the talk. He has doubts about one tool this module teaches: “I don’t even fully like “plan mode” as a concept, though it is useful.” He prefers to work with the agent “to design a detailed spec”. The lab does both, because its tests are the spec and plan mode is the tool.

He also said that “10x is not the speedup people can gain”, and that people who are very good at this can go much higher. That’s his opinion, and the talk gives no measurement for it. Module 10 looks at what studies have measured.

Rule: In Karpathy’s account, agents now write most of the code; the person who ships it still answers for its correctness, security and design.

What Claude Code is underneath

Claude Code is Anthropic’s coding agent, a program that runs in your terminal or editor, calls a Claude model, and reads, edits and runs code in your project. This module uses v2.1.330, released November 20, 2026 (changelog, checked 2026-11-22). It costs money, because it needs a Claude subscription, a Claude Console account with pre-paid credits, or a supported cloud provider (pricing).

The same loop as agent.ts, with more around it

Willison describes a coding agent as “LLM + system prompt + tools in a loop” (How coding agents work). That’s your agent.ts from Module 4. The Claude Code docs describe the same loop in three phases: gather context, take action, verify results (How Claude Code works).

The docs call everything around the model the agentic harness. A harness is the program around a model that holds the conversation, offers the tools, runs the tool calls and decides what goes into the context window. agent.ts is a small harness of about 300 lines. Claude Code is a large one, and Figure 3 compares them part by part.

Part Your agent.ts (Modules 4 and 5) Claude Code v2.1.330
Loop runTask: call the model, run the tools, repeat until end_turn The same loop
Tools list_files, read_file, edit_file, run_command, plus MCP tools Read, Edit, Write, Bash, WebFetch, WebSearch and more, plus MCP tools
Editing edit_file: old_str must appear exactly once Edit: old_string must appear once, unless replace_all is set
Asking you y/N before every command The permission mode decides what asks
Stopping MAX_STEPS, 20 by default Runs until the model ends its turn; Esc stops it
Context The history only grows Its own system prompt, instruction files and memory; compacts near the limit
Undo None A checkpoint for every prompt; /rewind
Between sessions Nothing kept The model still remembers nothing; files on disk are loaded again

Figure 3: Claude Code runs the loop you wrote in Module 4; most of its extra code decides what the model sees and what may run.

The Edit row shows how close the two are. Claude Code’s Edit “performs exact string replacement” and “doesn’t use regex or fuzzy matching” (tools reference). That’s the rule you wrote into edit_file, with the same failure when the text has changed. The tool names are exact strings, and Module 7 uses them in permission rules.

If the loop is the same, why use Claude Code at all? Because the parts around the loop are what let it run for many steps on a real project. They are the permission modes, the context management, checkpoints and plan mode, and the rest of this module teaches them.

What fills the context window

Your prompt is a small part of what Claude Code sends. Before the first word you type, the window holds Claude Code’s system prompt and tool definitions, information about your environment, and your instruction files. The docs give one example of these start-up costs: a system prompt of 4,200 tokens, 280 tokens of environment information, and 450 tokens of skill descriptions (context window). Type /context in a session to see your own.

Claude Code's context window, top to bottom

+--------------------------------------------+
| system prompt (Claude Code's own)          |
| tool definitions: Read, Edit, Bash, ...    |  sent with every
| environment information                    |  request, before
| instruction files and memory (Module 7)    |  your prompt
| skill descriptions, MCP tool names         |
|--------------------------------------------|
| user: your prompt                          |
| assistant: tool calls                      |  grows with
| user: tool results (files, test output)    |  every step
| ... more steps                             |
+--------------------------------------------+
Near the limit, compaction replaces the older steps with a summary.

Figure 4: what Claude Code puts in the context window; the top part is there before you type.

Compaction is replacing the older part of a conversation with a summary when the context window is nearly full, so the session can go on. Most current models have a window of 1M tokens, and the ones with a native 1M window compact at about 967K tokens by default (model configuration, checked 2026-11-22).

Compaction has a cost. The docs warn that “detailed instructions from early in the conversation may be lost” (How Claude Code works). After compaction, Claude Code loads the system prompt, the project’s instruction file, its memory and any plan from plan mode again from disk. Anything you said only in chat may be gone, and Module 7 is about putting it in a file.

The same holds between sessions. Claude Code saves every message, tool call and result in a JSONL file under ~/.claude/projects/, but “each new session starts with a fresh context window”. The model is stateless (Module 2), so yesterday’s decisions reach today’s session only from files.

Claude Code isn’t the only coding agent. OpenAI Codex, Cursor, Gemini CLI and GitHub Copilot cloud agent differ mostly in three ways:

  • where the agent runs, on your machine or in a cloud sandbox
  • how you drive it, from a terminal, an editor or a GitHub issue
  • which instruction file it reads

Each one costs money through a plan or API use. The ideas in this module carry over to all of them, and the commands don’t.

The autonomy slider: permission modes

Claude Code can do anything your user account can do, so the first decision is how much it may do without asking you. In his June 2025 talk at Y Combinator’s AI Startup School, Karpathy described this decision for tools like Cursor (Software Is Changing (Again)).

His examples went from tab completion, where you stay in charge, to an edit of a selected chunk and a change to a whole file. At the far end, an agent works across the whole repo. You choose the setting by how hard the task is.

The autonomy slider is Karpathy’s name for the setting of how much an AI tool may do before a person approves it, chosen task by task. His examples were Cursor and Perplexity, not Claude Code, so the mapping below is this course’s, not his or Anthropic’s.

In Claude Code, the slider is the permission mode, the setting that decides which tool calls run without asking you (permission modes, checked 2026-11-22). Figure 5 lists them from the least the agent does alone to the most, with plan mode last because it’s a different kind of setting.

Mode Status bar Runs without asking Fits
Manual (default) ⏸ manual mode on Reads, and a built-in set of read-only commands Code you don’t know yet, risky changes, watching what the agent does
acceptEdits ⏵⏵ accept edits on Reads, file edits, and common file commands (mkdir, mv, cp, rm, sed) in the folder Small steps with tests as a net, reviewed with git diff after
auto ⏵⏵ auto mode on Everything, with a classifier checking each action Tasks where you trust the direction
dontAsk ⏵⏵ don't ask on Only tools you allowed in advance; the rest is denied Scripts and CI
bypassPermissions ⏵⏵ bypass permissions on Everything Only inside a container or a VM
plan ⏸ plan mode on Reads; other commands go to the classifier or ask you; no edits until you approve a plan The start of a change (see “Planning in small steps”)

Figure 5: Claude Code’s permission modes, from the least the agent does alone to the most; plan mode is a separate setting.

To change mode during a session, press Shift+Tab. From auto mode, the first press goes to Manual, then to acceptEdits, then to plan. To start in a mode, run claude --permission-mode <mode>, where manual also works for default.

Older tutorials say Claude Code asks before every edit. That stopped being true in v2.1.283, released September 25, 2026. Since then, a plain claude session starts in auto mode, on every plan and provider.

Before v2.1.228 it started in Manual. So look at the status bar before you trust any tutorial, this one included.

Auto mode, and what it misses

Auto mode is the permission mode in which a second model, a classifier, reviews each action before it runs and blocks actions that go beyond your request. Your own allow, ask and deny rules apply first. Then reads and edits inside the working folder run, and everything else goes to the classifier. By default it blocks actions such as curl | bash, a force push, git reset --hard, production deploys and migrations, and sending sensitive data out.

Anthropic launched it on March 24, 2026 (Auto mode for Claude Code). The engineering post gives the reason: permission prompts caused “approval fatigue”, and “users accept 93% of them anyway” (How we built Claude Code auto mode, March 25, 2026).

The same post measures what it misses. On 52 real “overeager” actions from Anthropic’s own use, the classifier let 17% through, which the post calls “the honest number”. On 10,000 real internal actions, it blocked 0.4% that were fine.

Both sets come from Anthropic’s internal traffic, and the overeager set is small. The docs draw the conclusion: “Auto mode reduces permission prompts but does not guarantee safety.”

It also costs time and money. Each classifier call adds a round trip, and on API and Enterprise accounts it counts toward your token use. It needs a supported Claude model, so it isn’t there when Claude Code talks to a local model.

The far end: headless mode

Headless mode is running Claude Code with claude -p "<prompt>", which sends one prompt, prints the result, and has nobody there to answer a permission prompt (headless). Since v2.1.302 (October 16, 2026), a -p run with no mode set starts in Manual, and “calls needing approval are denied” unless you allowed them in advance.

The docs’ example for CI allows two things and nothing else:

claude -p "run the test suite" --permission-mode dontAsk --allowedTools "Bash(npm test)" "Read"

Here no person is in the loop, so the agent may run npm test and read files, and every other call is denied. The slider is at its far end, and the list you wrote is the only control.

So which mode should you use? The one in which a wrong action costs the least to notice and to undo.

Manual fits code you don’t know yet. acceptEdits or auto fits steps where tests and Git catch mistakes. Nothing broad fits actions that Git can’t undo, such as a database change or a deploy.

Rule: Pick the mode by what a wrong action would cost to notice and undo, and move it task by task, not once per project.

The generate and verify loop

In the same June 2025 talk, Karpathy described the work as a loop in which the AI generates and a person verifies. He said we should make that loop as fast as we can, in two ways: make verifying faster, and keep the AI’s tasks small. He called the second one keeping it on the leash. He said a diff of 1,000 lines isn’t useful to him, and that he works in small, incremental chunks.

The generate and verify loop is that cycle, in which the agent writes a change and something checks it before the next change. The check can be a test run, a type check, or you reading the diff.

Anthropic’s current best-practices page says what happens without a check: “Claude stops when the work looks done. If it has nothing to run that tells it whether the work actually is done, “looks done” is all it has to go on. In practice that makes you the test suite” (best practices, checked 2026-11-22). Its advice is to “Give Claude something it can run that comes back pass or fail”, and to ask for evidence: “the command it ran and its output”.

Module 1 quoted Karpathy on the same idea: LLMs “automate what you can verify”. For code, a check that passes or fails is what makes a change verifiable.

              generate                                    verify
(Developer) -- one small step --> [Claude Code] -- edits --> [[project files]]
     ^                                  |                          |
     |                                  +-- runs --> [npm test] <--+
     |                                                   |
     +---- reads the diff and the pass or fail output ---+
           then commits, and sends the next small step

Figure 6: the generate and verify loop; the tests check every step, and you check the diff before you commit.

For Omar’s feature, the check is a set of acceptance tests. An acceptance test is a test that states a business rule as the team decided it, written before the code, so that it decides when the feature is done. Each of Nina’s questions becomes one. This test answers the first:

test("SPRING10 takes 10% off the tickets, not the booking fee", async () => {
  const r = await quote([{ type: "standard", quantity: 2 }], "SPRING10");
  assert.deepEqual(r.body, { ticketsCents: 2160, bookingFeeCents: 150, totalCents: 2310 });
});

That’s an excerpt from the lab’s test/discount.test.ts. Two $12 tickets lose 10% each, $21.60, and the $1.50 fee stays. A version that took 10% off the whole order would return 2295, and the test would fail.

Who should write these tests? Willison’s guide suggests asking the agent itself for “red/green TDD”, which means it writes the tests first and confirms they fail before it writes the code (Red/green TDD). That works well for behavior you can describe exactly.

But a test the agent writes checks what the agent understood. When a rule is a business decision, such as whether codes stack, a person decides the expected numbers.

A check has a cost and a limit. Tests take time to write, and they catch only what they check. The MenuGen tests with one email address would all have passed.

Rule: Give the agent a check that passes or fails before you let it write; without one, you are the check.

Planning in small steps

Omar’s prompt asked for the whole feature at once. The result was one large diff, with every decision buried in it. Planning splits understanding from changing, and small steps keep each diff short enough to read.

Anthropic published this as a workflow in April 2025: explore, plan, code, commit (Claude Code: Best practices for agentic coding, April 18, 2025, archived copy). First you ask Claude to read the relevant files and not to write code yet. Then it makes a plan, then it writes the code, then you commit. Without the first two steps, the post said, Claude “tends to jump straight to coding a solution”.

The docs taught those four steps until October 27, 2026, with one limit: “If you could describe the diff in one sentence, skip the plan” (archived docs). On that day the page was rewritten.

It now says that “your first plain prompt in a fresh session already does the right thing”. It leans on auto mode and on giving Claude a check to run. Both versions agree on the core: understand before you change, and verify with something that passes or fails.

Plan mode is the permission mode in which Claude Code reads files, explores and writes a plan, but doesn’t edit your source until you approve the plan. You enter it with Shift+Tab, with /plan in front of a prompt, or with claude --permission-mode plan. When the plan is ready, you choose “Yes, and use auto mode”, “Yes, manually approve edits” or “No, keep planning”. Ctrl+G opens the plan in your text editor, so you can change it before Claude goes on.

Plan mode isn’t read-only. Claude can run shell commands to explore, such as npm test. If auto mode is available, the classifier reviews those commands; otherwise, any command outside the read-only set asks you first.

A plan helps most when its steps are small. Write it so that each step changes one file or one behavior. Then run one step per prompt, and end each step with the tests, a look at the diff and a commit. Each commit is a point you can go back to.

Planning has a cost too. It takes tokens and minutes, and for a one-line fix it’s waste. As Karpathy said in the last section, plan mode is one tool for the real job, which is agreeing on a spec with the agent before it writes.

Checkpoints, and what they can’t undo

Sometimes the agent goes the wrong way, and you want its changes gone. A checkpoint is a snapshot that Claude Code takes of the files its edit tools change, one for each prompt you send, which you can restore later (checkpointing, checked 2026-11-22). Type /rewind, or press Esc twice on an empty prompt, and choose a point.

You can restore the code, the conversation, or both. /rewind arrived in v2.0.0 (September 29, 2025), and Claude Code keeps the 100 most recent checkpoints.

What doesn’t a checkpoint undo? The docs list the gaps.

A file that only a Bash command changed “isn’t tracked and stays as it is”. That includes sed -i, a code generator, and npm install rewriting package-lock.json. And “actions that affect remote systems (databases, APIs, deployments) can’t be checkpointed.”

The second gap has a real example. In July 2025, during a public 12-day “vibe coding” experiment by Jason Lemkin, the Replit agent deleted a production database despite a code freeze (The Register, July 22, 2025). Replit’s CEO answered “Unacceptable and should never be possible”, and the company announced automatic separation of development and production databases. No undo button in the agent could have brought the data back.

So checkpoints “work alongside git rather than replacing it”, as the docs say. Commit before each step, so Git holds a state you trust. Keep production systems out of the agent’s reach, which is the subject of Module 9.

One step through Claude Code

This trace follows one prompt from the lab, step 8. You’ve approved a plan, chosen “Yes, manually approve edits”, and finished the plan’s first step. The status bar still says ⏸ manual mode on. You type:

Do step 2 of the plan only: read discountCode in src/routes/orders.ts.
Then run npm test and stop.

First, where Claude Code’s parts sit. Figure 7 redraws the agent loop of Modules 4 and 5 for Claude Code. Only the permission check is new.

                      context window
                    +-------------------+
                    | tool definitions  |    tool_use           tools
                    | system prompt     |-->[Model]-->[check]-->[Read]
(Developer) task -->| user: task        |            NEW |      [Edit]
     ^      ^       | assistant: calls  |                |      [Write]
     |      |       | user: results     |<- tool_result -|----- [Bash]
     |      |       | ... more steps    |                |      [MCP tools]
     +- answer -----| assistant: answer |                |           |
            |       +-------------------+                |           v
            +----------------- "Allow?" -----------------+   [[project files]]

[check] compares each tool call with the permission mode: it runs the
call, blocks it, or asks you first. In auto mode, a classifier decides.
Everything except [Model] runs in Claude Code, on your machine.

Figure 7: Claude Code runs the same loop as agent.ts; the new part is the check between the model’s tool call and the tool.

Figure 8 shows the messages of this one step in order.

(Developer)       [Claude Code]          [Claude API]     [[project files]]
     |-- prompt ------>| checkpoint            |                  |
     |                 |-- 1: request -------->|                  |
     |                 |<- tool_use Read ------|                  |
     |                 |-- read orders.ts, no question ---------->|
     |                 |-- 2: + tool_result -->|                  |
     |                 |<- tool_use Edit ------|                  |
     |<- Allow edit? --|                       |                  |
     |-- yes --------->|-- write orders.ts ---------------------->|
     |                 |-- 3: + tool_result -->|                  |
     |                 |<- tool_use Bash ------|                  |
     |<- Allow Bash? --|                       |                  |
     |-- yes --------->|-- npm test: 13 pass -------------------->|
     |                 |-- 4: + tool_result -->|                  |
     |                 |<- end_turn, summary --|                  |
     |<- summary ------|                       |                  |

Figure 8: one prompt in Manual mode; reads run, and the edit and the test run each wait for your yes.

The prompt. Claude Code takes a checkpoint, then builds request 1. It holds the system prompt, the tool definitions, the environment, the conversation so far (the plan and step 1) and your prompt.

Read. The model is likely to start by reading the route, with a tool_use block like the first one below. Reads need no approval in Manual mode, so Claude Code runs it and sends the file back, with line numbers, as a tool_result in request 2.

{ "type": "tool_use", "id": "toolu_...", "name": "Read",
  "input": { "file_path": "/home/you/tinytickets-mini/module-06/src/routes/orders.ts" } }

{ "type": "tool_use", "id": "toolu_...", "name": "Edit",
  "input": { "file_path": "/home/you/tinytickets-mini/module-06/src/routes/orders.ts",
             "old_string": "const { showId, lines } = req.body ?? {};",
             "new_string": "const { showId, lines, discountCode } = req.body ?? {};",
             "replace_all": false } }

{ "type": "tool_use", "id": "toolu_...", "name": "Bash",
  "input": { "command": "npm test", "description": "Run the test suite" } }

Those are the shapes of three calls, with the field names from the hooks reference. The id values are placeholders, and a real model may split the edit into several calls. They are the same tool_use blocks as in Module 4, with Claude Code’s tool names and absolute paths.

Edit. An edit needs approval in Manual mode, so Claude Code shows you the change and asks. This is your verify step for the code. Read it the way you’d read a colleague’s change, and say no if it does something the plan didn’t say.

Bash. npm test isn’t in the read-only set, so it asks again. With step 1 and step 2 done, all 13 tests should pass, and the output goes back as a tool_result in request 4.

The answer. The model reads the test output, replies with a summary and stop_reason: "end_turn", and the turn ends. Claude Code doesn’t commit for you here. You run git diff yourself, and you commit only what you can explain.

When you run this step in the lab, compare your own permission prompts with this trace. Your agent may read more files, or edit in several calls. The pattern stays the same: reads run, and changes wait for you.

Lab: vibe code it, then engineer it

Time: about 30 minutes. You’ll build Omar’s discount feature twice on the sample repo. First you vibe code it and run the team’s rules against it. Then you build it again with tests first, a plan, and small steps you approve and commit.

You need:

  • Git and Node.js 26 LTS (v26.13.1), as in Module 4. Node runs the repo’s .ts files directly.
  • Claude Code v2.1.330 or later. Install it with curl -fsSL https://claude.ai/install.sh | bash on macOS, Linux or WSL, or irm https://claude.ai/install.ps1 | iex in Windows PowerShell (quickstart). Check with claude --version.
  • A Claude plan or Console credits, which cost money (pricing). Sign in with one of them when Claude Code asks. Or use Ollama for free (see the note at the end of the lab).
  • A second terminal, for the commands you run yourself.

Model: Claude Code’s default model for your account. Note which model your session uses, because the agent’s output depends on it. With a later model, the steps stay the same, and the agent’s output changes.

The outputs this lab describes are what to look for, not copies of a real run. Your agent’s words, plans and file lists will differ, so check each step against what it tells you to look for.

Step 1: get the sample repo and start green

Why: you need a known good start, so any failure later comes from the agent’s change.

If you still have Module 4’s folder named tinytickets-mini, rename it first. agent.ts and jobs-server don’t depend on its name, and Module 5’s .mcp.json stays in it, because this lab doesn’t use it.

mv tinytickets-mini tinytickets-fixture
git clone https://github.com/vespaiach/tinytickets-mini.git tinytickets-mini
cd tinytickets-mini/module-06
npm install
npm test

The repo is vespaiach/tinytickets-mini on GitHub. It holds one folder for each module from 6 to 10, each with the starting state of that module’s lab. Figure 9 shows the folder for this module.

tinytickets-mini/module-06/
  package.json                 "type": "module"; express; npm start, npm test
  .gitignore                   node_modules/
  src/
    server.ts                  starts the app on PORT (default 3000)
    app.ts                     createApp(): JSON bodies, the two routers
    store.ts                   in-memory data: the show "Songs of Spring",
                               $12; resetStore()
    repositories/
      show-repository.ts       listShows(), findShow(id)
    sales/
      booking-fee.ts           $1.50 for an order of fewer than 4 tickets
      pricing.ts               ticket types and quoteOrder(), in cents
    routes/
      shows.ts                 GET /shows
      orders.ts                POST /orders/quote
  test/
    helpers.ts                 start() the app on a free port; postJson()
    booking-fee.test.ts        2 tests
    pricing.test.ts            3 tests
    quote.test.ts              3 tests over HTTP

Figure 9: the sample repo’s folder for this module; routes call repositories for data and src/sales/ for prices.

The price rules live in one file, src/sales/pricing.ts. All money is in integer cents, so no price ever carries a rounding error from floating-point math:

import { bookingFeeCents } from "./booking-fee.ts";

export type TicketType = "standard" | "student" | "vip";
export type OrderLine = { type: TicketType; quantity: number };
export type Quote = { ticketsCents: number; bookingFeeCents: number; totalCents: number };

const STUDENT_PERCENT_OFF = 20;
const VIP_EXTRA_CENTS = 500;

// Price of one ticket in cents, before the booking fee.
export function ticketPriceCents(showPriceCents: number, type: TicketType): number {
  if (type === "student") {
    return showPriceCents - Math.round((showPriceCents * STUDENT_PERCENT_OFF) / 100);
  }
  if (type === "vip") {
    return showPriceCents + VIP_EXTRA_CENTS;
  }
  return showPriceCents;
}

// Every ticket, then the booking fee once for the whole order.
export function quoteOrder(showPriceCents: number, lines: OrderLine[]): Quote {
  let ticketCount = 0;
  let ticketsCents = 0;
  for (const line of lines) {
    ticketsCents += ticketPriceCents(showPriceCents, line.type) * line.quantity;
    ticketCount += line.quantity;
  }
  const feeCents = bookingFeeCents(ticketCount);
  return { ticketsCents, bookingFeeCents: feeCents, totalCents: ticketsCents + feeCents };
}

So a $12 ticket is 1200 cents, a student pays 960, and a VIP pays 1700. bookingFeeCents is Module 4’s function after its fix, which returns 150 for fewer than four tickets and 0 otherwise. The route POST /orders/quote takes { showId, lines: [{ type, quantity }] }, returns 404 for an unknown show and 400 for a bad line, and answers with the Quote.

You should see 8 tests pass and none fail, in the summary lines at the end of the output (pass 8 and fail 0). Then make a branch for the vibe attempt:

git switch -c vibe

Step 2: vibe code it (this step fails on purpose)

Why: you should see what accepting everything gives you, on code you can check.

Start Claude Code in module-06 with claude. The status bar should say ⏵⏵ auto mode on, so most actions run without asking. Type Omar’s prompt:

Add discount codes to POST /orders/quote, in a new field discountCode.
SPRING10 gives 10% off and FRIEND5 gives 5% off. Make it work.

Don’t read the diff. If Claude Code asks anything, say yes. When it says it’s done, go to your second terminal, start the server with npm start, and send Omar’s request from a third terminal:

curl -s -X POST localhost:3000/orders/quote \
  -H 'content-type: application/json' \
  -d '{"showId":"songs-of-spring","lines":[{"type":"standard","quantity":2}],"discountCode":"SPRING10"}'

You should see a quote with a total below 2550, though the fields and the exact total depend on what your agent wrote. The demo works. Stop the server with Ctrl+C.

Step 3: try to explain it

Why: Willison’s rule is that you commit only code you can explain.

Pause and predict. Without reading the diff, answer Nina’s three questions about your branch: is the fee discounted, what does SPRNG10 cost, and do the two discounts stack?

Then look at the size of the change:

git diff --stat

You should see a few files changed, and which files depends on your agent’s choices. Could you explain every changed line to Nina? Write down your three answers before the next step.

Step 4: run the team’s rules

Why: the team has decided the rules, and a check that passes or fails is the only fair way to compare your answers with the code.

Nina wrote the decisions down as tests. Create test/discount.test.ts:

import { test, before, after } from "node:test";
import assert from "node:assert/strict";
import type { Server } from "node:http";
import { start, postJson } from "./helpers.ts";

let server: Server;
let base = "";

before(async () => {
  ({ server, base } = await start());
});

after(() => {
  server.close();
});

// Quote a Songs of Spring order ($12 tickets) with a discount code.
function quote(lines: unknown[], discountCode: string) {
  return postJson(base, "/orders/quote", { showId: "songs-of-spring", lines, discountCode });
}

test("SPRING10 takes 10% off the tickets, not the booking fee", async () => {
  const r = await quote([{ type: "standard", quantity: 2 }], "SPRING10");
  assert.deepEqual(r.body, { ticketsCents: 2160, bookingFeeCents: 150, totalCents: 2310 });
});

test("a code ignores case and spaces", async () => {
  const r = await quote([{ type: "standard", quantity: 2 }], " spring10 ");
  assert.equal(r.body.totalCents, 2310);
});

test("an unknown code is a 400, not a full-price quote", async () => {
  const r = await quote([{ type: "standard", quantity: 1 }], "SPRNG10");
  assert.equal(r.status, 400);
});

test("a code does not stack with the student discount", async () => {
  const r = await quote([{ type: "student", quantity: 1 }], "SPRING10");
  assert.deepEqual(r.body, { ticketsCents: 960, bookingFeeCents: 150, totalCents: 1110 });
});

test("FRIEND5 takes 5% off a VIP ticket too", async () => {
  const r = await quote([{ type: "vip", quantity: 1 }], "FRIEND5");
  assert.deepEqual(r.body, { ticketsCents: 1615, bookingFeeCents: 150, totalCents: 1765 });
});

start() in test/helpers.ts starts the app on a free port with fresh data, and postJson() sends a request and returns the status and the parsed body. The five tests are Nina’s answers:

  • the fee keeps its full price
  • case and spaces don’t matter
  • a typo is an error
  • a student keeps 20% and gets no code
  • VIP tickets get the code

Run them:

npm test

You’re likely to see the 8 old tests pass and some of the 5 new ones fail. Check which ones fail on your branch. Your run will differ, because the model chose the rules this time, and it may choose others next time. Compare the failures with your answers from step 3.

Step 5: keep the attempt, and start over with Git

Why: Git can return the whole folder to a known state, and /rewind can’t. A checkpoint doesn’t restore files that npm install or other Bash commands changed.

Close the Claude Code session from step 2. Then run these in your second terminal, not through the agent. They’re your decisions, and auto mode blocks some Git commands, such as git reset --hard, by default.

git add -A
git commit -m "Vibe attempt"
git switch main
git switch -c engineered
git checkout vibe -- test/discount.test.ts
npm test

The commit keeps the vibe attempt on its branch, so you can compare it in step 10. git checkout vibe -- <file> copies the team’s test file onto the new branch and stages it.

Pause and predict. No discount code exists in src/ on this branch. Which of the five new tests pass?

Answer

One test passes, “a code does not stack with the student discount”. The route ignores discountCode, so a student ticket costs 960 with or without it, and the test sees exactly what it expects.

So a green test proves less than it seems. That test checks the rule only once the code reads the field. Before that, it passes for the wrong reason.

You should see 9 tests pass and 4 fail. Commit the red tests, so the rules come before the code in the history:

git commit -m "Add the discount rules as tests"

Step 6: plan first

Why: a plan splits understanding from changing, and lets you settle the decisions the tests don’t.

Start a new session in plan mode:

claude --permission-mode plan

The status bar should say ⏸ plan mode on. Type:

Read src/sales/pricing.ts, src/routes/orders.ts and test/discount.test.ts.
Plan the smallest change that makes test/discount.test.ts pass.
Split it into steps that each change one file, and list every decision
the tests don't settle.

You should see a plan with steps and a list of open questions, in your agent’s own words. Check whether it asks about rounding, where the codes live, and what a blank or missing code does. The tests settle none of these.

Press Ctrl+G to open the plan in your editor, and write the team’s decisions into it:

Decisions:
- The codes live in a new file, src/sales/discounts.ts.
- Each standard or VIP ticket loses the code's percent, rounded to whole
  cents with Math.round. Student tickets keep their 20% and get no code.
- A missing or blank discountCode means no code. Any other unknown value
  is a 400.
Steps:
1. Add src/sales/discounts.ts, and a percentOff parameter to quoteOrder.
2. Read discountCode in src/routes/orders.ts.
Work rule: do one step at a time. After each step, run npm test, then
stop and wait for me.

Save and close the editor. When Claude Code asks how to go on, choose “Yes, manually approve edits”. The status bar should now say ⏸ manual mode on.

Step 7: do step 1, and approve each edit

Why: one file per step keeps each diff short enough to read before you approve it.

Claude may start on step 1 of the plan as soon as you approve it, and the work rule tells it to stop after that step. If it waits for you instead, type:

Do step 1 of the plan only. Then run npm test and stop.

Read each edit before you approve it, and say no to anything the plan doesn’t contain. When it stops, you should see the 9 earlier passes still passing and the 4 discount tests still failing, because the route doesn’t read the code yet. Check the counts in your test output.

In your second terminal, read the whole change and commit it:

git diff
git add -A
git commit -m "Discount codes in pricing"

Step 8: do step 2, as in the trace

Why: this is the step the trace followed, so you can match each permission prompt to a tool_use block.

Stay in Manual mode. Type the prompt from the trace:

Do step 2 of the plan only: read discountCode in src/routes/orders.ts.
Then run npm test and stop.

Reads run without a question. Read the edit before you approve it, then approve npm test. You should see all 13 tests pass. Review with git diff in your second terminal, then commit it with the message “Discount codes in the quote route”.

Once you trust the tests, the next notch along the slider is acceptEdits. Edits then run without a question, npm test still asks, and you review with git diff after the step. Try it on your next small task.

One version that passes (written for this page; your agent’s will differ)

src/sales/discounts.ts:

// Percent off for each discount code.
const CODES = new Map<string, number>([
  ["SPRING10", 10],
  ["FRIEND5", 5],
]);

// The percent off for a discountCode field from a request.
// A missing or blank code is 0. An unknown code is null.
export function percentOffFor(code: unknown): number | null {
  if (code === undefined || code === null) {
    return 0;
  }
  if (typeof code !== "string") {
    return null;
  }
  const key = code.trim().toUpperCase();
  if (key === "") {
    return 0;
  }
  return CODES.get(key) ?? null;
}

In src/sales/pricing.ts, quoteOrder takes the percent and leaves student tickets alone (excerpt):

export function quoteOrder(showPriceCents: number, lines: OrderLine[], percentOff = 0): Quote {
  let ticketCount = 0;
  let ticketsCents = 0;
  for (const line of lines) {
    let unitCents = ticketPriceCents(showPriceCents, line.type);
    if (line.type !== "student") {
      unitCents -= Math.round((unitCents * percentOff) / 100);
    }
    ticketsCents += unitCents * line.quantity;
    ticketCount += line.quantity;
  }
  const feeCents = bookingFeeCents(ticketCount);
  return { ticketsCents, bookingFeeCents: feeCents, totalCents: ticketsCents + feeCents };
}

In src/routes/orders.ts, after the line checks (excerpt; it also imports percentOffFor):

const percentOff = percentOffFor(discountCode);
if (percentOff === null) {
  res.status(400).json({ error: "unknown discount code" });
  return;
}
res.json(quoteOrder(show.priceCents, lines as OrderLine[], percentOff));

Step 9: a headless check, at the far end of the slider

Why: in a script or in CI, nobody answers a prompt, so the allow list is the only control.

Close the session. Then run Claude Code headless, with only npm test and reads allowed:

claude -p "Run npm test and list any failing test names" --permission-mode dontAsk --allowedTools "Bash(npm test)" "Read"

You should see a short report that names no failing tests, worded in your agent’s own way. Now ask for something outside the list, with the same flags:

claude -p "Delete test/discount.test.ts" --permission-mode dontAsk --allowedTools "Bash(npm test)" "Read"

You should see a reply saying it couldn’t, because every tool that could delete the file is denied. Check how your reply puts it. The file is committed, so nothing is lost if your run differs. Check with git status.

Step 10: compare the two branches

Why: the same feature, built twice, shows what the method changed.

git diff --stat main vibe
git diff --stat main engineered
git log --oneline main..engineered

You should see three commits on engineered, in this order: the rules, then pricing, then the route. Compare the size of the two changes. Then answer for each branch whether you could explain every line to Nina, and which file states the team’s rules.

Ollama note. Claude Code can run against a local model through Ollama (Ollama’s Claude Code page, checked 2026-11-22). With Ollama v0.40.17 started as OLLAMA_CONTEXT_LENGTH=64000 ollama serve, either run ollama launch claude, or set ANTHROPIC_BASE_URL=http://localhost:11434, ANTHROPIC_AUTH_TOKEN=ollama and ANTHROPIC_API_KEY="", then run claude --model qwen3-coder (qwen3:8b on a 16 GB machine). Check whether Claude Code still asks you to sign in to Anthropic.

Expect three differences. Auto mode needs a Claude model, so the session starts in Manual and asks far more often; for step 2, start with --permission-mode acceptEdits and say yes to every command. Smaller models follow a plan less closely, and more of their edits miss, because the old_string doesn’t match. Ollama’s docs also say that hosted web search and some tool controls are “not fully supported”. Steps 6 to 9 should still work, more slowly. Check each step’s output against what it tells you to look for.

Going deeper

Glob and Grep may not be there

Claude Code’s tool list includes Glob and Grep, but on macOS, Linux and WSL they’re absent by default. Claude searches with find and grep through the Bash tool instead, and in its shell those two commands run built-in versions of bfs and ugrep (tools reference). On Windows, Glob and Grep are in the default set. It matters when you write permission rules or hooks, because a search shows up as a Bash call.

Advice that changed

The rewritten best-practices page drops two pieces of older advice. One was “The context window is your main constraint, manage it aggressively”, which mattered less once most models had 1M tokens and compaction was automatic. The other was the keywords “think hard” and “think harder”, which the effort setting from Module 2 replaced. Tutorials from 2025 still teach both.

The harness has bugs too

Version 2.1.47 (February 18, 2026) fixed “plan mode being lost after context compaction, causing the model to switch from planning to implementation mode” (changelog). A plan approved in chat could stop applying in a long session. It’s one more reason to keep the plan’s decisions in tests and commits, where no harness can lose them.

A short history of Claude Code

  • 2025-02-24: first public release, v0.2.9, a research preview. Willison notes it came three weeks after the vibe coding post.
  • 2025-05-22: v1.0.0.
  • 2025-09-29: v2.0.0, with /rewind.
  • 2026-01-07: v2.1.0, with the /plan shortcut.
  • 2026-03-24: auto mode.
  • 2026-09-25: v2.1.283, sessions start in auto mode.
  • 2026-10-16: v2.1.302, claude -p starts in Manual.

Common mistakes with a coding agent

  • Trusting that Claude Code asks before edits. Symptom: files change without a question. Fix: start with --permission-mode manual, or press Shift+Tab, and read the status bar.
  • Asking for the whole feature in one prompt. Symptom: a diff of hundreds of lines that you skim and accept. Fix: plan first, then one step per prompt, each ending with the tests.
  • Taking “done” without a check. Symptom: the agent says it works, and the first real input breaks it. Fix: give it a check that passes or fails, and ask for “the command it ran and its output”.
  • Expecting /rewind to undo everything. Symptom: package-lock.json or a file changed by sed stays changed, and a database change stays made. Fix: commit before each step, and keep the agent away from systems Git can’t restore.
  • Correcting a drifting session again and again. Symptom: the third correction fails like the first two. Fix: the docs’ advice, “Watch the first minute, press Esc the moment Claude drifts, and after two failed corrections run /clear and write a better prompt instead of a third.”
  • Using bypassPermissions on your own machine. Symptom: none, until the agent runs something you’d have refused. Fix: use it only inside a container or VM, as the docs require.
  • Forgetting the allow list in claude -p. Symptom: since v2.1.302, the run reports that it couldn’t run the tests. Fix: list exactly what it may do, such as --allowedTools "Bash(npm test)" "Read".

Check yourself

Scenario. Omar starts claude in module-06 and asks it to rename quoteOrder to priceOrder everywhere and to run npm install for a new package. Halfway through, he sees that it also changed the expected numbers in test/pricing.test.ts. He presses Esc, opens /rewind and restores the code to before his prompt. What is restored, what isn’t, and which two habits from this module would have made this safe?

Answer

Files changed by Claude Code’s edit tools are restored, so the rename and the changed test come back, if the agent used Edit or Write. What npm install changed through Bash, such as package.json, package-lock.json and node_modules, stays as it is, because checkpoints don’t track Bash changes.

Two habits would have made it safe. First, a commit before the prompt, so git switch or git checkout returns the whole folder. Second, Manual mode or a plan with small steps, so the change to the tests would have waited for Omar’s yes, and he would have said no.

  1. In one sentence each, what did Karpathy mean by vibe coding (February 2, 2025) and by agentic engineering (February 4, 2026)?
  2. Name two things Claude Code does that agent.ts doesn’t, and one thing both do the same way.
  3. What runs without asking in Manual mode, in acceptEdits, and in auto mode?
  4. Plan mode is on. Can Claude run npm test? Can it edit src/sales/pricing.ts?
  5. In step 5, why did one of the five discount tests pass before any discount code existed, and what does that tell you about a green test?
Answers
  1. Vibe coding is building with a model and accepting its code without reading it. Agentic engineering is directing coding agents while you keep oversight and the quality bar of professional software.
  2. It has permission modes, compaction and checkpoints (any two), and both run the same loop of model calls and tool calls, with an edit tool that replaces one exact string.
  3. Manual runs reads and read-only commands; acceptEdits adds file edits and common file commands in the folder; auto runs everything, with a classifier checking each action.
  4. It can run npm test to explore, after the classifier or you approve it; it can’t edit source files until you approve the plan.
  5. The route ignored discountCode, so a student ticket cost 960 either way; a test can pass for the wrong reason, so a green test proves only what it checks.

Cheat sheet

From vibe coding to agentic engineering

  • Vibe coding: accept the agent’s code without reading it; fine for prototypes and throwaway tools.
  • Agentic engineering: agents write, you decide, check and can explain every change you ship.
  • Underneath: Claude Code is a harness around the model, running the same loop as agent.ts.
  • Context: system prompt, tools and instruction files come first; compaction summarizes near the limit.
  • Slider: Manual, acceptEdits, auto, dontAsk, bypassPermissions; Shift+Tab or --permission-mode.
  • Defaults: claude starts in auto (v2.1.283+); claude -p starts in Manual (v2.1.302+).
  • Loop: tests first, plan mode, one step per prompt, then git diff and a commit.
  • Undo: /rewind restores edits by Claude’s tools; Git restores the rest; nothing restores remote effects.

Figure 10 is the module in one picture: the same feature built two ways.

Vibe coding                          Agentic engineering

(Developer)                          (Developer) -- tests first --> [[test/]]
     | whole feature, auto,          (Developer) -- plan, decisions
     | no review                                        |
     v                                                  v
[Claude Code]                                     [Claude Code]
     |                                      step 1, then step 2, each:
     v                                                  |
[[one large diff]]                                      v
     |                                             [npm test]
     v                                                  |
"the demo works"                     (Developer) reads git diff, commits

Figure 10: the same agent and the same feature; on the right, a person decides the rules, sees every step checked and commits only what they can explain.

Next, Module 7 stops the team from typing the same decisions into every session, with instruction files, skills, hooks and permission rules that the agent reads every time.

Sources