Skip to content
Linkdrop
Links

S01E02 · Steering Models Through Context: MEGA lesson video by Theo Browne

Theo Browne explains how harnesses provide models with context, including system prompts, tools, skills, and project instructions. He demonstrates using a handoff file to carry work between sessions and discusses what belongs in shared agent guidance.

videoTheo Browne · hq.mega.dev · Saved Nov 19, 2026

mega course, context engineering, agent prompting, coding agents

Transcript of the lesson video for S01E02 of the MEGA.dev course, by Theo Browne. Agenda: Settings · Context · Processing · Skills · Tools · Subagents. The video plays on the lesson page in MEGA Student HQ (needs a login).

0:02 Hopefully now you understand how the model sees the world a bit better. With that, we can take a bit more control and steer the model towards the things we want it to do. In the end, the only way we can really control what AI does is by giving it the right context to do the things we want it to do, and that's what this lesson's gonna be all about. Let's start with a simple demo of what the different harnesses that you might be using see. We're gonna ask a simple prompt to a handful of different harnesses and models. We're asking it to not run any tools and just list the blocks of context that it can see right now from top to bottom.

System prompt, tools, skills, et cetera. I still remember the days where everyone was trying to protect their system prompts. I'm thankful we're over that because it's good to know what context exists in the model when you're using it. So we can see exactly that here. Here we have Claude Code's response. It starts with the tool definitions. These are all the things in the harness that it has access to, like the agent, tool, bash, edit, read, write, all the things that the model would want to do. We then have the system prompt, which describes the identity that the model should take, 'cause we want it to behave like a helpful assistant, yada yada, the rules of the harness, the things it should and shouldn't do, how we want it to code, how we want it to speak to us and refer to us and itself, confirm before risky actions rule, which is telling it to ask us about doing things before it does something risky, context management, which is a general, like, how to think about the things that are in your history.

These are all things that the Anthropic team has written in order to allow Claude to know what capabilities it has and how it should behave. The simplest way to think about all of this is it's almost like the model is in Groundhog Day, where it wakes up and knows nothing other than whatever it was taught as a kid. The model has a bunch of knowledge, but it doesn't really know where it is, why it's there, or what it's doing. We have to give it all of that. So you can see all of this data here, all of the system prompt stuff, almost like a set of sticky notes that we give to the model when it wakes up to let it know what's going on and what its job is to do.

There's a bunch more stuff the model's given access to, like my global Claude MD, the git status snapshot that describes what the current state of the repo is, so that if you're using Claude Code for code, it has that info early. There's commit and PR attribution lines, which is telling the model how to behave with commits. Then we have your message. This is what we actually sent. And after our message, all of these additional pieces come beyond it. This isn't in the history before our message. This actually comes after. This is the environment info, the output style, because you can set this in Claude Code, the tool list, 'cause remember I said before, mine is on search mode, which means that the tools aren't always there.

They're only there if the model asks. It just has vague descriptions of them initially. Then we have the agent types, all of the different things that the agent can do and how it behaves. I have a custom one for Soul because, uh, it was not easy enough to let Claude call Soul as a sub-agent initially. This fixed it. Probably don't need it anymore. Shout out to T3 Code. The MCP servers for things that the model might wanna do. In this case, I gave my Claude access to the ChatGPT computer use server for Codex. Then we have a skills list, auto mode, which is a thing that the harness has capability for, where it can approve things for you.

And then the final reminder at the end to be concise, as well as today's date, because people sometimes ask, and it's good for the model to know. But again, without all of this, the model doesn't know anything, at least not anything about what we want it to do. This is all the context that we give the model so that it feels smarter. Because if you just asked a raw instance of Opus 5.5 to make changes to a code base, it doesn't even know what code bases are, really. I mean, it does to an extent. Like, it knows what a GitHub repo is and that code exists, but it doesn't know what your code base is, what the state of it is, or what's going on at all.

So by putting all of these things in the system prompt and in the context the model gets, we are steering it to behave in ways that are better. I also ran this on Codex, and you see it's very similar in terms of its structure and what it is putting here. It puts the user message much closer to the end than Claude Code does, but it doesn't really matter. They are all behaving effectively the same way here. But then we have Pi, a beautiful, minimal, elegant option. It has a simple system prompt, a handful of really simple tools. In this case, read, bash, edit, and write. It then has available skills. These are the ones that are provided by my setup, which, uh, has a very small set of things.

It has my repo explorer skill. I use railway skill for dealing with my railway deployments. PyDS4 config, which came from something I installed a while ago. You get the idea. Then we have the project instructions. These are the things that are included for a specific project. So if you have a Claude or Agent SMD in the repo, this gets added there. We'll talk about those in just a bit. We have the project context, which is environment info it automatically pulls in when you run, like the current directory, other little bits of info like that, and then the user message at the end. I wanna talk a bit more about this Groundhog Day effect, because I think it's really important to understand as we try to make our models more capable at delivering real good code.

Something weird about how I work is that I really don't like long-lived threads. I try to keep all my threads as effectively ephemeral as possible, with the goal of closing it as soon as possible after I open it. But as we've been discussing, the history is important. If something isn't in the history, the model doesn't know about it, and then it has to do things like call tools or hallucinate in order to get the next steps, and we don't want it to hallucinate, and we don't want it to have to do a bunch of tool calls before making simple changes that it should already know about. Once you start working on lots of things in parallel, you're gonna start experiencing some weird behaviors.

Like, you have one thread that got something wrong, you correct it, and then you go to one of the other threads, and it also got the same thing wrong. That can be annoying. The reason for this is because the model isn't sharing the information across the threads. It has to get it from somewhere. And the best place the model can get this info is from the code itself. Let's see what this looks like with another demo. Here, we're gonna start a new session called Session 1. We're telling it that we're making some changes to our cart system. We're adding discount codes and a receipt to this cart in two steps. The first step is that we're adding this particular code.

We are adding this coupon code for saving 10%. And then step two is that we should add this new receipt function. Returns one string, yada, yada, yada.

5:52 We're gonna tell it to only do step one and do tests for it. If we were to do that and then start another thread, it wouldn't know where things are at. It could, like, read the code. Maybe it could even use its tools to find the history of your chats on the computer to build this all up. But ideally, it could find what it needs from the code itself. So in this case, we're going to fire this off. It's going to make the change for this one part of the two-part request. So it started by doing a bunch of tool calls, in this case, reading the files that, like, the agent being claude.md. It doesn't have to do that 'cause they're included in the context by default, but if it doesn't know, it can go double-check this way.

We then output some text and write it to cart.js, and then we write a bit more text to handoff.md to wrap things up. Step one is now done, and all eight tests pass. I then stopped as you asked. It made the changes, it updated the tests, and then it wrote to the handoff.md file explaining what things are at and restating step two so that some other thread can pick this work up. Obviously, if we were working traditionally, these two tasks are similar enough, they should probably just be done in the same thread or in one shot. But if you have complex work that you'll be working on across many threads over large windows, encoding what matters in the code base is important.

This is the contents of that handoff.md file, if you were curious, by the way. We can see it has a simple markdown file with a title, says the work's split into two steps. It says the basis of the project, says what it already did, and then it says what step two is so the model can do that next. We press enter, session two starts, and we give it a very simple request, "Continue the work described in handoff.md." And now, despite not having any of the history from before, it's able to operate almost as though it does because the context that it needed was, it re- read from this file. We're not even including the file in the history ourselves.

We are just telling the model the file exists and that it has what it needs. So it runs this cat command to read the content, which outputs the content into its history, and now it knows it can do things and what is requested of it. It then generates the code, it tells us all about what it changed, and now we are done. And you can see the effect here, which is that session one used 5,000 tokens, and session two only had about 500 because it didn't have to go do all of these things and get all of this information. It could just output a simple thing. Now that we understand the basics of how the model gets the context, I'm gonna say some things that might sound a bit contradictory.

We shouldn't be giving all of these detailed instructions in our shared global agents.md, claude.md, or even the project-level ones. Anything that the model can get easily with one command probably doesn't belong in your claude or agent.md files because models can run commands and get that context. The reason that you put things in these shared context files is to share knowledge that is not trivial to get, and more importantly, to steer model behavior in the directions that you want it to go in. For reference, here is the actual claude.md from T3 Code. We give a basic description of what T3 Code is so that it knows what it's working on as soon as it wakes up.

I then chose to tell the model what makes T3 Code special. The reason I did this is I noticed the model would make changes that didn't always embrace the core promises that I think are so important to my project. In this case, that it's open at the core, that it's always performing very well, so don't do things that slow it down. It's remote-ready, so any and all changes and new features we add should work remotely as well as on your local device, and that it's multi-surface so that it will work well on web, desktop, and mobile. I have a note for myself, which might sound crazy, but this helps the model understand how I am thinking about things so that when I or others contribute to this code base, this context is given.

You can get the equivalent experience from the model by copy-pasting this text at the start before you send your first message, but I'd much rather the model just know what I'm going for and also channel specific behaviors like measure twice, cut once, and you ain't gonna need it. These things are all small, and you'll notice a lot of this is almost vibes-based, but I'm trying to vibe the model into the direction where I live so that it behaves the ways that I want. One of the best ways to improve here is to pay attention to when the model does things you don't want it to do, like it takes too long to complete a task, or it uses the wrong tool, or edits a file it shouldn't have edited, or pushes code it shouldn't have, or doesn't push code it should have.

Ask the model why it did the thing after it does it, and then from there, you can find opportunities to improve these files. You might also have noticed there's something missing from everything we've looked at so far. There isn't a single code path anywhere here so far. The reason for that is because code paths are not that important if the model can find them itself, and these models are very, very good at that. What they're less good at is communicating in the ways that we communicate. So if you and your team have a specific grammar or set of terms you use, defining that in one of these files is very helpful so you don't get confused when the model says something in three different ways in three different threads.

You now have a shared grammar where you and the model can understand each other better. These types of glossaries have been way more helpful than I ever would have expected in my code bases, and I've started introducing them into a lot of the work that I do. There are other ways for the model to get context, and if you put all of its capabilities in the claude or agent.md, you're just gonna bloat the context up with things that might not matter. For example, I want the model to be able to spin up a dev server on Tailscale if I'm using a remote box over Tailscale, but I don't want it to just blindly run Tailscale commands all the time and to have all this context when it doesn't work or isn't needed.

Like, if I'm running on my local machine, I don't want it to fire off Tailscale commands. And this is where skills come in. Again, I'm gonna use a real example from the T3 Code code base with our test T3 app skill. I have a repo called Fleet where I personally manage all of my skills, contexts that's shared across projects, and all of those things. And I'm gonna look at one of my personal favorite skills I've been using a lot recently, full stop. This is a skill I built for when I want the agent to go all the way end to end to figure out the problem, verify it itself, iterate, loop accordingly, and then make the thing work.

It should put up a PR, continue monitoring the PR until it is ready to merge as far as it's concerned, and then stop and tell me that it's ready. The reason I call it full stop is it should do everything it possibly can until merge, and that's when it stops. Skills have a few core pieces. They have a name, a description, optional metadata, and then the actual content of the skill. I'm gonna give a hot take quick and say the description is a bad name for the description because it's implying that the point of this section is to tell us what it does. It isn't that at all. The point of the description is to tell the model when it should use the thing.

I think the better phrase for this would be trigger, not description, and that's how I use it. You'll see here, I say, "Use when Theo asks for full stop or explicitly invokes this skill, not when he asks to stop working." I almost want to go change this, and I probably will when I'm done recording, to literally just say, "Use when Theo asks for full stop and nothing else," because that is how descriptions should be used. They are what lets the model know the point of the skill. The reason this all matters is the model chooses when the skill comes in. When you write a skill, it's not just always there bloating your context. The model sees a very small amount of data.

It just sees the name and the description and nothing else. So if you want the model to decide when to pull the skill in itself, you would give it a description that categorizes when it should. If you want the model to only do a thing when you specify, then you can say that in the description. In this case, I only want the skill to run when I say full stop, and I don't have to, like, carefully do the dollar sign full dash stop to trigger it. I just want the model to pull it in when it should. And then we have the important part of the skill, the actual text content. In this case, I describe what this is.

Theo's not watching. Own the work until the PR is ready for him to merge. Keep fixing, verifying, and reviewing. Never merge it. And then I describe all of the things I want it to do in this particular style of working, but this is all the context that the model needs to behave the way I want when I call out this specific thing. You can do this for lots of different things. For example, my leaving PR comment skill is one of my other favorites. This one is how I describe to the model the format to use when it leaves comments. I could manually invoke this skill by saying, "Use the leaving PR comment skill," or running the command to invoke it, but here I have a more vague description where I say that it should use this whenever an agent is drafting, posting, replying to, or resolving PRs or review comments for Theo, including comments made by other PR skills.

And here, I describe the exact format I want the model to leave comments in. If you go look at something like the T3 Code GitHub or any other place I'm contributing, you'll see all the comments left in this format because the models are smart enough to see this description, say, "I should probably use that if I'm leaving a comment," pull it into context, and then act accordingly. This is what makes skills so useful. They're super dynamic. The model can pull them in on different conditions. You can manually pull them in, and all of this allows the model to change how it behaves because the context is different depending on what skills you're using and when they're being used.

If there are certain behaviors or issues that you notice you and your coworkers are running into on a given project, you can use a combination of the Claude MD, Agent MD files, as well as custom skills to steer the model in the right way. Separately, if you have specific behaviors or characteristics you want the model to exhibit, for example, you don't want it to bother you until the PR is up, or you wanna make sure it uses browser use a bunch to test your changes before it puts up the PR, you can make these all personal custom skills that the model will have access to when it's running on your machines, but these won't affect how your teammates do things when they pull the code base down themselves.

One last thing I'll say here, and I feel bad 'cause I've kind of broken the rule a bit myself recently, I don't love writing skills with agents. I'll often have them make the first version of the skill and then send it across my fleet of machines, but I'll almost always go back in and clean things up, just deleting a bunch of useless text and things that don't matter that much. LLMs love to be unnecessarily verbose, and skills should be relatively simple. The less text, the better. The simpler the instructions, the better. And if you give it a simple flow, like do one, two, three, four, five, the model will almost always behave accordingly. Skills shouldn't be treated as this esoteric black box that you only touch with agents.

You should spend a decent bit of time customizing them, configuring them, seeing how they behave and how small changes change their behaviors. This is how you control the way the model works with you, and you should take advantage of that. One last thing I wanna touch on with context is the types of things the model can see, 'cause it's not just text. Different models have different capabilities, but there's a handful that pretty much all of them have. For example, pretty much every model you're gonna be using with code today has the ability to see and understand images. I'll show this by taking a screenshot of T3 Code itself. I use a tool called Shottr in order to annotate my screenshots, and I'm gonna show you something that honestly is still just, like, mind-blowing to me.

I'm gonna point an arrow at the icon here where I have the brain and the word high, 'cause I don't love that we show this brain icon. We all know what high means now, so I'm going to say something in here like, "Ugly. Get rid of it." Now, I can take this image I made, put it on my clipboard, paste it to the model, and without saying anything else, hit send. Now, the model is thinking about this image, trying to pinpoint exactly where the arrow is pointing. It looks like it's near the bottom bar area, possibly indicating the high brain icon just below the composer's edge. It then greps for brain in the code base, reads the picker, which is the code where this lives, and decides what it wants to do about it.

It removed the icon. Dependencies are not installed within the work tree, so I'm installing them now to run lint and type check. It's now running commands in order to test these things that it changed. But this image that I sent it gave it the context it needed to know what to do. I sent no text along with it. T3 Code will automatically insert this user-attached one or more files text, just 'cause some models and harnesses need some text, but it isn't even necessary. This image is just another chunk of data that's in the history as far as the model's concerned, which means that all the other techniques we've given the model to add things to its history work here too.

For example, if the model makes a UI change and it wants to confirm it, it can use a tool to spin up the change, it can use another tool to open it in the browser, then it can use one last tool call to get a screenshot of the result that it would then get in its history as a new message that it can look at and make decisions around. To wrap things up, it's important to understand that the model only has so much knowledge in it, and its behavior doesn't come from its training so much as what context it has. Obviously, the training matters. Obviously, the model matters. But what it knows and what it has access to matters as much, if not more.

The context the agent has is one of the most important things we have to control its behavior, which is why it's important to understand it and start working with it directly. You can use the tools we showed here, things like skills, Claude and Agent MD, and all these other ways to give the model context, even just changing what files are where in your code base to make it easier for the model to find. All of this is what steers the way the model behaves. And if you ever notice the model doing things you don't like or that are confusing, you can ask why it did it and what information it had in its context that made it act that way.

You can always just ask the model what info it sees and what it has and get good answers to figure out how it sees the world, because something might be obvious to us when we look at the app or we look at the code base, but the model doesn't know it until it runs the right command to get the data that it needs to do the thing. As models keep getting better, they are improving their ability to build context themselves, but it's still important to send them in the right direction. And all of these lessons will help you understand why the models behave the way they do and change the behavior to make them more effective for you.

[music]