Sub topic 1
Why packaging instructions matters: the context window
Prerequisites
This chapter assumes you have used an AI coding assistant in an editor or terminal. You should know basic Markdown and simple YAML, and you should be comfortable with Git and a repository layout. You should also have a general idea of what a prompt is.
The context window is a budget
A model reads and writes inside a context window. This is the fixed amount of text, measured in tokens, that the model can consider at one time. A token is a small piece of text, roughly a short word or part of a word.
Everything the agent sees in a session shares that one window:
- The system prompt from the tool
- Your persistent project instructions
- Descriptions of the tools the agent can call
- Your messages and the agent's replies
- Files the agent has read and the output of commands it has run
Each item you add leaves less room for the others. A long window does not remove this problem. Quality can drop when the window is crowded with text that has nothing to do with the current task, and every request costs more and runs slower as the window grows.
Two ways instructions go wrong
You can fail in two opposite directions.
- Too little guidance. You retype the same request each time: "review my staged changes, check for tests, don't edit anything." The wording drifts, steps get skipped, and results vary from run to run.
- Too much guidance. You put every rule, workflow, and checklist into one always-loaded file. The agent pays for all of it on every task, including tasks where most of it is irrelevant. Important rules are also harder to find in a long file.
Packaging is the answer to both. You write the instructions once, give them a name and a place on disk, and control when they load.
Three packaging mechanisms
This tutorial covers three mechanisms. Each one differs mainly in when its content enters the context window.
| Mechanism | What it is | When it loads |
|---|---|---|
| Reusable prompt file | A Markdown file holding a fixed task | When you invoke it |
| Custom agent | A specialist with its own role, instructions, and tool list | When you select it or the tool delegates to it |
| Agent skill | A folder with a `SKILL.md` file and optional extra files | A short description is always visible. The body loads when the task matches. |
File names, folder locations, and frontmatter fields differ between products. The examples in this tutorial are illustrative, so check your tool's documentation for exact names.
Loading cost is the design question
Persistent project instructions, such as an AGENTS.md file, sit at the always-loaded end of the range. Prompt files and agents load on request. Skills load in stages, which later chapters call progressive disclosure.
When you decide where a piece of guidance belongs, ask how often the agent needs it. A rule that applies to every task belongs in the persistent file. A workflow you start by hand belongs in a prompt file. Guidance that matters only for some tasks belongs somewhere that loads on demand.
What comes next
The following chapters take each mechanism in turn. They start with persistent instructions as a baseline, then cover prompt files, custom agents, and skills. Later chapters show how to choose between them, test them, share them, and review them for security.
Exercise
A team keeps a 400-line checklist for database migrations in its always-loaded project instructions. Most tasks never touch the database. Name the problem and one way to reduce it.
Show answer
The checklist takes up context window space in every session, including those where it is irrelevant, and it can bury other rules. Move it to something that loads on demand, such as a skill (or a prompt file the developer invokes when starting a migration), and leave only a short pointer in the always-loaded file.