Your Starting Context

You may have noticed during the concept section, and even if you worked through the code, that I have a strong paranoia about what is in my context window at all times.

When you build AI-powered apps, you need to be really careful about every token you put in your context window to make sure the app runs efficiently and passes your evaluations. I inherited that context paranoia, and I take that into agent coding.

Now that the real work of the course is about to begin, I want to make sure we're all starting on a solid foundation. We can't include any bloat in our harness before we even kick off.

If we've got tokens that aren't supposed to be there in the context window, we are not going to have fun when we're using these coding agents, and you're not going to get the results you expect.

This demo uses Claude Code, but you can walk through this with any agent - you might just need to pass it the instructions below and achieve the same goals.

Resetting Your Config

The first step is to open your .claude directory in VS Code.

Then you're going to do two important things:

  1. Go to your settings.json file and rename it as settings-backup.json - this is a backup of your settings before you start the course.
  2. Rename your skills directory to skills-backup as well.

Everything that we've got inside your skills and inside your settings is now reset to defaults.

VS Code showing the .claude directory with settings.json and skills folder ready to be renamed

VS Code showing the .claude directory with settings.json and skills folder ready to be renamed

Go back to your AI Coding Crash Course repository and run your agent of choice. Next, run the /context command to visualize the current context.

What's In Your Baseline

/context

This shows you everything currently sitting in the context window - before you've sent any real messages.

Here's what a fresh session looks like with the default configuration:

CategoryTokens
System prompt3k
System tools17.9k
MCP tools (deferred)24.5k
System tools (deferred)16.9k
Skills2k
Messages8
Total~23k

That's around 23,000 tokens - before you've really sent any messages. The only tokens you used are the eight tokens it took to type /context.

Terminal output showing /context command results with 22.9k tokens used by default configuration

Terminal output showing /context command results with 22.9k tokens used by default configuration

As you can see, there are plenty of built-in skills here and built-in project stuff, which is expected. You also have a ton of MCP tools, which are loaded in from claude.ai - things like Figma, Gmail, Google Calendar, Google Drive, Slack, Todoist, and Zapier.

All of this adds up to around 23k tokens, even before you've really started working.

Your mileage may vary. Your agent harness might send fewer tokens than this by default, or you might notice that your config actually has tons of stuff you didn't even know was in there.

See The Difference

Now, just for fun, let me go back into my .claude folder and re-enable my settings.json and my skills directory.

I'll restart the agent and rerun /context to show you the difference.

/context

Now we're only at 6.6k tokens - we've managed to remove 16k tokens just through our settings.

CategoryTokens
System prompt2k
System tools3.5k
MCP tools (deferred)192
System tools (deferred)9.2k
Skills1.1k
Messages8
Total~6.6k
Terminal output showing /context command results with 6.6k tokens after custom configuration restored

Terminal output showing /context command results with 6.6k tokens after custom configuration restored

This is a crucial difference because it means you've got a whole lot more to work with inside the smart zone - the part of your context where the agent actually thinks and reasons. It just means you're feeling more efficient every single time you interact with the agent.

Why We're Doing This

A little note: we're not doing this in order to min-max token spend. We're not necessarily doing this to minimize cost. We are maximizing quality.

We're trying to extend the space inside our smart zone - the part of the context window where the agent actually thinks through your problem. The more space you have there, the better the reasoning.

You'll probably be shocked by what you find in your own configuration, especially if you've never looked there before.

Understanding Your Context

I want to give you the skills so that you can:

  • Look at your own context window usage and see what's there
  • Look at other people's configs and identify what really shouldn't be there

Hopefully you can inherit a little bit of my context paranoia - and with that, you'll get higher quality outputs.

Your Next Steps

If you're following along exactly, make sure you:

  1. Rename settings.json to settings-backup.json
  2. Rename the skills directory to skills-backup

We will not be using your default config for this course.

If you have anything else inside your context window that you just can't seem to get rid of, message in the Discord and we'll see if we can update these instructions for your specific case.


Nice work - I'll see you in the next one.

Quiz

You strip the MCP servers and extra skills out of your agent config, taking a fresh session from 23k tokens down to 6.6k. What is the main thing you gain?

  • More room in the smart zone, where the agent reasons
  • A cheaper session, because fewer tokens get billed
  • A faster startup, because less config has to load
  • A larger context window limit for this session
Answer
The aim is quality, not spend. Cost does drop a little, but that is a side effect rather than the reason. Startup speed is not what the trimming buys, and the size of the window itself does not move - trimming only changes how much of it is free for the agent to think in.

You want to see what is already sitting in your context window before you type a single real prompt. Which command do you run?

  • /context
  • /config
  • /compact
  • /clear
Answer
/context prints the breakdown - system prompt, tools, MCP tools, skills, messages - so you can see the baseline. /config opens settings rather than reporting usage, /compact squeezes a session that already holds work, and /clear empties a session without ever telling you what was in it.

Killing Bloat

Killing Bloat: Understanding Your Agent's Payload

Every request you send to your agent carries an invisible payload. Your tool schemas, system prompt, skills catalogue, and feature instructions all ship together — and you're billed for every token, every turn.

Before you type a single word, you're already paying a hefty bill.

The problem is visibility. The /context command breaks your window into categories, but it lumps all your tools together into one number. You can see the total, but not which single tool is eating the most tokens. To cut precisely, you need to see the actual payload.

Set Up The Request Logger

Your goal is to examine what actually gets sent on each request to your agent provider, then identify and cut the biggest offenders.

  • Start the request logger

Run the request logger in one terminal:

npm run request-logger

It asks which coding agent you use, and which model provider if your agent can use more than one. It can remember your answer, so it only has to ask once. It then prints the exact command for your agent, under the line "Run your agent in another terminal with:".

  • Point your agent at the logger

Copy and paste that command into a new terminal and run it. It is built for the agent you picked, so there is nothing to adjust. If your agent also needs a config file, the logger prints that above the command.

  • Clear old logs

Delete all files inside request-logger/logs/ so you start fresh.

  • Send a test message

In your agent, send a simple message:

Hello!

Wait for the reply. Then check request-logger/logs/ — you should now have a new log file (a .md render, plus .request.txt and .response.txt files).

VS Code showing the request-logger/logs/ directory with the new log files

VS Code showing the request-logger/logs/ directory with the new log files

Examine The Payload Structure

Now open the log file and explore what gets sent on every request.

  • Search for and read the system prompt

Search for <system-prompt> inside the log file. Spend time understanding what's there.

Pay special attention to: - The Environment section — this tells the agent about your OS, shell, and working directory - The Context management section — how the agent handles long conversations - Any recent git commits (if you're using an agent like Claude Code)

  • Review all available tools

Find the <tools> section. Every tool available to your agent has its own definition here.

As you scroll through, notice: - How many tools are listed (you'll likely see 70+ definitions) - Which tools you've actually heard of (Artifact, Bash, etc.) - Which tools are completely unknown to you — read their descriptions. Some will be obscure: CronCreate, DesignSync, EnterPlanMode, Workflow - How large some of these definitions are — there's a lot of redundant text explaining commit message formats, PR templates, and feature flags

  • Look for MCP tools

Search for mcp__ in the file. These are Model Context Protocol tools attached via integrations.

You'll see tools like: - mcp__claude_ai_Figma__authenticate - mcp__claude_ai_Gmail__create_draft - mcp__claude_ai_Slack__authenticate - mcp__claude_ai_Google_Drive__search_files

Count how many of these are present. These tools ship on every request, whether you need them or not.

  • Check the skills list

Search for "following skills are available" to find the skills catalogue. You'll see a list of 15-20+ skills, each with a description.

Notice which ones are project-specific versus built into your agent by default.

Understand The Cost

  • Run /context in your agent

Check how many tokens your system is using across different categories (system prompt, tools, skills, messages).

The request logger's full markdown render of a single "Hello!" message is typically 4,000+ lines and 150-200 KB. That entire payload is sent and billed on every turn.

Now you understand the invisible cost of every request. The solution video will show you how to cut it down.

If the request logger isn't working with your agent of choice, reach out in the AI Hero Discord — we can help you set it up for your specific agent.

Killing Bloat Solution

The first step is to create a settings.json file inside your ~/.claude directory and initialize it with an empty object.

The instructions demonstrated here are agent-specific, but if you look at the written lesson below, you'll see harness instructions for removing bloat there too if needed.

The workflow

Every time you make a change to settings.json, the process is the same:

  1. Edit ~/.claude/settings.json
  2. Quit your agent
  3. Relaunch it
  4. Send a Hello! message
  5. Run the /context command
  6. Check the logs to see what's changed

To give us a baseline marker, let's run /context on a fresh start. We're starting at 68.3k tokens. That's really quite a lot.

Disable MCP connectors

The first thing to address is the MCP (Model Context Protocol) stuff. There's a bunch of Claude AI connectors that automatically enable if you're using Claude.ai.

Inside ~/.claude/settings.json, you can disable all of them in one go:

{
  "disableClaudeAiConnectors": true
}

After restarting and running /context, we've already dropped down to 47k tokens. That's 21k tokens saved with a single setting.

Disable workflows

Next, you'll notice there's a ton of configuration related to dynamic workflows. These orchestrate multiple sub-agents deterministically.

If you won't be using workflows, disable them:

{
  "disableClaudeAiConnectors": true,
  "disableWorkflows": true
}

Now we're down to 39k tokens.

Disable bundled skills

The bundled skills include deep research, data visualization, artifact design, config updates, and keybindings help. If you're not using any of them, disable them all:

{
  "disableClaudeAiConnectors": true,
  "disableWorkflows": true,
  "disableBundledSkills": true
}

This takes us down to 37.1k tokens — and kills skills usage completely.

Disable artifacts

There's a relatively new feature called Artifacts that you might not use at all. Turning this off is straightforward:

{
  "disableClaudeAiConnectors": true,
  "disableWorkflows": true,
  "disableBundledSkills": true,
  "disableArtifact": true
}

That's another 4k tokens gone, bringing us to 33.1k tokens.

Control tool access with permissions

Now for the big one: looking at the tool definitions themselves.

Here's the key principle: if you deny your agent access to a tool via permissions.deny, its definition is removed from the system prompt entirely. This isn't just a runtime block — it's a context saving on every single request.

Let's look at which tools you actually need:

ToolAsk yourself...Action
NotebookEditDo you need to replace, insert or delete cells in a Jupyter notebook?Probably not. Deny it.
DesignSyncDo you need to design, sync, read, and update Claude.ai design-system projects?No. Deny it.
CronCreate, CronDelete, CronListDo you need to create and manage cron jobs?Probably not. Deny all three.
EnterPlanMode, ExitPlanModeDo you need the agent to enter and exit plan mode?No. Deny both.
PushNotification, RemoteTriggerDo you need push notifications or remote triggers?No. Deny both.
ReportFindingsDo you need the agent to report findings?No. Deny it.
ScheduleWakeupDo you need wake-up scheduling?No. Deny it.

Add these to your settings:

{
  "permissions": {
    "deny": [
      "NotebookEdit",
      "DesignSync",
      "CronCreate",
      "CronDelete",
      "CronList",
      "EnterPlanMode",
      "ExitPlanMode",
      "PushNotification",
      "RemoteTrigger",
      "ReportFindings",
      "ScheduleWakeup"
    ]
  },
  "disableClaudeAiConnectors": true,
  "disableWorkflows": true,
  "disableBundledSkills": true,
  "disableArtifact": true
}

This takes us down to around 21.6k tokens.

One more tool to consider

There's one more tool worth disabling: AskUserQuestion. It's a very long tool definition (~130 lines), and some people love the UI while others find it intrusive.

{
  "permissions": {
    "deny": [
      "NotebookEdit",
      "DesignSync",
      "CronCreate",
      "CronDelete",
      "CronList",
      "EnterPlanMode",
      "ExitPlanMode",
      "PushNotification",
      "RemoteTrigger",
      "ReportFindings",
      "ScheduleWakeup",
      "AskUserQuestion"
    ]
  },
  "disableClaudeAiConnectors": true,
  "disableWorkflows": true,
  "disableBundledSkills": true,
  "disableArtifact": true
}

Removing it takes us down to under 20k tokens — around 19.9k. That's a good stopping point.

The attitude matters more than the specifics

This demonstration is agent-specific, but the attitude is what matters.

You have to be aware of all the tokens you're sending in your system prompt. You don't need to read every single one, but you need to notice if something's there that shouldn't be — because it affects every subsequent request.

Performing this kind of hygiene on your own tools and setup is really important. Notice that everything we removed here was stuff you weren't going to use anyway. It absolutely shouldn't be in there, influencing behavior and eating up precious tokens.

Your turn

Go and look at your own harness. See what you can remove from the system prompt while still retaining good behavior. Find your own harness-specific optimizations, and when you do, share them in the Discord.

Now you have a good base to start working from. Let's get building.

Showing Context in the Status Line

Claude Code doesn't show your context window usage by default. You need to set this up yourself if you want to monitor it constantly while you're coding.

Having that number right in your status line, visible at a glance, gives you the feedback you need to make good decisions about your session. We'll use ccstatusline, a community tool that formats Claude Code's session data into a clean status line.

Steps To Complete

Configure ccstatusline

  • Create the config directory
mkdir -p ~/.config/ccstatusline
  • Create ~/.config/ccstatusline/settings.json with this content:
{
  "version": 3,
  "lines": [
    [
      {
        "id": "1",
        "type": "context-length",
        "color": "yellow",
        "bold": true,
        "rawValue": true
      },
      {
        "id": "2",
        "type": "custom-text",
        "customText": "(",
        "color": "brightBlack",
        "merge": "no-padding"
      },
      {
        "id": "3",
        "type": "context-percentage",
        "color": "brightBlack",
        "rawValue": true,
        "merge": "no-padding"
      },
      {
        "id": "4",
        "type": "custom-text",
        "customText": ")",
        "color": "brightBlack",
        "merge": "no-padding"
      }
    ],
    [],
    []
  ],
  "flexMode": "full-minus-40",
  "compactThreshold": 60,
  "colorLevel": 2,
  "defaultSeparator": " ",
  "inheritSeparatorColors": false,
  "globalBold": false,
  "powerline": {
    "enabled": false,
    "separators": [" "],
    "separatorInvertBackground": [false],
    "startCaps": [],
    "endCaps": [],
    "autoAlign": false
  }
}

This configures four widgets on one line: a bold yellow token count (context-length), followed by a dimmed percentage in parentheses. The "merge": "no-padding" on the parentheses and percentage widgets glues them together without extra spacing, while "defaultSeparator": " " adds a space between the token count and the opening parenthesis. "rawValue": true strips the labels so you get clean numbers.

Update Claude Code Settings

  • Open ~/.claude/settings.json

If this file doesn't exist yet, create it.

  • Add the status line configuration
{
  "statusLine": {
    "type": "command",
    "command": "npx ccstatusline@latest"
  }
}

Preserve any other settings that might already exist in this file. Claude Code pipes session data to this command automatically - ccstatusline reads it and outputs the formatted status line.

Test Your Setup

  • Restart Claude Code completely

Close the application fully and reopen it.

  • Check your status line

You should now see a bold yellow token count followed by a dimmed percentage (like 186.2k (17.3%)) displayed in your Claude Code status line. These numbers update as your context window fills during your session.

Codebase Exploration

Every time an agent starts a fresh session with your codebase, it has to explore to find the information it needs. Statelessness is the hardest constraint to work around - the agent remembers nothing from previous sessions.

The quality of the agent's exploration directly determines the quality of what happens next. If it fails to find the information it needs, it probably won't do what you want.

So exploration matters. A lot. And making your codebase easy to explore is one of the most important things you can do.

What The Agent Already Knows

When you start a session, the agent gets some environment information automatically. Let's look at what that includes:

  • Platform (Linux, macOS, Windows)
  • Working directory (so it can guess something from the repo name)
  • Git repository status (branch, main branch, git user, recent commits)
  • Shell type (bash, zsh, etc)
  • Your assistant's knowledge cutoff date

That's actually quite helpful. But there's a critical gap.

What The Agent Doesn't Know

The agent gets no filesystem information at all. It doesn't have an ls of the current directory. It doesn't have a file tree. It has zero knowledge of what files actually exist in the directory.

So all the agent knows is:

  • The directory name
  • The vague environment it's operating in
  • Some recent commit names
  • Nothing about the actual filesystem

This is exactly where you are right now as someone learning this repo. You probably don't know much about the app we're building yet. You're in a similar place to your agent.

Steps To Complete

  • Open a terminal and run the request-logger proxy
npm run request-logger

It asks which coding agent you use, then listens on http://localhost:8787 and prints the exact command to start that agent through it.

  • Open a second terminal, then copy and paste the printed command to start an agent session through the proxy
  • Ask the agent about the project's tech stack and purpose
Tell me what the tech stack of this project is and what its intended purpose is.

Watch what happens as the agent explores:

  • Does it spawn subagents to help with the exploration?
  • Does it try to read through all the files itself?
  • How does it navigate the codebase?
  • Does it explore the filesystem? Read files? Make good guesses?
  • Ask follow-up questions to get more detail

Ask the agent to tell you more about:

  • The main purpose of each folder
  • What the core business logic does
  • What technologies are being used and why

Keep asking questions until you have a really detailed understanding of the codebase.

  • (Optional) Check the request logs

Open request-logger/logs/ and look at the most recent .md file. Jump to the # Environment section to see exactly what was passed to the agent. Notice what's included and what's missing.

Codebase Exploration Solution

Let's start by running an initial exploration prompt to see what happens. A lot of stuff will happen very quickly, so let's zoom out to get a better view.

What we're looking for is the number of files, the searches, and the tools that the agent uses to explore the directory. To see this in more detail, press Ctrl+O, this shows a more verbose version of the output.

Verbose output showing detailed tool usage

Verbose output showing detailed tool usage

Examining the verbose output and tool usage

Looking at the top of the output, just after the initial prompt was added, we can see the sequence of tools the agent used:

The first thing it reads is the README file. It then finds the package.json by running a bash command:

find . -name package.json -not -path '*/node_modules/*'

This is a Linux command that searches for package.json files while excluding the node_modules directory.

Once found, it reads the package.json file. It then reads two more files at once: the request-logger package.json and the request-logger README. This gives it all the information it needs to produce a tech stack table.

If we search inside the logs for "tool_result", we can see all the tool results. There are eight tags total, which means there are four tool results. The only files read were the main README, the package.json, and the files for the request-logger. This is really just a surface-level skim.

After this first exploration, the agent has only spent around 26.1k tokens, not that many at all.

Token count showing 26.1k tokens used

Token count showing 26.1k tokens used

Requesting deeper code analysis

Now let's ask it for a follow-up with a more detailed request:

Give me a much more in-depth understanding about the different parts of the app, the different modules inside it, and go ahead and read a ton of source code to give me more information.

By doing this, we're asking the agent to put in more effort and do more legwork. It says it's going to do a deep dive. It lists some directories, finds various areas, and starts reading files in parallel: schema, database, routing, services, and so on.

Agent reading multiple files in parallel

Agent reading multiple files in parallel

One interesting thing here is that the agent isn't opening up any sub-agents. It's reading all the files directly into the parent agent's context.

This process takes a while. The agent is working through extremely long amounts of raw code files. The amount of information it now has access to is much richer than before.

Understanding non-deterministic behavior

Because models are non-deterministic, sometimes the agent will explore by putting code directly into its main context window, but sometimes it will use sub-agents instead.

To show you what using sub-agents looks like, let's go back to where we gave the initial prompt for a more in-depth understanding. We'll add three words to the end of that request:

Give me a much more in-depth understanding about the different parts of the app, the different modules inside it, and go ahead and read a ton of source code to give me more information. Use subagents.

This explicit mention of sub-agents should prompt the agent to spawn sub-agents to do the exploration.

Prompt with 'Use subagents' instruction

Prompt with 'Use subagents' instruction

The divide-and-conquer approach

The agent first gets a quick map of the structure, then dispatches sub-agents to deep-dive different areas in parallel. Remember, we've rewound to the point where it only had the package.json and README. All the previous deep-dive information is gone from its context window.

The agent decides to divide and conquer. It splits the work into four areas and dispatches a sub-agent to deep-read each in parallel:

  • The data layer
  • The service layer
  • The routes/UI layer
  • The request-logger proxy
Four sub-agents dispatched for different areas

Four sub-agents dispatched for different areas

Looking at the bottom right, we can see all the tokens that these sub-agents are spending. This is a pretty expensive operation, we're at around 200k tokens and rising, spread across these four sub-agents.

Token counter showing 200k tokens across sub-agents

Token counter showing 200k tokens across sub-agents

From these sub-agents, we're going to get seriously rich detail. The way they work is they send back a summary of their findings to the parent agent.

Check out the routes/UI layer sub-agent alone, it uses 159k tokens just for that one area.

Once all four deep reads complete, we have extremely detailed information. The agent even spotted a deliberate architectural outlier, which is very clever.

Agent output identifying deliberate architectural outlier

Agent output identifying deliberate architectural outlier

The routes and UI layer is very deeply researched, the service layer has comprehensive coverage, and the request-logger is thoroughly documented. For all of that work by the sub-agents, the parent agent's context window only used around 65.1k tokens, that's remarkably efficient for analyzing the entire repository and chunking it down into a tiny summary.

Parent agent context showing only 65.1k tokens

Parent agent context showing only 65.1k tokens

How sub-agents report back

If we look inside the logs, we can find the summaries that come back from the sub-agents. They arrive as system notifications, automated background task events.

System notification from sub-agent in logs

System notification from sub-agent in logs

Here's what one sub-agent's report looks like. It comes through with an "UI layer overview" and gives a complete route map with all the different areas:

  • Public (unauthenticated routes)
  • Auth (outside app layout)
  • Purchase and redeem flows
  • Instructor (authoring tools)
  • Admin
  • Team
  • API endpoints
Sub-agent report showing complete route map

Sub-agent report showing complete route map

The report includes lots of pattern information and personas. It also contains a list of notable UI components and some developer experience features. Inside the report, there's extra information about key file paths, which is super critical, so the parent agent can just read those file paths if it needs to.

Key file paths section in sub-agent report

Key file paths section in sub-agent report

This is what a sub-agent reports back: an extremely detailed summary to the parent agent that's extremely dense in terms of token quality. You're not having raw files passed in here. It's a really well-crafted summary that the parent agent can then use to find relevant files if needed.

Why this pattern works

Most of the time on large repositories, this is how sub-agents work:

  1. The sub-agent reads a bunch of files
  2. It synthesizes all that information
  3. It reports back a summary, including key file paths and lots of detail, to the parent agent

The parent agent (the orchestrator) stays lean, while the sub-agents spend their tokens doing deep exploration and summarizing their findings.

Diagram showing orchestrator and sub-agent relationship

Diagram showing orchestrator and sub-agent relationship

The alternative is what we saw earlier, the agent just does its exploration itself, reading all the files directly into its own context.

Choosing your exploration strategy

Many prefer having sub-agents go off and do the exploration. This way, you keep a really tight context window in the orchestrator.

This is where paying attention to your starting context window pays off. If your starting context is really big, then you're going to pay that cost every time you open a sub-agent. Keeping it small means it's more economical and you get more time in the smart zone.

So it makes sense why exploration is so important and why using sub-agents for exploration is so effective, it lets you scale your understanding of large codebases while keeping token costs reasonable.

In the next lesson, we're going to show you a technique for learning any repository.

Good work, I'll see you in the next one.

The /teach Skill

Starting a new job, joining a new project, or exploring unfamiliar code is a challenge everyone faces. You need to understand the architecture, the libraries, the patterns - but you don't know where to start.

That's where agents shine. With the /teach skill, you can explore a codebase deeply and get a personalized explanation tailored to your experience level.

Steps To Complete

Set Up A Fresh Workspace

  • Create a new directory next to the course repo
mkdir ../ai-coding-learning
  • Open that directory in your code editor

Install The /teach Skill

  • Run the skills installer in your new directory
npx skills add mattpocock/skills

An interactive menu will appear.

  • Select only the teach skill using the spacebar, then press Return
  • Choose to install for your agent (Claude Code, or whichever agent you're using)
  • Install to the current directory only, not globally
  • Select symlink as the installation method when prompted
  • Confirm the installation when asked

You should now see a .claude/skills/teach folder in your file tree.

Run The Exercise

  • Clear your terminal
clear
  • Start your agent
claude
  • Run the /teach command with this structure:
/teach Teach me about this repo: ../ai-coding-crash-course I've done a little bit of vibe coding before. I know the basics of TypeScript. I've never worked in React before, and I'm not very clear about client and server, and certainly not about the database.

Replace the experience description with your own honest assessment of what you know and don't know.

The skill will analyze the repository and create a learning plan tailored to your level.

The /teach Skill Solution

The agent starts by looking through the directories and examining the actual codebase. It reads the readme and package.json, diving deeper than a surface-level scan.

No sub-agent gets spawned for this work — it's all exploration happening in the main context. Once it has explored enough, the agent says it's got a solid picture and is ready to set up the teaching workspace.

Setting up the teaching workspace

The /teach skill puts together several key files to ground your learning. Here's what gets created:

  • MISSION.md — Your learning goal and success criteria
  • NOTES.md — A learner profile describing what you know and what you don't
  • RESOURCES.md — Primary sources like official docs and community links
  • assets/lesson.css and assets/quiz.js — Shared stylesheets and quiz components that every future lesson reuses
  • lessons/ — HTML lessons designed for your exact level
  • reference/glossary.html — A reference doc you'll return to
  • learning-records/ — Stateful records of where you are in your learning journey

The agent has found primary sources and written them into RESOURCES.md. These include React Router v7 docs about data loading and actions, along with other official documentation.

MISSION.md file showing the learning goal: understanding the AI Coding Crash Course codebase

MISSION.md file showing the learning goal: understanding the AI Coding Crash Course codebase

The first lesson: The Round Trip

The agent creates a glossary and generates the very first lesson, then opens it for you to read.

Lesson 01: The Round Trip
What actually happens between typing a URL and seeing a page —
traced through one real file in your repo.

The lesson is formatted and designed exactly for where you need to be. It references the exact URLs in the application and describes them in the idiomatic language that the official docs use.

The Round Trip lesson HTML page open in browser

The Round Trip lesson HTML page open in browser

Here's what the lesson walks you through:

StepWhat happensWhere
1Router matches the URL against a literal list of patternsServer
2The loader function runsServer
3The component rendersServer
4The browser paints the HTMLClient
5Hydration happensClient

The line route("courses", "routes/courses.tsx") in app/routes.ts tells you that the path /courses is handled by that file.

The tricky bit: Same component, two machines

There's an important callout in the lesson. In steps 3 and 5, the same component function runs twice — once on the server, and once in the browser. The loader, by contrast, runs only on the server, every single time.

This asymmetry is the core concept you need to understand.

When the lesson shows you the real file, it strips away everything but what matters:

// app/routes/courses.tsx

export const loader = async (args: LoaderFunctionArgs) => {
  // ...
};

export default function CourseCatalog() {
  // ...
}

export const ErrorBoundary = () => {
  // ...
}

export const meta = () => {
  // ...
}

Those export names — loader, default, ErrorBoundary, meta — are a contract. React Router looks them up by exact name. Renaming loader to fetchData would break everything.

Testing your understanding with quizzes

The lesson includes interactive quizzes. Each question tests a single idea:

  1. Which file tells you that /courses is handled by courses.tsx?
  • The file app/routes.ts lists it
  1. How many times does the default-exported component run?
  • Twice: server first, then browser
  1. Where does a route's loader function actually execute?
  • Only on the server, every time
  1. Renaming loader to fetchData in a route file would...
  • Break it: the name is a contract
  1. Searching courses filters the list by doing what?
  • Re-running the loader on the server

Notice that each answer is the same length. The formatting doesn't give away clues about which one is right.

Interactive quiz showing multiple choice questions about React Router

Interactive quiz showing multiple choice questions about React Router

Do this now: Prove it to yourself

Reading is not learning. The lesson asks you to run the app and prove the boundary to yourself.

Add this to your loader:

console.log("LOADER RAN");

And this to your component:

function CourseCatalog() {
  console.log("COMPONENT RAN");
  // ...
}

Now predict: where will each log appear? The terminal? The browser devtools? Both? Run it and see what surprises you.

Stateful learning: You can clear context anytime

The /teach skill is designed to be stateful. It saves learning records into the learning-records/ directory — little markdown files that track exactly where you are in your journey.

MISSION.md grounds the agent in your goal. These two files together mean you can almost clear the context at any time and the agent will pick up exactly where you left off.

The agent is your teacher

Inside the teaching workspace, you can ask the agent follow-up questions:

  • "Why does the component run twice?"
  • "What breaks if I put a database call in the component?"
  • "What's LoaderArgs?"

Any of it. Half of learning a codebase is asking the question early instead of guessing for a week.

Getting the most from /teach

Take a break from the main course and work through the teach skill until you understand deeply everything about the codebase. Become an absolute expert in navigating it.

This gives you a massive leg up when you then go to implement features, which happens very soon.

This is the technique recommended for learning any new repository:

  1. Create a new teaching workspace just for that repo
  2. Tell the agent where you're at
  3. Tell it what you understand
  4. Tell it what you don't understand
  5. Let it teach you

The /teach skill works on all sorts of things. You can use it to learn how to solve a Rubik's Cube, how to feed your kids better food, or how to review an AI-generated codebase with confidence.

This is a good example of how to write a good skill.

Build a Feature

Commit Map
make-a-schema-change Start the lesson: the repo before any rating feature exists
course-star-ratings See my solution: the star rating system the agent built

You now understand the codebase and how exploration works. It's time to actually build something.

You're going to create a course review system where students can leave star ratings on courses. This is a deliberately meaty feature - it touches the database schema, migrations, service layer, routes, and UI components. But it's well scoped and doesn't demand complex UI work.

Before you start building, this exercise is a baseline for the rest of the course. You'll see what happens when you prompt an agent directly. Later lessons will teach you techniques to improve on this approach. For now, pay close attention to context usage as the agent works, and observe how your setup explores the codebase.

Your Task

Build a course review system with these requirements:

  • Students can leave a 1-5 star rating on courses (no written reviews yet)
  • Ratings appear as a global average visible to all users
  • The average rating displays on both the course list page and the course detail page
  • Students should see a way to select a star rating on the course page

Think about what the user will see, then work backwards from there.

Steps To Complete

Set Up Your Prompt

  • Open your agent in the repository

The repo is already set up and ready. You'll be prompting the agent to build the feature.

Think About the Feature

Before you write your prompt, consider:

  • Where should the star-rating widget appear?
  • How should the average rating be calculated and stored?
  • Which database tables and API routes will need to change?
  • Should there be any restrictions on who can rate (for example, should instructors be able to rate their own courses)?

Don't over-engineer this, just think through the user flow.

Write Your Prompt

  • Write a clear, concise prompt asking the agent to build the course review system

Keep it focused. Mention:

  • That students can leave a star rating (1-5 stars)
  • That ratings should be visible as an average on the course list and course page
  • That this is star-rating only (no written reviews)

Run the Build

  • Send your prompt to the agent and let it build

As the agent works, observe:

  • Context usage: Watch the context counter tick upward. What kinds of changes drain the most context?
  • Exploration: Does the agent spawn a subagent to explore, or does it explore in its main window?
  • File changes: How many files does it touch? Is it adding new files or modifying existing ones?

Verify the Feature Works

  • Run the dev server with npm run dev

Once the build completes, test the feature:

  • Log in as a student (use the dev UI to switch users if available)
  • Navigate to a course page
  • Find the star-rating widget
  • Leave a rating
  • Check that the average rating displays on the course list and course detail page
  • Verify the rating persists when you refresh the page

Observe the Baseline

  • Take notes on what happened

This is your baseline. In later lessons, you'll learn techniques to make this process smoother and more efficient. For now, document:

  • How many files were modified or created?
  • What was the quality of the implementation?
  • Did the agent make any assumptions you didn't expect?
  • What would you improve about this approach?

Build a Feature Solution

Commit Map
make-a-schema-change Start the lesson: the repo before any rating feature exists
course-star-ratings See my solution: the star rating feature, with the bundling bug fixed

The foundation for this session is a clear feature request: a course review system where students can leave star ratings (no written reviews, just ratings). These ratings should be visible everywhere courses appear, with average ratings shown on both the course list page and individual course pages.

Starting the Build

With a solid prompt in hand, the agent begins exploration. It starts by reading the codebase structure to understand how to implement this feature effectively. Within the first few interactions, it's already consumed about 20k tokens, exploring config files, testing files, and the overall structure.

Agent starting to explore the codebase structure

Agent starting to explore the codebase structure

Implementation Begins

The agent jumps straight into implementation with confidence, no clarifying questions asked. Here's the order it tackles the feature:

  1. Schema - Creates a course_ratings table in SQLite with fields for userId, courseId, and rating (1-5 whole numbers). It adds a migration script to apply the schema change.
  1. Service layer - Builds courseRatingService with functions like rateCourse (insert-or-update), findRating, and getCourseRatingSummary for calculating the average rating.
  1. Test coverage - Writes 17 tests for the service to verify behavior.
  1. React components - Creates StarRating for displaying average ratings and StarRatingInput for interactive rating submission.
  1. Integration - Wires the rating widget into the course list page and course detail page.
The generated schema showing the course_ratings table structure

The generated schema showing the course_ratings table structure

Verification and Testing

Rather than just shipping code, the agent goes the extra mile:

  • Runs the full test suite, 295 tests passing
  • Uses TypeScript's typecheck to verify all types are correct
  • Improves the seed script so test data includes ratings
  • Starts a dev server and performs smoke tests using curl

To verify the implementation actually works, it makes HTTP requests to the running dev server and greps the response for "Rated" text to confirm ratings appear on the pages.

curl -s http://localhost:5173/courses | grep -o 'Rated [^"]*' | head -5

This kind of automated verification shows the agent is thinking about whether its work actually solves the problem, not just whether it compiles.

The Build Summary

After all this work, the agent provides a summary of what was built:

  • Schema with a course_ratings table and unique index on (user_id, course_id) so users can only rate a course once
  • Service with validation, upsert logic, and batch lookup functions
  • Components for both displaying and submitting ratings
  • Integration into course list and course detail pages
  • Updated seed data with ratings for 6 courses
  • Full end-to-end verification

The entire feature consumed about 75k tokens, well within the "smart zone" for agent work.

Viewing the Results

The course list page now shows star ratings under each course

The course list page now shows star ratings under each course

Loading the application in the browser shows the ratings working as expected. Each course displays its average rating prominently.

The Critical Bug

But there's a problem. When testing interactively, the dev UI stops responding, the user switcher no longer works. Clicking to change a rating causes the entire page to refresh instead of updating instantly. Something is seriously wrong.

Browser console showing the promisify error

Browser console showing the promisify error

Diagnosing the Issue

Opening the browser developer console reveals the smoking gun: an uncaught TypeError: promisify is not a function. This is a classic React Router / Vite bundling issue.

Uncaught TypeError: promisify is not a function
    at node_modules/better-sqlite3/lib/methods/backup.js

The error shows that better-sqlite3 (the database driver) somehow got bundled into the browser JavaScript. The browser environment doesn't have Node.js utilities like util.promisify, so the code fails.

Posting the Bug Back

I copy the console error and paste it back into the agent with a message: "This is happening in the browser console, and it's making things go weird."

The Agent's Diagnosis

The agent quickly identifies the root cause:

Good catch, that's my bug. star-rating.tsx (a client component) imports MAX_RATING from courseRatingService, which imports the database module. That drags the whole database driver into the browser bundle.

The problem is architectural: client-side components shouldn't import from modules that depend on server-only code. While React Router normally strips out loader and action functions from the client build, it can't protect against a component directly importing from a service that uses the database.

The Fix

The solution is clean and minimal. Move the rating constants to a module with zero server dependencies:

// app/lib/ratings.ts
// Rating bounds live here rather than in courseRatingService so that client
// components can import them without pulling the database driver into the
// browser bundle.

export const MIN_RATING = 1;
export const MAX_RATING = 5;

Now star-rating.tsx imports from app/lib/ratings.ts instead of from the service. The component gets what it needs without triggering a massive dependency chain.

Verification After the Fix

After updating the code, the agent verifies the fix by:

  • Checking the Vite dev server's module transform output
  • Grepping the production bundle for better-sqlite3 (finds zero instances)
  • Testing the application again to confirm interactive features work
The course page now updates ratings instantly without full page refresh

The course page now updates ratings instantly without full page refresh

The dev UI responds properly, the user switcher works, and clicking a star to rate a course updates the average instantly instead of triggering a full page reload.

Summary: What Went Right and Wrong

AspectResult
ExplorationThorough, no subagent needed
ImplementationComplete end-to-end feature
TestingComprehensive: unit, type, integration, smoke tests
Token usage~75k for build, ~90k total (smart zone)
Production bugShipped a critical bundling issue
Bug fixIdentified and resolved quickly once feedback was provided

The agent demonstrated solid engineering practices: exploration, test-driven development, verification, and the ability to learn from feedback. However, it did ship a bug that broke interactive features, suggesting gaps in how it reasons about client vs. server boundaries in modern frameworks.

Overall, I would say not a great showing. However, I think there's definitely some improvements to be made, and we'll tackle those next.

Why Plan Mode Sucks

In our previous lesson, we saw how an agent behaves under normal conditions. The results were not great. What really troubled me was the pattern: the agent prompted, explored the codebase, then immediately began implementing.

There was no verification with us about whether it was building the right thing. There was no attempt at alignment between the AI and us.

In that run, we were actually lucky. The agent built the thing we wanted pretty well. There were some issues and a critical bug, but it worked. However, this rush to create an asset is really dangerous in AI and something I always try to slow down.

Plan mode: a buffer between exploration and implementation

Most agents ship with something called plan mode. The intention of plan mode is to have a planning session before any work is done. This planning session creates a plan document that you read, review, and then decide whether to continue (maybe with modifications). Only when you're happy with the plan do you proceed.

Let me show you how this works in practice.

npm run reset
Terminal output showing npm run reset

Terminal output showing npm run reset

This resets the codebase to the main branch, clearing out the existing course rating implementation from the previous lesson.

Next, I'll open up the agent and enable plan mode by cycling through the permission modes using shift+tab until the input footer reads "plan mode on".

Now I'll paste in the original prompt:

I would like to create a course review system where students can review courses by leaving a star rating. We don't want to add written reviews, just star rating. These reviews will then be visible everywhere that courses are visible. We want to show the average rating on the courses in the list page and on the course page itself.

After submitting, the agent should explore the codebase to understand the structure, then come back with a plan. This plan mode acts like a little buffer between exploration and implementation. A moment where we can align before continuing.

Agent exploring the codebase during plan mode

Agent exploring the codebase during plan mode

The plan it generates

Now the agent has finished exploration and is writing the plan. This is roughly how most agents handle plan mode. The behavior is similar across different tools.

I can view the plan by typing /plan:

Terminal showing the /plan command output

Terminal showing the /plan command output

This gives me a quite detailed output of everything the agent is going to do, along with some key decisions:

  • One user per rating per course - makes sense
  • Averages are computed on read - looks fine
  • Empty state: courses with zero ratings show "No ratings yet" rather than zero stars - makes sense
  • Who can rate: enrolled users only - makes sense

The critical issue: plan mode is still rushing

Here's the problem: instead of rushing to create an implementation, the agent rushed to create a plan which reads exactly like the implementation would.

It's given me the exact implementation it's going to do:

  • Database table structure
  • Service names and functions
  • Component names
  • Route modifications
  • Testing strategy

It's still rushing to create an asset. The plan is the asset now, not the code.

The root cause: sycophantic trait of agents

This feeling of premature completion, of rushing to get to the end, is a sycophantic trait of agents. When you tell it you want to produce something, it will go produce that thing.

It won't necessarily stop to make sure it's done the legwork to ensure you're aligned on how it should look.

This is really bad because it leads to a failure mode that happens constantly: the agent builds the wrong thing.

On a relatively simple feature like course ratings, it doesn't matter too much. But on a more complicated feature, it really matters.

What this means in practice

Imagine if a human developer behaved this way. They just said, "Yes, I know how to build that," and they went ahead and did it. There would be no alignment whatsoever. There would be no sense of a shared understanding being developed.

In the book "The Design of Design" by Frederick P. Brooks Jr. (the author of "The Mythical Man-Month"), there's a concept called the design concept.

A design concept is not an asset. It's the concept floating around in the room when humans are designing something. Everyone has a slightly different idea of it, but as conversations develop and you work towards understanding what you're building, everything starts to sharpen.

In both plan mode and the version we saw before, there's no design concept here. There's no moment to check in with each other to make sure we're actually aligned on what we're building.

We got an okay result the first time we ran it, but I guarantee on more complex features, this would quickly go wrong.

A different approach

The approach I've designed tries to sidestep this issue. It takes away the sycophantic asset rush. What you end up with, I hope, is a feeling of greater alignment with the agent - like you're both on the same page.

I'm going to explain that in the next lesson.

Quiz

You run a feature request in plan mode. The agent explores, then hands back a plan naming the database table, the service functions, the components and the testing strategy. What is wrong with that?

  • It rushed to an asset again - the plan is the implementation
  • It is too vague to review, so you cannot judge the approach
  • It skipped exploring the codebase, so the plan is guesswork
  • It cannot be changed, so you have to accept the plan as it is
Answer
The agent did explore first, and the plan is anything but vague - it is extremely specific, and you are free to modify it before continuing. That specificity is the problem: the decisions are already made and written down before any shared understanding was built with you.

You name a thing you want, and the agent goes and produces it without ever stopping to check that you agree on what it should look like. Which agent trait is this?

  • Sycophancy - producing whatever you asked for
  • Hallucination - inventing facts with no source
  • Non-determinism - behaving differently each run
  • Degradation - losing focus as a session grows
Answer
Nothing here is invented, so it is not hallucination. The behaviour is consistent rather than varying run to run, so it is not non-determinism, and it shows up immediately rather than after a long session, so it is not focus fading. It is the agent agreeing and delivering instead of aligning.

You and a colleague talk a feature through until you both picture it the same way, and nothing is written down. What do you have?

  • A design concept - shared understanding, not an artifact
  • A specification the implementation can be checked against
  • A plan document, just held in an informal spoken form
  • Nothing usable until one of you writes the decisions down
Answer
A spec and a plan are both assets - the thing here is deliberately not one. Nor is it worthless for being unwritten: the sharpening of that shared picture through conversation is exactly the step plan mode skips when it jumps straight to a document.

The Grill-Execute-Clear Loop

Commit Map
grill-me-skill Start the lesson: the /grill-me skill added to .agents/skills/
lesson-comments See my solution: lesson comments built from the grilled spec

Before you start building features, you need to understand what you're building. Most developers skip this step and rush straight into coding, which leads to wasted time and solutions that don't quite fit the problem.

The /grill-me skill forces you to pause. It interviews you relentlessly until you reach a shared understanding of what you're trying to build. Only then do you implement.

This is the grill-execute-clear loop. You grill until you understand. You execute the solution. You clear your mind and move to the next feature.

The Grilling Skill

The grilling skill works by building a design tree. Every decision branches into the decisions that hang off it.

It asks questions in rounds. The frontier is every decision whose prerequisites are already settled. The skill asks the whole frontier at once, then waits for your answers.

As you answer, the frontier expands. New questions unlock. Previously blocked decisions become answerable.

The session ends when the frontier is empty: every branch visited, nothing left silently assumed. Only then should you implement.

Your Task

Build lesson comments for the course platform. Students and instructors should be able to comment on individual lesson pages.

Imagine browsing to a lesson like "Connecting to a Database" or "CRUD Operations". On that page, students should be able to ask questions, share insights, and discuss the lesson content with other students and instructors.

This is deliberately open-ended, just like the previous exercise with course star ratings. But this time, instead of rushing to implement, you're going to use /grill-me to explore the feature space first.

The skill will ask you questions like:

  • Who can comment? Only enrolled students? Instructors too?
  • Can users edit or delete their own comments?
  • Should comments be threaded, or flat?
  • Do comments need moderation?
  • Should users get notifications when someone replies?

You might not have thought about all of these. That's the point. The grilling process surfaces the decisions you need to make before you write any code.

Steps To Complete

Get the Skill

  • Run npm run reset to pull in the /grill-me skill
npm run reset

This brings the repository up to the current lesson's commit, which includes the grilling skill in your .agents/skills/ directory.

Editor showing the grilling skill files after npm run reset

Editor showing the grilling skill files after npm run reset

Invoke the Skill

  • Clear your terminal and run your agent

In your agent harness, you'll invoke the skill differently depending on your setup. In agent code, it's typically / followed by the skill name.

  • Type / to open the skill picker, then select grill-me

This invokes the grilling skill and puts you into interview mode.

Terminal showing the skill picker with grill-me selected

Terminal showing the skill picker with grill-me selected

Start the Discussion

  • Write a loose, non-comprehensive prompt about lesson comments

You don't need to be thorough here. The agent will ask clarifying questions.

/grill-me
I want to add comments to lessons so students can ask questions and discuss.

This kicks off a discussion. The agent will start building the design tree and asking about the decisions that hang off this feature.

Work Through the Grilling

  • Answer each round of questions as the agent asks them

The agent will ask multiple questions per round. Answer them all before the next round begins. Your answers reshape the design tree and unlock new questions.

  • Keep going until the frontier is empty

When the agent says the session is done and you've reached a shared understanding, you're ready to implement.

This might take many rounds. That's the point. You're thinking through the problem before you code it.

Implement the Feature

  • Once you have a shared understanding, implement lesson comments

Now that you know what you're building, write the code.

  • Test your implementation in the browser

Students and instructors should be able to comment on lesson pages. The comments should persist and be visible to other users.

Verify Your Work

  • Run the app and navigate to a lesson page

Pick a course you're enrolled in. Find a lesson like "Connecting to a Database" or "CRUD Operations".

  • Add a comment as a student

Your comment should appear on the page.

  • Switch users and verify the comment is visible

The comment you added should be visible when you switch to a different user and return to the same lesson.

The Grill-Execute-Clear Loop Solution

Commit Map
grill-me-skill Start the lesson: the /grill-me skill added to .agents/skills/
lesson-comments See my solution: the full lesson comments feature

Starting with a loose prompt, you can use the /grill-me skill to align on a feature before you write a single line of code.

The Initial Prompt

The process starts simple. Tell the agent what you want to build:

/grill-me I would like to build a lesson comments feature.
I think students should be able to comment on lessons they
have access to. Instructors should also be able to comment
on them as well.

The agent immediately launches a background task to map your codebase. It does not wait for that exploration to finish - it starts asking questions right away. This is the non-blocking design pattern in action.

Round 1: The Strategic Questions

Questions arrive in rapid succession. These are not implementation details. They are design decisions.

First batch of grilling questions displayed

First batch of grilling questions displayed

The agent asks about purpose ("What is this feature actually for?"), not just mechanism. It explores edge cases ("What happens when nobody comments?"). It challenges assumptions ("Why gate commenting to students with access at all?").

Each question includes a recommendation. You do not have to follow it - your job is to think through it and decide.

How to Answer

You do not answer each question separately. You dictate one long paragraph, covering all the answers.

Here's the answer that I gave to the questions I received:

I would say this feature is for Q&A and support, with a bit of community and discussion.
I'd say that having a comment section that's healthy is really useful for students.
I think I don't mind a comments box with zero comments.
We probably want to design an empty state that looks nice and makes students not turned off from commenting, that encourages them to comment.
I am not actually the teacher in this situation.
This is for other teachers.
I think the expectation of a response should be there.
I think I would prefer to build it.
It's just weird to discuss a lesson that you can't see, and it's part of the paid-only perks.
To be honest, all three of those seem fine.
I think one table, one comments feature, the instructor gets a badge.
Yep, your recommendation makes sense.

The agent absorbs your answers and prepares the next round.

Round 2: The Implementation Layer

Second round of questions about threading model and comment behavior

Second round of questions about threading model and comment behavior

Now the questions dig into structure. Threading model. Edit permissions. Sorting. Notification strategy.

Here's the answer that I gave to the questions I received:

For the threading model, I think we just want a flat list, first of all.
I don't want to have an explicit resolution state.
I don't think we need that in v1.
The instructor should have a dedicated queue page on their dashboard that lists every unanswered question.
I guess, since we've decided that we're not having an explicit resolution state, it should be that every thread where there's a recent comment that they've not seen or not replied to.

When the Agent Pushes Back

During Round 3, the agent catches a contradiction in your answers:

Agent highlighting contradiction between flat list and queue requirements

Agent highlighting contradiction between flat list and queue requirements

You chose a flat list. You also chose no explicit resolution state. But you asked for a queue of unanswered questions.

With a flat list, every comment is top-level. Nothing points at anything else. How do you mark something as answered?

The agent forces a decision. It offers three options:

  1. Reinstate one-level replies (parent-child relationships)
  2. Keep flat, define "unanswered" at lesson level
  3. Keep flat, add explicit seen-state

You choose option 1. One-level replies make sense for an instructor-student dynamic.

The Real Bug Discovery

While you are answering questions, background exploration finishes. The agent uncovers a critical security issue:

Agent reporting XSS vulnerability in markdown rendering

Agent reporting XSS vulnerability in markdown rendering

The renderMarkdown function has no sanitization. Raw HTML passes straight through. A student could inject a script tag into a comment, and it would execute in the instructor's session.

The recommendation: create a separate renderComment() function with a restricted renderer. Only student comments need sanitization. Instructor comments can render full markdown.

You agree. This becomes part of the spec.

The Spec

By Round 4, the agent has enough information. It produces a written specification:

Agent producing complete written specification

Agent producing complete written specification

You do not need to read it. Your answers throughout the session have already encoded all the decisions. The spec is just a confirmation - proof that you and the agent share the same understanding.

However, if the grilling session took a weird twisty turn, you might want to skim it. In this case, everything feels aligned.

One Last Push

The agent makes one final objection about queue ordering:

Queue ordering - your reasoning argues against your choice. You want newest-first _so mis-flagged items float away._ But the queue only contains items with no staff reply. Nothing floats _away_; it floats _down_.

You do not need to respond. You just say:

Okay, let's start building.

The agent resolves it itself and moves into execution mode.

The Build Happens

No clearing of context. No starting fresh. You keep all the grilled context in the session and jump straight into implementation.

Agent building the feature while context remains in session

Agent building the feature while context remains in session

The agent churns for 14 minutes and 28 seconds. By the end, you have 362 tests passing, a clean typecheck, and a working feature in VS Code.

All of this happens while staying well under the context limit - the build ends at around 155k tokens, leaving room to spare.

Quality Assurance in the Browser

You open the feature in the browser. A student (Olivia Martinez) posts a comment:

Student posting comment on lesson

Student posting comment on lesson

You switch to the instructor (Marcus Johnson) and reply:

Instructor replying to student comment

Instructor replying to student comment

You can edit your own comments. The UI shows "(edited)" when you do:

Comment showing edited state

Comment showing edited state

You can delete comments. The system leaves a tombstone:

Deleted comment showing tombstone with reply still visible

Deleted comment showing tombstone with reply still visible

The instructor has a dedicated Questions queue:

Instructor questions queue page showing unanswered questions

Instructor questions queue page showing unanswered questions

Every unanswered question appears here. Olivia's "how are you?" is at the top. There is another question from Liam Thompson below it.

The instructor can reply inline, without leaving the queue page.

What Gets Built

The full feature ships:

  • A comments table in the database
  • A getAccess helper in access.server.ts (the shared guard from your code-quality question)
  • A sanitized renderComment() function in comment-markdown.server.ts with 19 tests
  • A commentService with 48 tests covering all the business logic
  • A comment thread UI component with an empty state
  • An instructor questions queue page at /instructor/questions
  • Seed data: 15 comments across 9 threads, 4 of which are unanswered

Everything is tested. Everything is typed. The working tree is dirty and ready for review.

Why This Works Better Than Direct Implementation

Without grilling, you might have built:

  • No empty state (what does zero comments look like?)
  • No instructor queue (instructors have to hunt through lessons)
  • No XSS sanitization (a real security hole)
  • A flat list with a seen-state (more complex than replies)
  • Full HTML rendering for students (dangerous)

Grilling made you think through all of that _before_ writing code. The implementation became trivial because the hard decisions were already made.

This is the power of alignment. The agent is not trying to be clever. It is trying to understand what you actually want, and it uses pressure (contradictions, edge cases, security issues) to force that understanding into the light.

Then it builds exactly what you agreed on.

The Loop

This is one cycle of the grill-execute-clear loop:

  1. Grill: Ask clarifying questions until you and the agent share a mental model
  2. Execute: Build the feature with confidence, context still warm
  3. Clear: Once the feature is done and committed, clear the context before the next task

The next time you work on something, you start fresh. The session history is gone. But the grilling session before it left you with exactly what you needed.

Compaction

When building features with an agent, you eventually reach the end of the "smart zone" - the part of the context window where your model works best. What happens next?

If you continue in that same session, results degrade slowly. The agent sends all previous tokens with every request. Those tokens are cheaper because they've been cached, but you're still operating in a higher latency, less capable environment.

More importantly: how many of those tokens are actually useful? A lot of them are just noise from the work itself - file reads, file writes, files in different states as you move through the project.

The Naive Solution: Starting Fresh

One option is to totally clear the context and start a new session. But this comes with a hidden cost.

When you clear the context, the agent loses crucial understanding from the initial conversation. It has to re-explore and re-establish everything it knew before. You might prompt it like this:

we are going to do QA on the stuff that's literally just been worked on.
Can you go and explore it so you understand the reasons behind its existence?

The agent will do that exploration, but it's also lost some of the crucial reasoning from your initial conversation.

It can re-explore the code and re-read what you built, but that re-exploration is lossy - you've lost a lot of the actual _why_ behind what you constructed.

Introducing Compaction

This is where compaction comes in. Instead of clearing the context entirely, compaction takes the context from your current session, squeezes it down, and seeds a fresh session with it.

Think of it like a hand-off between sessions that you control - similar to using a sub-agent, but in reverse. The session history is summarized, then it seeds a fresh session you can continue working from.

ApproachTokensQualityDownsides
Continue current session156k+Full context, lots of noiseHigh latency, dumb zone results
Clear and start fresh~5kClean slateMust re-explore everything, lossy understanding
Compaction~28kSummarized contextLossy compression, secondary source

Compaction saves re-exploration. Without it, you'd spend a ton of tokens just re-discovering context you'd already established.

How Compaction Works in Practice

In your agent, you run the /compact command with a summarization instruction:

/compact Yeah, we're going to do some QA in this area.
Running the /compact command with summarization instruction

Running the /compact command with summarization instruction

This instruction matters. The thing doing the summarization is a language model, so it needs context to highlight relevant information. Your instruction doesn't need to be detailed - one sentence is often enough.

When you launch the compaction, the agent shows a UI where it's compacting the conversation.

Compaction UI showing progress

Compaction UI showing progress

Here's a useful tip: you can queue messages inside the compaction UI. Once compaction finishes, your queued message runs automatically - no need to sit around waiting.

What Gets Preserved

When compaction finishes, it outputs a summary with several key elements:

Compaction finished readout with file references

Compaction finished readout with file references

  • Primary request and intent - what you originally asked for
  • Full agreed spec - all the decisions you confirmed
  • Key technical concepts - important domain knowledge
  • File references - pointers to critical files, plus some files retained verbatim
  • Errors and fixes - what went wrong and how you solved it
  • Problem solving - your approach and reasoning
  • All user messages - everything you said
  • Pending tasks - work still to do

Here's what the token compression looks like:

From the original session with ~156,000 tokens, the compaction summary reduced it to around 28,300 tokens. That 150k becomes 30k - giving you plenty of room back in the smart zone.

Running /context showing 28.3k tokens after compaction

Running /context showing 28.3k tokens after compaction

Model: claude-opus-4
Tokens: 28.3k / 1m (3%)

| Category                | Tokens | Percentage |
|-------------------------|--------|------------|
| System prompt           | 2.9k   | 0.3%       |
| System tools            | 4.5k   | 0.5%       |
| Messages                | 20.7k  | 2.1%       |
| Free space              | 971.7k | 97.2%      |

For example, a line from the summary might read:

- app/lib/comments.ts (new): MIN_COMMENT_LENGTH = 1,
  MAX_COMMENT_LENGTH = 5000 (client-safe, mirrors ratings.ts)
Dense compression of file changes in the summary

Dense compression of file changes in the summary

This is extremely dense compression of everything you did in that previous session.

The Trade-off: Information Loss

Compaction isn't without downsides. Think of it using historical terms:

The compaction summary as a 'historian' looking over the session

The compaction summary as a 'historian' looking over the session

  • The primary source is your initial session - the record from people there at the time
  • The secondary source is the summary - a historical summary, which is lossy compression of the primary source

Compaction is the first hand-off mechanism you've seen that preserves context between sessions. But all hand-off mechanisms suffer from the same issue: whenever you create a secondary source, you lose information.

However, you're gaining efficiency. Here's the trade-off:

ApproachInformationNoiseManeuverability
Primary source (continue)FullLotsLimited
Secondary source (compaction)LossyLessMore room

If you continue with the primary source, you have all the information but probably along with a lot of noise. If you use the secondary source, you have more room to maneuver and less space being used up, but you might lose some of the nuances from the primary source.

When Compaction Shines

However, in the exact situation where you want to do QA on a finished piece of work, compaction is a cast-iron great place to use it. You're not re-implementing. You're not making architectural decisions. You're validating something that's already complete.

This is an introduction to compaction. You'll see how it compares to clearing and other mechanisms in upcoming lessons.

Quiz

You compact a 156k-token session down to 28k and carry on working. What is now true of the detail from before the compaction?

  • It is a summary now, so nuance from the original is gone
  • It is held in full and pulled back in whenever it is needed
  • It is unchanged, and simply billed at the cheaper cached rate
  • It is saved to a file on disk that you can open and search
Answer
Compaction squeezes the session rather than storing it, so nothing is retrievable in full afterwards. Old tokens being cheap because they are cached describes staying in the same session, which is the option you just left. And compaction writes no file - it seeds a fresh session in memory.

You are about to compact so the next session can QA a finished feature. What do you actually type?

  • /compact plus a sentence saying you are moving on to QA
  • /compact on its own, then explain the goal afterwards
  • /compact plus the whole agreed spec pasted in for safety
  • /clear, then ask the agent to go and re-read the code
Answer
The thing writing the summary is a language model, so a bare /compact leaves it guessing which parts matter - and by the time you explain, the squeeze has happened. Pasting the full spec is wasted effort, since one sentence is enough. Clearing throws away the reasoning and forces lossy re-exploration.

Handing Off

Commit Map
handoff-skill Start the lesson: the /handoff skill added to .agents/skills/

In the previous exercise, I showed you how compaction works: you take one session's primary source, summarize it into a secondary source, and seed a new session with it.

Compaction, though, has some constraints. It can only compact within the same directory, and it can only compact within the same agent.

For instance, if we did some implementation with Claude and wanted to hand off to another AI agent like Codex to review it, how would we do that with compaction? We can't.

The /handoff skill

There is one way to do it though, and I encounter this situation so often that I made a skill for it.

The theory is straightforward: instead of compacting inside the agent (in memory), you create a handoff.md file, a markdown file. That markdown file is totally portable. You can do anything you like with it.

  • Feed it into Codex
  • Pass it to an agent in another directory
  • Send it to a colleague
  • Use it to hand off a side task you discovered mid-feature

One really great situation is when you're working on a feature, you notice a random bug that's unrelated to what you're building, and you want to fix it later in a separate session. You can just create a handoff artifact and come back to it.

Looking at the skill

First, run npm run reset and choose the handoff skill lesson from the list.

The /handoff skill file showing the skill definition

The /handoff skill file showing the skill definition

If we look inside the skill directory, we have a /handoff skill. Like most of my skills, it's pretty short.

Write a handoff document summarising the current conversation so a fresh agent can continue the work. Save to the temporary directory of the user's OS - not the current workspace.

One useful feature here is that it saves to the temporary directory of the user's OS. This means these handoff documents are designed to be ephemeral. They're not going to be saved locally in your project, and they won't be stored in any memory. They will be deleted when your computer resets, or whenever the OS decides to clear the temporary directory.

(OS stands for operating system: Windows, Mac, Linux, whatever.)

Using handoff in practice

Let me show you how this works. I'm going to resume a previous session and work with the star rating review system.

We're at around 89k tokens, which might be a good moment to hand off. To use the /handoff skill, I'm going to run the command and pass it a reason:

/handoff pass to Codex to review

Just like with compact, we give the /handoff skill a reason for the handoff. This tells it the purpose of the next session.

It comes back and requests permission to write to the temporary directory. Perfect.

Agent requesting permission to write to the temporary directory

Agent requesting permission to write to the temporary directory

VS Code showing the generated handoff document

VS Code showing the generated handoff document

Now we can see the handoff file. It's a really nice, detailed secondary source of all the things we might need to review. It looks fairly similar to the compacted documents we saw before: nice and detailed, with lots of file references and everything else.

The handoff document includes:

  • What the feature is
  • Files to review (with git status / git diff instructions)
  • Key decisions or bugs fixed mid-session
  • Known pre-existing issues (not part of this change)
  • Verification already done
  • Project conventions the diff should conform to
  • Review angles worth probing
  • Suggested skills for the next session

The way I would seed this into a new session is to open it in a separate window. I've just run /clear, so I've got a totally empty session. Now I can use the @ symbol to reference the file:

@/tmp/handoff-course-star-ratings-review.md
A fresh agent session reading in the handoff document

A fresh agent session reading in the handoff document

Once this gets seeded, it gets immediately read into the context window and it's ready for review.

I'll just cancel out of that because I don't actually want it to do the review right now.

/handoff vs. Compact

That's how the /handoff skill works. It's really nice for:

  • Passing work to separate agents
  • Saving a document you can send to a colleague
  • Handing off to another agent in a different repo to fix a bug you encountered

It's just like compaction, except a little bit more flexible and a little bit more involved.

I wouldn't say that handoff is a total replacement for compaction. Here's when to use each:

WhenUse
Staying in the same directoryCompaction
Retaining context of the previous conversationCompaction
Don't care about retaining previous conversationCompaction (especially because you can queue up messages after it)
Passing to a different agent/handoff
Handing off to another repo/handoff
Sending to a colleague/handoff

Compaction is still really good. /handoff is nice too, but the linking to the next conversation is a little bit more involved, and it's only really useful if you're getting something out of it.

We're going to do a full comparison in the next lesson. Nice work, and I'll see you there.

Quiz

You have just implemented a feature with Claude, and you want Codex to review it. How do you carry the context across?

  • Write a handoff document, then reference it from Codex
  • Compact the session, then reopen that session in Codex
  • Clear, and let Codex explore the repository on its own
  • Save a summary into the project as a notes.md file to read
Answer
Compaction only works inside the same agent and the same directory, so it cannot reach Codex at all. Letting Codex explore alone hands it the code but none of the decisions or bugs already found. A summary committed into the project would linger there - the handoff is written outside the workspace on purpose.

The handoff skill asks permission to write its document. Where does that file go, and how long does it survive?

  • The OS temporary directory - it gets cleared in time
  • The project root - it is committed alongside your work
  • The agent memory - it loads into every later session
  • A folder in your home directory - it is kept forever
Answer
These documents are meant to be disposable, so nothing is added to the project and nothing is written into memory for later sessions to pick up. Nor is any permanent copy kept anywhere - the file dies when your machine resets or the OS clears its temporary directory.

Clear, Compact, Handoff, Or Subagent

In the coding sessions we've done so far with agents, you might have noticed that they break down into pretty discrete chunks. We've had a grilling phase, then an implementation phase, and then a QA phase at the end. We compacted before we started QA-ing.

These phases are loosely defined. They're really just chunks of work within a coding session. Each phase is composed of two parts: the actual phase itself (the running of the grilling, implementation, or QA), and the boundaries between them.

The boundaries are really important. They represent a decision point where you're deciding what to do with the session at each phase boundary.

Understanding Phase Boundaries

Decision tree for phase boundaries showing the five options

Decision tree for phase boundaries showing the five options

By the time we finished grilling, we were only at about 30k tokens. It made sense to continue directly on with the implementation. That meant the implementation could rely on the primary source of the grilling without any kind of secondary source lossiness there.

Showing the choices we assigned to each phase boundary

Showing the choices we assigned to each phase boundary

But by the time we finished implementation and we wanted to QA it, we decided to compact it. We'd used up our smart zone really, and we wanted to get rid of all the cruft and just use the good stuff for the QA.

The way to come to those decisions isn't particularly obvious. You actually have five choices for things you can do at these phase boundaries.

Your Five Options

OptionWhat It Does
ContinueStay in the current session, no context switch needed
ClearTotally clear your context window and start fresh
CompactCompress your context and seed a new session with it
HandoffCreate a markdown file summarizing the session to pass anywhere
SubagentSpawn a subagent to handle the task and report back

Wielding these five options is not trivial. I've created a decision tree to help you navigate them. It might look pretty scary at first glance, but we're going to walk through it step by step.

The Decision Tree: Start At The Top

When you've reached the end of a phase and you're not quite sure what to do, you start here.

Question 1: Can You Continue?

Does it make sense to continue in the current session?

This is a fairly rich decision in itself. Between grilling and implementation, it obviously makes sense to continue because we've got that rich primary source that we need. We don't want to discard it for when we get to the implementation.

You may also want to continue if you just have enough smart zone budget left. If you're at 80k tokens maybe and you know the task is pretty small and is going to fit inside the smart zone, then yes, you can just continue.

If you decide that you do need to do something, then we need to go down this little decision tree.

Decision tree showing the first question: Can you continue?

Decision tree showing the first question: Can you continue?

Question 2: Is Your Context Irrelevant To The Next Task?

If you need to do something, ask yourself: is all the information in this session totally disposable?

In other words, all the explorations, the decisions that were made in that session - is it totally irrelevant to what comes next?

If yes, clear your context window. Clearing is the most efficient path if you can take it because it takes zero time. You're just deleting information. Then you have the most smart zone available to you. You're going back to a blank slate.

However, if you clear the context with relevant information inside, you're losing information that might have been useful later. Imagine if I cleared rather than compacted when I went to QA. This means that the QA would know absolutely nothing about the implementation, which maybe is okay - it could figure it out from the git commits. But it would also lose all the information from the grilling as well.

It would lose the reasoning behind the decisions that I had made. Both phases were important for the QA that then followed. So clearing just wasn't an option.

If no, your context is relevant. Move to the next question.

Decision tree showing the second question: Is your context irrelevant?

Decision tree showing the second question: Is your context irrelevant?

Question 3: Do You Need To Hand Off?

This is specifically about the handoff skill. The handoff skill is relatively narrow compared to the other options.

You'll only need to do the handoff when you need to:

  • Pass work to another agent
  • Pass work to another directory or another colleague
  • Fork off a side task you discovered mid-phase without derailing the current session

For instance, you might find something during grilling that also needs to be tackled. You can just hand off to another session while you're doing that.

If yes, use handoff (/handoff). If no, move to the next question.

Decision tree showing the third question: Do you need to hand off?

Decision tree showing the third question: Do you need to hand off?

Question 4: Can The Task Be Done AFK?

AFK means away from keyboard. You're not touching the keyboard. You're just watching the agent go and you cannot intervene.

This means the task is well-scoped. The agent can do it without needing your intervention at all.

Let's imagine we wanted to do an automated review on the implementation before human review got there. Automated review is where you send the agent into the codebase and you get it to look at the changes and check if it's broken anything or done anything weird.

Diagram showing automated review as an example of AFK task

Diagram showing automated review as an example of AFK task

We could have compacted at this point (we're at 150k tokens from the implementation), then run the review in the main session. But since the human isn't needed for automated review, we might as well run it in a subagent. That means we just get it to run in its own context window. We don't affect the main session.

This is a really common pattern for automated review, and it's one that we'll touch on in this course.

If yes, spawn a subagent. If no, move to the final option.

Decision tree showing the fourth question: Can the task be done AFK?

Decision tree showing the fourth question: Can the task be done AFK?

The Default: Compact

This is the bottom of the decision tree. When your context is relevant, when you want to do something with the context, and you can't continue, when you don't need to use a handoff, and when the task needs to be done with you there - then compact is the solution.

Compact compresses your context window and seeds a new session with the good stuff. You keep what matters and discard what doesn't.

These Are Subjective Decisions

These questions are not objective. There's a little bit of subjectivity, a little bit of taste in there too. You will find your own answers to these questions as you continue your work and continue working with agents.

But I hope this concept of phases, of what you do at phase boundaries, really sinks in. This is one of the fuzziest decisions, the most interesting decisions you're going to make when you're AI coding. It's one that demands a lot of discussion and a lot of wisdom.

Join the Discord and talk about these situations. Use this shared language when you discuss different scenarios. The Discord is a great place to go if you have a question about what to do at a certain phase boundary.

I've also added some quizzes below which will test you on different scenarios.

Nice work. I'll see you in the next one.

Quiz

You have just finished grilling. You are at 30k tokens and implementation is next. What do you do at this boundary?

  • Continue - the grilling is the primary source you need
  • Compact - lock the agreed spec into a summary first
  • Clear - the implementation can start from a blank slate
  • Handoff - write the spec out before you implement it
Answer
Compacting or handing off would swap a rich primary source for a lossy secondary one, and you have smart zone budget to spare, so you would be paying that loss for nothing. Clearing is worse still: the implementation would lose the reasoning behind every decision you just made.

A phase ends. Everything explored and decided in it is genuinely irrelevant to the task you are about to start. What do you do?

  • Clear - it takes no time and gives back the most room
  • Compact - keep a short summary of it, just in case
  • Handoff - write the session out to a markdown file
  • Subagent - run the next task in its own context window
Answer
Compacting and handing off both spend time producing a secondary source of information you have already decided you do not need, and both leave that summary occupying your window. A subagent isolates the new task but leaves the old session sitting underneath it. Deleting costs nothing and frees the most smart zone.

You are at 150k tokens after an implementation, and the next job is an automated review that needs nothing from you while it runs. What do you do?

  • Spawn a subagent so the review gets its own window
  • Compact, then run the review in your main session
  • Clear, then run the review from an empty session
  • Continue, since the review only has to read code
Answer
Compacting would work, but it spends a summarisation step on a task you never touch, and the result lands back in your window. Clearing throws the implementation context away. Continuing at 150k runs the review well past the smart zone, which is what you are trying to escape.

Auto-Compaction

You might be wondering: what happens if you try to push past the context window limit? Opus 4.8, which is what we're using, has 1 million tokens of context. What happens if you go for 1 million and 1?

If you send a request to Anthropic that has 1,000,001 tokens in it, you will get an error. The model simply cannot process that many tokens.

Your agent has built-in protections against hitting this hard limit. When you get to a certain point, it will automatically compact your session.

Finding Auto-Compact in Your Agent

You can see this setting in your agent by typing the /config command and then searching for auto-compact. The matching settings appear at the top.

The /config panel showing Auto-compact set to true

The /config panel showing Auto-compact set to true

The relevant configuration shows:

Auto-compact: true

with a description: "Automatically compact conversation when context fills"

Auto-compaction exists in every single agent harness, because every harness has this problem. Every harness has a window in which, if you hit it, the system will pause your session and automatically compact what's in there.

You used to be able to see this by typing /context to view the autocompact buffer inside the context breakdown. But it appears that teams have made it slightly more obscure.

Customizing the Auto-Compact Window

One interesting thing you can do is customize the auto-compact window itself. Inside your ~/.claude/settings.json file, you can adjust when auto-compaction fires:

The settings.json file showing the autoCompactWindow setting

The settings.json file showing the autoCompactWindow setting

{
  "autoCompactWindow": 250000
}

If you want it to automatically compact after 250,000 tokens, you can totally do that. The setting accepts values from 100,000 to 1,000,000 tokens.

The Promise: Context Management Goes Away

The promise of auto-compaction is really quite nice. Imagine a world where you didn't have to think about phase boundaries at all, didn't have to think about the smart zone, didn't have to think about context at all.

This decision tree would simply not be needed:

The decision tree diagram showing all five options

The decision tree diagram showing all five options

You would just auto-compact at the right moments. In fact, you will see a lot of people online saying that auto-compaction just handles all of their problems for them.

Why Auto-Compaction Is Actually Really Difficult

However, it turns out that auto-compaction is an incredibly difficult problem to solve. And it's really, really painful to get wrong.

Compacting in the Middle of a Phase Is Dangerous

Think back to a typical session with a grilling phase and an implementation phase, separated by a phase boundary.

Diagram showing grilling phase, implementation phase, and phase boundary

Diagram showing grilling phase, implementation phase, and phase boundary

If someone forced you to put in a compact somewhere in this session, you would probably say that the safest place to do it would be at the phase boundary, between grilling and implementation.

But what would happen if you compacted in the middle of a grilling session? You'd be working with only a summary of what had been done before. What I've found when this has occasionally happened is that the agent really does lose its way quite often and just forgets stuff you were talking about just before.

The same is true in implementation, and it's often worse:

  • The agent will often lose its way completely
  • The second half of the implementation phase will use a totally different coding style from the first part
  • It will lose its train of thought and forget features it was supposed to implement

You Lose Control of the Handoff

There's another problem: when you automatically compact, there's no opportunity for you to say what you should compact and what the intention of the next session is going to be.

The little summarization notes that you pass to the handoff document or you pass to /compact are really key for getting it to compact the correct things. Auto-compaction gives you no equivalent hook.

The Better Approach: Human Control

So will mid-phase compacting always be bad? Probably not, although it feels like it's going to be a hard problem no matter what the model is. It's a very tricky, difficult problem to solve.

My attitude in general is to increase the skill of the human instead of increasing the demand on the harness and the model. I tend to prefer the human having control of this decision tree, rather than just passing it off to the agent.

It's a one-time learning curve that the human has to go through, and it will just get you better and better results the better you get at it. More of your sessions are going to be in the smart zone and you're going to have better control.

The Real Rule

In my opinion, if you're hitting the auto-compact buffer, if you're automatically compacting, then something is probably going wrong.

Instead, you should be in control. You should be the one deciding whether you continue the session, clear the session, hand it off, spawn a subagent, or compact.

When you own that decision, you get better code.

Quiz

Halfway through implementing a feature, your session pauses and compacts itself. What should you take from that?

  • You left the boundary decision too late - own it yourself
  • The harness dealt with it, so there is nothing to change
  • Your context window is too small for work of this size
  • The model is not capable enough for a feature this large
Answer
The harness did rescue you, but it compacted mid-phase, which is where the agent most often loses the thread. Raising the auto-compact window only moves when that happens rather than adding capacity, and the model is not the thing that failed - the phase boundary went unclaimed.

A compaction has to happen somewhere in a session that runs grilling then implementation. Where does it do the least damage?

  • At the phase boundary, between grilling and implementing
  • Midway through implementation, once the style is settled
  • Midway through grilling, once the questions are all asked
  • Anywhere at all - the summary keeps the same information
Answer
Cutting into implementation is often the worst case: the second half comes back in a different coding style and forgets features it was meant to build. Cutting into grilling makes the agent forget what you were discussing moments earlier. And the summary is lossy, so where it lands genuinely matters.

You want your agent to compact automatically at 250,000 tokens rather than wherever it currently fires. What do you change?

  • Set autoCompactWindow to 250000 in your settings file
  • Set compactThreshold to 250000 in your settings file
  • Pass a token budget to the /compact command each time
  • Turn auto-compact off in /config and compact by hand
Answer
autoCompactWindow is the setting that moves the trigger, and it accepts anything from 100,000 up to 1,000,000 tokens. No such compactThreshold key controls this, /compact only compacts on demand rather than setting a future trigger, and switching auto-compact off removes the automatic behaviour instead of moving it.