Day 3, 25 minutes · advanced
Why it matters
Long agent sessions often go the same way. The first hour is sharp. Then the agent forgets a rule you gave it at the start, reads the same file twice and starts to guess. When an agent seems to get worse during a long session, check its context window first: everything the model can see at once. That window is a fixed budget, and every instruction, file and command output spends part of it.
On a client job you also hand the work over. Tomas, the client's engineer, will never see the rules you typed into a chat. The rules that matter have to live in the repository, in a short file that every new session loads by itself.
At the end of this lesson the orderdesk/ repository has a project instruction file of one page at most. And you have proven, in a fresh session, that the agent follows two of its rules without being told.
What fills the window
On day 1 you saw what is sent to the model on every turn: the tool's own instructions and tool list, your instruction file, the conversation, and the results of earlier tool calls. All of that sits in the context window at the same time, and the parts do not behave alike.
The tool's instructions and your instruction file are there before you type a word. The rest grows with every step: every file the agent reads, the output of every command it runs, every turn of the conversation. A test run that prints two hundred lines takes as much room as two hundred lines you wrote yourself.
Signs of a full window
- The agent stops following a rule you gave it early in the session.
- It reads a file again that it already read.
- It asks for something you already told it.
- Its answers get vaguer while its plans get longer.
Three ways out
- Start fresh. End the session and begin a new one. The instruction file loads again and the clutter is gone. Between two tasks this is usually the right move.
- Compact. Most tools can replace the earlier turns with a summary. You keep the thread, but details from early in the session can get lost in the summary. Several tools also do this by themselves when the window is nearly full.
- Hand over through a notes file. Ask the agent to write what is done, what is open and which files matter into a short notes file. Start fresh and point the new session at that file. You decide what survives, not the summary.
What goes in the instruction file
An instruction file is a plain Markdown file in the repository that the agent loads at the start of every session, before your first message. It rides along on every turn, so each line in it costs room for the whole session. Keep it to one page.
Put in what the agent cannot work out by reading the code:
- the commands to build and test, exactly as you type them
- conventions that are not visible in the code
- the things it must never do
- where things live, one line per folder
Leave out:
- long documentation: name the file instead of pasting it
- anything the agent finds by itself, such as a list of files or what each function does
- secrets of any kind: no keys, passwords or connection strings, also not "for now". Day 5 covers where they belong.
The steps
Start from the orderdesk/ repository of day 2. Commit what is there first, so that git can show you later exactly what the agent changed.
- Write the instruction file with this text. Each tool wants its own file name and place, so pick your tool below and follow the steps.
Project: orderdesk drafts replies to order-status emails for the support team of Kettlebrook Wholesale.
It only writes drafts. A person at Kettlebrook reads and sends every reply.
Commands
- Run the tests: python -m unittest
- Print the draft for one sample email: python draft_reply.py E-001
- Python 3, standard library only. Use python3 if python is not found.
Where things live
- data/: made-up order data and sample emails
- prompts/: the reply prompt (added later)
- evals/: test cases for the reply prompt and their scores (added later)
Rules
1. Never edit files in data/. They are made-up fixtures.
2. Run python -m unittest before you say a change is done, and show the output.
- Read it once more and cut. If your tool generated a starting file, it probably lists files and describes code. Remove every line the agent could find by reading the repository.
- Check that your tool has loaded the file. Where your tool has a command for that, its guide names it.
- Start a fresh session. If anything from earlier is still in the window, you test your chat history, not your file.
- Give the proof task. Do not mention the rules.
Add a function expected_delivery_for(order_id) to orders.py that returns the expected delivery date from the order data, with a test. Do not change draft_reply.py.
Nothing from day 2 reads that date, so this is new work for the agent.
Check the result
Check the evidence, not what the agent says about itself:
- Rule 2: the transcript shows that the agent ran
python -m unittestbefore it called the change done, and that it showed you the output. - Rule 1:
git status -- data/shows no change.
When both hold, commit twice: first the instruction file, then the new function with its test. Day 4 reviews that second commit as change A.
In a chat tool
We found no vendor page that shows a chat product running the tests in your repository, so its two rules are about the reply instead:
- Rule A: answer in the language of the customer's email.
- Rule B: never state an order status that is not in the order data. If the order is missing, say you cannot find it.
Save the rules as instructions that load in every chat, give the assistant the six order rows, and test in a fresh chat with two sample emails. E-005: Emma writes in Dutch, so the draft must come back in Dutch. E-004: Marco asks about WH-19999, which is not in the data, so the draft must say it cannot find that order. The guides below show where each product keeps saved instructions and where the order rows fit.
When a rule is not followed
- Make the rule concrete. "Run
python -m unittest" works better than "test your work". - Look for a second instruction file that says something else. Several tools read more than one file name and combine them.
- Remember what the file is: context the model reads, not a lock. A rule that must hold every single time becomes a hook on day 4: a script the tool runs by itself at a fixed moment.
- Throw away the agent's change (
git restorefor changed files, delete the files it added), then test again in a fresh session, never in the one where you edited the file.
How the tools name the file
- Claude Code:
CLAUDE.mdin the project root. It readsAGENTS.mdwhen there is noCLAUDE.md. - OpenAI Codex:
AGENTS.md. It reads the files when a session starts, so restart after a change. - Gemini CLI:
GEMINI.md. Other file names can be added in its settings. - Cursor:
AGENTS.mdorCLAUDE.mdin the project root, next to its own Rules. - GitHub Copilot CLI:
.github/copilot-instructions.md, and it also readsAGENTS.md,CLAUDE.mdandGEMINI.md. - The four chat products: saved instructions in a project or in the account settings, not a file in the repository.
If the client's team uses several of these tools, keep the rules in one file and check which names each tool reads. Two near-copies drift apart.
Keep it working
The file belongs to the repository, not to you. When a command changes, change the file in the same commit. On day 7 Tomas takes the repository over, and his agent loads this page in every session.
Deeper dive
Today's actions
Ticks are not saved without an accountDo it in your tool
Claude
- Open Claude, hover over the left side and click Projects.
- Click + New Project in the upper right corner and name it
orderdesk. Claude does not see the name. - Click the + button in the project knowledge area on the right and upload
orders.csvfrom day 2. If you have no copy, save these six rows as orders.csv first.order_id,customer,status,expected_delivery WH-10432,Sanne,delayed,2026-12-03 WH-10433,Daan,shipped,2026-11-30 WH-10434,Priya,processing,2026-12-05 WH-10435,Marco,delivered,2026-11-24 WH-10436,Emma,shipped,2026-12-01 WH-10437,Priya,processing,2026-12-08 - Click Set project instructions, paste this text and click Save instructions.
You help the support team of Kettlebrook Wholesale draft replies to order-status emails. A person checks every draft before it is sent. Order numbers look like WH- plus five digits. The order data is in the project file orders.csv. Rule A: answer in the language of the customer's email. Rule B: never state an order status that is not in the order data. If the order is missing, say you cannot find it. - Start a new chat inside the project and paste the email from Emma. Do not mention the rules.
Draft a reply to this email from Emma: Hallo, waar blijft mijn bestelling WH-10436? - Check that the draft is in Dutch. Then paste the email from Marco in the same chat.
Draft a reply to this email from Marco: Where is WH-19999? It should be here by now. - Check that the draft says it cannot find WH-19999 and states no status for it.
Note: Claude's help pages disagree: one says Projects are open to all users, free accounts included (up to five projects), another lists project instructions under paid plans only. Check your own plan before you count on it. If Set project instructions is missing, put the text under Settings, Your Claude, Instructions (older layout: Account, Instructions for Claude) and paste the order rows as your first message.
ChatGPT
- Hover over Projects in the sidebar on the web and select the plus icon (+) for New project.
- Enter the name
orderdesk, then select Create project. - Open the project, select the more options menu (the three dots in the upper-right corner) and select Project settings.
- Paste this text into the Instructions field.
You help the support team of Kettlebrook Wholesale draft replies to order-status emails. A person checks every draft before it is sent. Order numbers look like WH- plus five digits. The order data is in the project file orders.csv. Rule A: answer in the language of the customer's email. Rule B: never state an order status that is not in the order data. If the order is missing, say you cannot find it. - Add the order data to the project: upload
orders.csvfrom day 2, or paste these six rows as text.order_id,customer,status,expected_delivery WH-10432,Sanne,delayed,2026-12-03 WH-10433,Daan,shipped,2026-11-30 WH-10434,Priya,processing,2026-12-05 WH-10435,Marco,delivered,2026-11-24 WH-10436,Emma,shipped,2026-12-01 WH-10437,Priya,processing,2026-12-08 - Start a new chat inside the project and paste the email from Emma. Do not mention the rules.
Draft a reply to this email from Emma: Hallo, waar blijft mijn bestelling WH-10436? - Check that the draft is in Dutch. Then paste the email from Marco in the same chat.
Draft a reply to this email from Marco: Where is WH-19999? It should be here by now. - Check that the draft says it cannot find WH-19999 and states no status for it.
Note: Projects work on the Free plan, with up to 5 files per project (25 on Go and Plus). Project instructions apply only inside that project and override your global custom instructions. A project holds instructions and files, but it does not read a repository by itself. For an instruction file in a repository, see the OpenAI Codex tab: Codex reads AGENTS.md. If your workspace admin blocks new projects, paste the same text and the rows as the first message of a new chat; it is not remembered.
Gemini
- Open Gemini in the browser on your computer. At the bottom, click Settings, then Personal context.
- Click Add + under "Your instructions for Gemini".
- Paste this text and click Submit.
When I ask for a reply to a customer email, you draft it for the support team of Kettlebrook Wholesale. A person checks every draft before it is sent. Order numbers look like WH- plus five digits. I paste the order data in my first message. Rule A: answer in the language of the customer's email. Rule B: never state an order status that is not in the order data. If the order is missing, say you cannot find it. - Start a new chat. Paste the order data and the email from Emma as one message. Do not mention the rules.
Here is the order data: order_id,customer,status,expected_delivery WH-10432,Sanne,delayed,2026-12-03 WH-10433,Daan,shipped,2026-11-30 WH-10434,Priya,processing,2026-12-05 WH-10435,Marco,delivered,2026-11-24 WH-10436,Emma,shipped,2026-12-01 WH-10437,Priya,processing,2026-12-08 Draft a reply to this email from Emma: Hallo, waar blijft mijn bestelling WH-10436? - Check that the draft is in Dutch. Then paste the email from Marco in the same chat.
Draft a reply to this email from Marco: Where is WH-19999? It should be here by now. - Check that the draft says it cannot find WH-19999 and states no status for it.
Note: These instructions apply to every chat of your account, so take them out again under Personal context after the test. The page gives no size for them, so the order rows go in the first message of each chat. Saved instructions are not a file in a repository: for GEMINI.md, see the Gemini CLI tab. Skills, which load only when needed, come on day 4.
Microsoft Copilot
- Go to Copilot Chat and sign in with your Microsoft 365 account.
- Select Settings and more (the three dots) at the top right of the Copilot app, then select Chat settings.
- Select Personalization from the left-side menu of the Chat settings window and find the Custom instructions tile.
- Select Edit instructions, paste this text in the compose box and select Save instructions.
When I ask for a reply to a customer email, you draft it for the support team of Kettlebrook Wholesale. A person checks every draft before it is sent. Order numbers look like WH- plus five digits. I paste the order data in my first message. Rule A: answer in the language of the customer's email. Rule B: never state an order status that is not in the order data. If the order is missing, say you cannot find it. - Start a new chat, not a temporary chat. Paste the order data and the email from Emma as one message. Do not mention the rules.
Here is the order data: order_id,customer,status,expected_delivery WH-10432,Sanne,delayed,2026-12-03 WH-10433,Daan,shipped,2026-11-30 WH-10434,Priya,processing,2026-12-05 WH-10435,Marco,delivered,2026-11-24 WH-10436,Emma,shipped,2026-12-01 WH-10437,Priya,processing,2026-12-08 Draft a reply to this email from Emma: Hallo, waar blijft mijn bestelling WH-10436? - Check that the draft is in Dutch. Then paste the email from Marco in the same chat.
Draft a reply to this email from Marco: Where is WH-19999? It should be here by now. - Check that the draft says it cannot find WH-19999 and states no status for it.
Note: Custom instructions are part of Copilot personalization, which is a preview. An admin can switch it off, and then Copilot stops applying your instructions. A temporary chat does not use them. This is text in a settings screen, not a file in the repository. Microsoft gives no length limit for it, so the order rows go in the first message. If it is switched off, paste the instructions with that first message; they are not remembered.
Paid planNeeds Copilot Chat on a work Microsoft 365 account. Microsoft says Copilot memory, custom instructions included, works with or without a Microsoft Copilot licence.
Claude Code
- Start
claudein the root oforderdesk/and run/initto generate a startingCLAUDE.md. - Open
CLAUDE.mdand cut it down to this one-page text. Keep a generated line only if the agent could not find it by reading the repository.Project: orderdesk drafts replies to order-status emails for the support team of Kettlebrook Wholesale. It only writes drafts. A person at Kettlebrook reads and sends every reply. Commands - Run the tests: python -m unittest - Print the draft for one sample email: python draft_reply.py E-001 - Python 3, standard library only. Use python3 if python is not found. Where things live - data/: made-up order data and sample emails - prompts/: the reply prompt (added later) - evals/: test cases for the reply prompt and their scores (added later) Rules 1. Never edit files in data/. They are made-up fixtures. 2. Run python -m unittest before you say a change is done, and show the output. - Exit Claude Code and start a new
claudesession in the repository root. It begins with an empty conversation and loadsCLAUDE.mdat launch. - Run
/context alland check thatCLAUDE.mdis listed under Memory files. - Paste the proof task. Do not mention the rules.
Add a function expected_delivery_for(order_id) to orders.py that returns the expected delivery date from the order data, with a test. Do not change draft_reply.py. - Press Ctrl+O when it says it is done, to open the transcript viewer, and check that it ran
python -m unittestand showed the output. - Run
git status -- data/in another terminal and check that nothing indata/changed. - Make the wording of a rule more concrete if it was missed, and test again in a new session. A check that must run every time becomes a hook on day 4.
Note: The vendor calls CLAUDE.md context, not enforced configuration, and advises under 200 lines per file. /context shows how full the window is, /clear starts an empty conversation between tasks and /compact summarises the conversation to free space. Near the limit Claude Code compacts by itself and reloads the root CLAUDE.md from disk. Personal notes go in CLAUDE.local.md, added to .gitignore.
Paid planNeeds a paid Claude plan (Pro, Max, Ultra, Team or Enterprise) or a Claude Console account. The Free plan does not include Claude Code.
OpenAI Codex
- Start
codexin the root oforderdesk/and run/init. It creates a starterAGENTS.mdin that folder. - Open
AGENTS.md, replace the scaffold with this one-page text and save it.Project: orderdesk drafts replies to order-status emails for the support team of Kettlebrook Wholesale. It only writes drafts. A person at Kettlebrook reads and sends every reply. Commands - Run the tests: python -m unittest - Print the draft for one sample email: python draft_reply.py E-001 - Python 3, standard library only. Use python3 if python is not found. Where things live - data/: made-up order data and sample emails - prompts/: the reply prompt (added later) - evals/: test cases for the reply prompt and their scores (added later) Rules 1. Never edit files in data/. They are made-up fixtures. 2. Run python -m unittest before you say a change is done, and show the output. - Quit Codex, then run this check from the repository root. Codex should echo the guidance from your file. The flag stops Codex from asking first, which is acceptable here because the prompt only asks for a summary. Quit Codex again if it stays open after the answer.
codex --ask-for-approval never "Summarize the current instructions." - Start a new session with
codexin the repository root and paste the proof task. Do not mention the rules.Add a function expected_delivery_for(order_id) to orders.py that returns the expected delivery date from the order data, with a test. Do not change draft_reply.py. - Check that it ran
python -m unittestand showed the output once it says it is done. Then rungit status -- data/in another terminal: it must show no change. - Make a rule more concrete if it was ignored, then quit Codex and start it again before you test. Codex builds its list of instruction files when a session starts.
Note: We found no vendor page that says whether /new reloads AGENTS.md in a running session, so restart Codex after every change. Codex stops adding instruction files once they reach 32 KiB together (project_doc_max_bytes). In a long session, /status shows token use (tokens are the small pieces of text a model counts) and /compact replaces earlier turns with a summary.
Paid planThe Codex CLI needs ChatGPT Plus, Pro, Business, Enterprise or Edu, or an API key. A free route for the CLI is not confirmed.
Gemini CLI
- Create
GEMINI.mdin the root oforderdesk/with this one-page text.Project: orderdesk drafts replies to order-status emails for the support team of Kettlebrook Wholesale. It only writes drafts. A person at Kettlebrook reads and sends every reply. Commands - Run the tests: python -m unittest - Print the draft for one sample email: python draft_reply.py E-001 - Python 3, standard library only. Use python3 if python is not found. Where things live - data/: made-up order data and sample emails - prompts/: the reply prompt (added later) - evals/: test cases for the reply prompt and their scores (added later) Rules 1. Never edit files in data/. They are made-up fixtures. 2. Run python -m unittest before you say a change is done, and show the output. - Start
geminiin the repository root and run/memory show. Check that the text of your file is in the output. - Run
/clearto clear the conversation and start a new session. - Paste the proof task. Do not mention the rules.
Add a function expected_delivery_for(order_id) to orders.py that returns the expected delivery date from the order data, with a test. Do not change draft_reply.py. - Check that it ran
python -m unittestand showed the output once it says it is done. Then rungit status -- data/in another terminal: it must show no change. - Run
/memory reload(the commands page calls it/memory refresh) if you changeGEMINI.mdduring a session, then/clear, and test again.
Note: Google now sends individuals to Antigravity CLI, a different product. This course has no checked steps for it. Gemini CLI sends all loaded GEMINI.md files with every prompt, and its footer shows how many context files are loaded. To have it read AGENTS.md too, set context.fileName in settings.json. When the window fills, /compress replaces the chat with a summary.
Paid planNeeds a company Gemini Code Assist Standard or Enterprise licence, or a paid Gemini API or Vertex AI key. Free and Google AI Pro or Ultra sign-in stopped on 18 June 2026.
Cursor
- Create
AGENTS.mdin the root oforderdesk/with this one-page text. If you already madeCLAUDE.mdin the Claude Code tab, Cursor reads that file the same way.Project: orderdesk drafts replies to order-status emails for the support team of Kettlebrook Wholesale. It only writes drafts. A person at Kettlebrook reads and sends every reply. Commands - Run the tests: python -m unittest - Print the draft for one sample email: python draft_reply.py E-001 - Python 3, standard library only. Use python3 if python is not found. Where things live - data/: made-up order data and sample emails - prompts/: the reply prompt (added later) - evals/: test cases for the reply prompt and their scores (added later) Rules 1. Never edit files in data/. They are made-up fixtures. 2. Run python -m unittest before you say a change is done, and show the output. - Open the
orderdeskfolder in Cursor. - Start a new Agent chat. Do not reuse the chat where you wrote the file.
- Paste the proof task. Do not mention the rules.
Add a function expected_delivery_for(order_id) to orders.py that returns the expected delivery date from the order data, with a test. Do not change draft_reply.py. - Check that it ran
python -m unittestand showed the output once it says it is done. Then rungit status -- data/in another terminal: it must show no change. - Click the context ring next to the prompt input and note how much of the window Rules take in the breakdown.
- Make a rule shorter and more specific if it was missed, then test again in another new chat.
Note: Cursor's pages do not say which plans include Rules and AGENTS.md. Check your own plan before you count on it. They also do not say whether AGENTS.md is applied in every chat or only when relevant, while a CLAUDE.md in the project root is always applied. Cursor advises keeping a rule under 500 lines. The Cursor CLI reads the same files.
GitHub Copilot
- Start
copilotin the root oforderdesk/and enter/initto have it draft the repository instructions in.github/copilot-instructions.md. - Open
.github/copilot-instructions.md, replace the draft with this one-page text and save it.Project: orderdesk drafts replies to order-status emails for the support team of Kettlebrook Wholesale. It only writes drafts. A person at Kettlebrook reads and sends every reply. Commands - Run the tests: python -m unittest - Print the draft for one sample email: python draft_reply.py E-001 - Python 3, standard library only. Use python3 if python is not found. Where things live - data/: made-up order data and sample emails - prompts/: the reply prompt (added later) - evals/: test cases for the reply prompt and their scores (added later) Rules 1. Never edit files in data/. They are made-up fixtures. 2. Run python -m unittest before you say a change is done, and show the output. - Start a fresh session with
/new, or exit and startcopilotagain. A running session does not pick up the change. - Enter
/instructionsand check that your file is in the list of discovered instruction files. - Paste the proof task. Do not mention the rules.
Add a function expected_delivery_for(order_id) to orders.py that returns the expected delivery date from the order data, with a test. Do not change draft_reply.py. - Check that it ran
python -m unittestand showed the output once it says it is done. Then rungit status -- data/in another terminal: it must show no change. - Enter
/contextto see how much of the window the instructions use.
Note: The CLI also reads AGENTS.md, CLAUDE.md and GEMINI.md and combines every file it finds, with no general order of precedence. If you made one of those in another tab, keep them the same or switch one off in /instructions. GitHub says instructions guide the model but do not guarantee it follows every rule. /compact compresses the history when the window fills.
Create a free account to save your progress
Free, and no payment details. Your ticks and finished lessons are kept, on every device.
Create a free account I already have an accountCreate a free account to save your progress. Sign in or sign up