Course contents
Create context files
Write the short instruction file your agent loads every session (AGENTS.md, CLAUDE.md, GEMINI.md or a Cursor rule) with your stack, commands, files and rules.
An instruction file is a short note to every future session: here's the project, here's how we work, here's what never to do. Agents load it automatically at the start, so you stop repeating yourself and rules stick even in a brand-new conversation. You started one in the security lesson. Now you'll make it complete, and keep it short.
Which file does your tool read?
| Tool | Instruction file (as of November 2026) | Shortcut |
|---|---|---|
| Codex | AGENTS.md | /init writes one for you |
| Claude Code | CLAUDE.md. It reads AGENTS.md instead when there's no CLAUDE.md | /init writes a CLAUDE.md |
| Gemini CLI | GEMINI.md | Write it yourself, or ask the agent |
| Cursor | AGENTS.md, or rule files (.mdc) in .cursor/rules/ | /create-rule in the Agent chat |
| GitHub Copilot | .github/copilot-instructions.md, AGENTS.md, or a single CLAUDE.md or GEMINI.md at the project root | Ask the agent to create one |
| Grok Build | Run grok inspect to see which instruction files it found | Ask the agent to create AGENTS.md |
| Lovable | Project settings, then Instructions (up to 10,000 characters) | Paste your rules there |
AGENTS.md is the closest thing to a standard. It's an open format stewarded by the Agentic AI Foundation under the Linux Foundation, and Codex, Cursor, Gemini CLI, Devin, the GitHub Copilot coding agent and many other tools read it. If you use more than one tool, write AGENTS.md. For Claude Code, either let it read AGENTS.md directly (it does when there's no CLAUDE.md), or create a CLAUDE.md whose only line is @AGENTS.md, which imports the shared file.
What goes in, and what stays out
Where does each line belong?
Brand colors: cream #FFF8EE, brown #4A2C1A, accent #C8553D.
Keep it short. Claude Code's documentation recommends keeping each CLAUDE.md under 200 lines, because longer files cost more context and are followed less consistently, and the same logic applies to every tool. A good beginner file fits on one screen: what the project is, the stack, how to preview and ship, a map of the files, the rules, and what “done” means.
Assemble a good AGENTS.md for Crumb & Co. Switch on what helps; leave out what hurts.
# AGENTS.md Crumb & Co.: website for a neighborhood bakery.
# AGENTS.md
## What this is
Website for Crumb & Co., a neighborhood bakery. Visitors are mostly on phones.
## Stack and constraints
Plain HTML, CSS and JavaScript. No frameworks, no build step.
No new packages or outside scripts without asking. Pin exact versions.
## Preview and ship
Preview: start a local server in the project folder.
Ship: commit, then push. The host redeploys automatically.
## Files
index.html (home), archive.html (all past weeks), specials.json (every week, newest first),
invoice.html (the owner's invoice tool), styles.css, app.js.
## Rules
- Brand: cream #FFF8EE background, brown #4A2C1A text, accent #C8553D.
- Secrets only in .env, which stays in .gitignore. None in front-end code.
- Show anything a visitor types as plain text, never as HTML.
- Never turn off a security rule to make an error go away.
## Done means
Checked at 375px wide, no red errors in the console, and you tell me what you tested.Generate a starter file
In Codex or Claude Code, run
/init: Codex writesAGENTS.mdand Claude Code writesCLAUDE.md. With other agents, ask: “Create an AGENTS.md for this project.” Then read what it wrote, because generators guess.VerifyThe file exists and describes your actual project, not a generic one.Cut it down to one screen
Ask the agent to restructure the file, then compare it with the example above.
promptRewrite our instruction file so it fits on one screen, under these headings: - What this is - Stack and constraints - Preview and ship - Files - Rules (keep the Security rules) - Done means Remove anything that's a one-off task, project history, or a secret. Show me the result before saving.VerifyThe file has the six headings, fits on one screen, and has no secrets or one-off tasks.Make one file serve every tool
If you use Claude Code and also want other tools to share the rules, keep the rules in
AGENTS.mdand makeCLAUDE.mda single line:@AGENTS.md. Or deleteCLAUDE.md, and Claude Code readsAGENTS.mddirectly.VerifyYour rules live in exactly one file; any other instruction file points to it.Test it in a fresh session
Quit and start a brand-new session (in Claude Code,
/clearalso works), then ask a question only the file can answer. In Grok Build,grok inspectshould list the file too.promptWhat are this project's rules, and how do I preview it?VerifyThe agent answers correctly from the instruction file.Commit it
Ask the agent to commit the instruction file with a clear message.
VerifyThe git log shows the commit.
Plain-English definitions from the AI Coding Dictionary.