Skip to content

Module 03 · Lesson 3.5

Assistant Context Files

30 minUpdated 19 Nov 2026Part of Project Scaffolding · New Project Creation
On this page
  1. What you will learn
  2. What an assistant context file is
  3. What to include and what to leave out
  4. Worked scenario: Tidewell's AGENTS.md
  5. Check that the file matches the project
  6. Step-by-step workflow: write and maintain the file
  7. What the assistant does and what you do
  8. Conclusion and your next step
  9. Reusable prompt
  10. Expected output
  11. Common errors and fixes
  12. Validation checklist
  13. Hands-on exercise
  14. Knowledge check
  15. Frequently asked questions
  16. References

Imagine a new contractor on their first morning. They are skilled, but they know nothing about your clinic. A one-page note by the door helps a lot: where things are, how to start the machines and which rooms to leave alone. An AI coding assistant starts every session in exactly that position.

In this lesson you write that note for Tidewell's booking project. It is a short file called AGENTS.md. You learn what belongs in it, what to leave out and how to check that it is still true. You also run a small script that catches a missing section or a command that does not exist.

What you will learn

  • Explain what an assistant context file is and why a project needs one.
  • Write an AGENTS.md with commands, a folder map, conventions, a do-not-touch list and a definition of done.
  • Keep the file short and current, and leave out what does not belong.
  • Check the file against the project, and treat it as guidance, not protection.

Before you start

  • Completed Linting, Formatting and Type Checks, or have check commands of your own.
  • Access to any capable AI assistant.
  • Optional: Node.js and the project from earlier lessons, if you want to run the examples.

What an assistant context file is

An assistant context file is a plain text file in your repository that an AI coding assistant reads at the start of a session. It tells the assistant how your project works. Without it, you repeat the same instructions in every chat, and the assistant guesses whatever you forget.

AGENTS.md
An open, tool-neutral file name for these notes. Many assistants read it. It is a convention, so each tool decides how it uses the file.
Context
Everything the assistant can see when it answers: your message, the files it reads and notes like this one. It is its working memory for the session.
Instruction file
Another name for a context file. It holds standing instructions rather than a single request.
Definition of done
A short list of what must be true before any task counts as finished.

Some tools read their own file names as well. For example, Claude Code reads CLAUDE.md, and GitHub Copilot reads .github/copilot-instructions.md. Which names a tool reads can change, so check the tool's own page. See How Claude remembers your project (opens in a new tab) and Adding repository custom instructions for GitHub Copilot (opens in a new tab). The AGENTS.md site (opens in a new tab) describes the shared convention.

What to include and what to leave out

A context file is read every time. Each extra line costs attention, and a long file hides the rules that matter. Write only what the assistant cannot work out for itself from the code.

IncludeLeave out
One line on what the project is for.The full requirements. Link to docs/requirements.md instead.
The exact commands to install, run and check.Commands that do not exist yet, or that you have not run.
A short folder map.A copy of the whole file tree. It goes out of date.
Rules the code cannot show, such as 'never edit an applied migration'.General advice such as 'write clean code'.
A do-not-touch list.Secrets, keys or real data. Never put any in this file.
A definition of done.A long history of past decisions. Link to the decision records.

A good test is this: if a new human developer would ask the question on day one, answer it here. If the code already answers it, leave it out. Aim for a file that fits on one screen or two.

Worked scenario: Tidewell's AGENTS.md

This is the file for tidewell-booking. It uses the folder layout from lesson 3.2, the settings rules from lesson 3.3 and the check commands from lesson 3.4. It sits in the root of the repository.

MarkdownAGENTS.md
# Tidewell booking

A web app where patients of Tidewell Physiotherapy (a fictional clinic) see free slots and move or cancel their own bookings. Requirements are in `docs/requirements.md`.

## Commands

- `npm install` installs packages.
- `npm run dev` starts the app at http://localhost:3000.
- `npm run check` runs lint, format check and type check. Run it before you say a task is done.
- `npm run lint`, `npm run format:check` and `npm run typecheck` run one check each.

## Folder map

- `docs/` requirements, acceptance criteria, architecture and decision records (`docs/adr/`).
- `db/migrations/` numbered SQL files, applied in order.
- `src/app/` pages and API route handlers.
- `src/features/bookings/` booking rules, validation, service and types.
- `src/lib/` shared helpers: `config.ts`, `db.ts`, `problem.ts`, `api-client.ts`.
- `src/components/` shared interface pieces.

## Conventions

- TypeScript strict mode is on. Do not use `any` to silence an error.
- SQL is written by hand and always parameterised ($1, $2). Never build SQL from strings.
- Never edit a migration that has been applied. Add a new numbered file.
- Every endpoint and screen names the requirement it serves (for example FR-02) in a comment.
- Errors use the problem format in `src/lib/problem.ts`.
- Settings come from `src/lib/config.ts`. Do not read `process.env` anywhere else.
- Business rules live in `src/features/bookings/rules.ts`, not in settings.

## Do not touch

- `.env` and `.env.local`. Never print, copy or commit their contents.
- Applied files in `db/migrations/`.
- Accepted decision records in `docs/adr/`. Ask first.

## Definition of done

- `npm run check` passes.
- The change traces to a requirement ID.
- New behaviour has a matching acceptance scenario in `docs/acceptance-criteria.md`.
- No new package was added without saying why.

Forty-two lines. Every command exists, and the file contains no secret.

What each part does

  • The opening lines say what the project is and where the requirements are.
  • Commands give the exact way to start the app and run every check, and tell the assistant to run the check before saying a task is done.
  • Folder map says where each kind of file goes, so new files land in the right place.
  • Conventions hold rules the code does not show: strict types, safe database queries, migrations that are never edited, requirement references and the one home for settings and business rules.
  • Do not touch names what is off limits, and says to ask before changing an accepted decision record.
  • Definition of done lists what must be true before a task is finished.

Two lines are worth a second look. The line about parameterised SQL means database queries use placeholders for values instead of gluing text together, which protects against injection attacks. The line about process.env keeps all reading of settings in config.ts, from lesson 3.3.

Check that the file matches the project

A file that names a command that does not exist is worse than no file, because the assistant will run it and fail. This checker reads the text and compares it with the real package.json scripts. It checks for the five required sections and the length. Then it looks at every npm run command in the text.

TypeScriptcheck-agents-md.ts
export interface Scripts {
  [name: string]: string;
}

const REQUIRED_HEADINGS = ["Commands", "Folder map", "Conventions", "Do not touch", "Definition of done"];
const MAX_LINES = 80;

/** Check an AGENTS.md text against the project's real package.json scripts. */
export function checkAgentsFile(text: string, scripts: Scripts): string[] {
  const problems: string[] = [];
  const lines = text.split("\n");

  if (lines.length > MAX_LINES) problems.push(`Too long: ${lines.length} lines (limit ${MAX_LINES})`);

  for (const heading of REQUIRED_HEADINGS) {
    if (!lines.includes(`## ${heading}`)) problems.push(`Missing section: ${heading}`);
  }

  for (const match of text.matchAll(/npm run ([a-z:-]+)/g)) {
    if (!(match[1] in scripts)) problems.push(`Command not in package.json: npm run ${match[1]}`);
  }
  return problems;
}

Tested with the TypeScript compiler. The headings and the line limit are choices for this project, not a standard.

What each part does

  • REQUIRED_HEADINGS and MAX_LINES are this project's own rules for the file.
  • checkAgentsFile takes the file's text and the project's scripts, and returns a list of problems.
  • The first check flags a file that is too long.
  • The second loop flags any missing section.
  • The last loop finds each npm run name and flags any name that is not a real script.

Now try it on a rushed first draft. It has three sections missing and mentions a test command, but tests only arrive in Module 7.

TypeScripttry-draft.ts
import { checkAgentsFile, type Scripts } from "./check-agents-md";

const scripts: Scripts = {
  dev: "next dev",
  lint: "eslint",
  "format:check": "prettier --check .",
  typecheck: "tsc --noEmit",
  check: "npm run lint && npm run format:check && npm run typecheck",
};

const draft = [
  "# Tidewell booking",
  "## Commands",
  "- `npm run check` runs every check.",
  "- `npm run test` runs the tests.",
  "## Conventions",
  "- Parameterised SQL only.",
].join("\n");

const problems = checkAgentsFile(draft, scripts);
console.log(problems.length === 0 ? "AGENTS.md looks right." : problems.join("\n"));
OutputCaptured from a real run
Missing section: Folder map
Missing section: Do not touch
Missing section: Definition of done
Command not in package.json: npm run test

The same checker, run on the full Tidewell file above with the same scripts, prints one line. Run twice, the result is identical.

Output on the full fileCaptured from a real run
AGENTS.md looks right.

Step-by-step workflow: write and maintain the file

  1. Step 1: Collect the facts

    Gather the commands that you have run, the folder layout, the rules from earlier lessons and the things that must never be touched.

    What you should see: A list of facts, each one true today.

  2. Step 2: Write the first draft

    Use the five headings: Commands, Folder map, Conventions, Do not touch, Definition of done. Start with one line about the project.

    What you should see: A file of under 80 lines.

  3. Step 3: Cut it down

    Delete anything the code already shows, anything general and anything long. Link to documents instead of copying them.

    What you should see: A shorter file with only what the assistant cannot guess.

  4. Step 4: Test it in a fresh session

    Open a new assistant session and ask it to describe the project and the rules, using only the file. Check its answer.

    What you should see: You see which rules it read and which it missed.

  5. Step 5: Check it against the project

    Run commands from the file. Run a checker like the one above. Fix any mismatch.

    What you should see: Every command in the file works.

  6. Step 6: Update it in the same change

    When a command, a folder or a rule changes, edit the file in the same commit. Make that part of the definition of done.

    What you should see: The file stays true as the project grows.

Keeping the notes true
  1. Facts

    Run and confirmed

  2. Draft

    Five sections

  3. Cut

    Only what it cannot guess

  4. Test

    Fresh session

  5. Check

    Against the project

  6. Update

    In the same commit

A context file is code for the assistant. It needs the same care.

What the assistant does and what you do

TaskAssistant's partYour part
Drafting the fileCan draft it from the repository.Check every command and rule. Cut anything that is guessed.
Following the fileReads it and usually applies its rules.Review the work. It can still miss a rule.
Proposing changes to the fileCan suggest updates after a change.Approve each one. The file steers all later sessions.
Protecting filesCannot be forced by a text file.Use ignore files, permissions and review for real protection.
Choosing the rulesNot its job.Decide the conventions and the do-not-touch list.

Conclusion and your next step

An assistant context file is the note by the door: purpose, commands, folder map, rules, off-limits areas and what done means. Keep it short, true and free of secrets. Check it against the project, update it in the same change as the code, and remember that it guides the assistant but does not enforce anything.

Your next step: your repository is now scaffolded, with settings, checks and notes in place. Move on to the data. Start Module 4 with Data Modeling, APIs and Backend, and then Modelling Entities and Relationships.

For more on writing good notes for assistants, read Giving AI Coding Assistants Useful Context. You can also revisit the module overview, Project Scaffolding, for the assignment and checklist.

Reusable prompt

Draft a short AGENTS.md from facts

Gets a first draft of a context file from facts you supply, with anything it is unsure of marked for you to check.

You are helping me write an AGENTS.md for an AI coding assistant. Use only the facts below. Do not invent commands, folders or rules.

Project: tidewell-booking, a fictional clinic booking web app. Next.js, TypeScript strict, PostgreSQL.
Commands that exist: npm install, npm run dev, npm run lint, npm run format:check, npm run typecheck, npm run check (runs all three).
Folders: docs/, db/migrations/, src/app/ (pages and api route handlers), src/features/bookings/ (rules.ts, validation.ts, service.ts, types.ts), src/lib/ (config.ts, db.ts, problem.ts, api-client.ts), src/components/.
Rules: parameterised SQL only; never edit an applied migration, add a new one; every endpoint and screen traces to a requirement ID; errors use the problem format; settings are read only in src/lib/config.ts; the 24-hour notice period is a business rule in rules.ts.
Off limits: .env files, applied migrations, accepted decision records (ask first).

Tasks:
1. Write the file with these headings only: Commands, Folder map, Conventions, Do not touch, Definition of done. Add one opening line saying what the project is.
2. Keep it under 60 lines. Link to documents instead of copying them.
3. Do not include any secret, key or real data.
4. After the file, list anything you were unsure of, so that I can check it.
Show the reusable template

Replace each {{placeholder}} with your own details.

You are helping me write an AGENTS.md for an AI coding assistant. Use only the facts below. Do not invent commands, folders or rules.

Project: {{project_description_and_stack}}.
Commands that exist: {{commands}}
Folders: {{folder_map}}
Rules: {{conventions}}
Off limits: {{do_not_touch}}

Tasks:
1. Write the file with these headings only: Commands, Folder map, Conventions, Do not touch, Definition of done. Add one opening line saying what the project is.
2. Keep it under {{max_lines}} lines. Link to documents instead of copying them.
3. Do not include any secret, key or real data.
4. After the file, list anything you were unsure of, so that I can check it.

Expected output and limitations

A short file with the five headings, one opening line, only the commands and folders you gave, and a separate list of anything the assistant was unsure of.

Sample responseIllustrative — your output will differ
# Tidewell booking
A clinic booking web app (fictional). Requirements: docs/requirements.md.

## Commands
- npm run dev starts the app.
- npm run check runs lint, format check and type check.

## Do not touch
- .env files and applied migrations. Ask before changing a decision record.

Unsure, please check: whether npm install should be listed, and whether the type check runs in the check command.

Limitations to keep in mind

  • The assistant may add commands or rules that sound likely but that you never gave it. Run every command listed.
  • It may be too long. Cut anything the code already shows.
  • It cannot know what has changed since you wrote the prompt. Update the file when the project changes.

Common errors and how to fix them

The file lists a command that does not exist.

Why it happens: It was written from memory, or the command was removed later.

Fix: Run every listed command, and check the file against package.json with a script like the one in this lesson.

The file grows to hundreds of lines and the assistant misses its rules.

Why it happens: Everything was added and nothing was removed.

Fix: Keep only what the assistant cannot guess. Link to the longer documents.

A key or a real value is pasted into the file.

Why it happens: It was added to make a setup step 'just work'.

Fix: Remove it, revoke and replace the key, and say in the file where the settings come from instead.

Validation checklist

Tick each item once you have confirmed it.

Hands-on exercise

An AGENTS.md for Ferngate Cycle Repairs

Write a short AGENTS.md for Ferngate's parts tracker. Use the five headings. Then add one line you would deliberately leave out, and say why.

You will need

  • Ferngate's stack: Next.js, TypeScript strict, PostgreSQL.
  • Commands that exist: npm run dev and npm run check.
  • Rules: parameterised SQL only, never edit an applied migration, the low-stock threshold is 'to be agreed' and must not be guessed.
  • Off limits: .env files and applied migrations.

Acceptance criteria

Your work is done when every one of these is true.

Hints (2)
  • Ask what a mechanic's assistant would get wrong on day one without being told.
  • A rule about a decision that is not yet made is useful: it stops the assistant from making it for you.
Show a model answer

A strong answer is short, and it uses only the commands and folders it was given. It makes the threshold a clear rule to ask the owner, which stops an assistant from inventing a number. It lists the do-not-touch items and a definition of done that mentions the check command. It leaves out long material such as the whole requirements list and links to it. It contains no secrets. The note about what was left out shows that the writer cut on purpose.

Knowledge check

Choose an answer, then check it. Nothing is recorded — this is for you.

  1. 1.Which line belongs in an AGENTS.md?
    Show the answer and explanation

    Answer: B. A specific rule that the code does not show is exactly what the file is for. 'Write clean code' is tempting but too general to change what the assistant does. A password must never go in the file, because the file is committed and read widely.

  2. 2.The file says 'do not touch .env'. Does that protect the file?
    Show the answer and explanation

    Answer: B. The file steers the assistant, but it enforces nothing. Believing it is a lock is tempting because it sounds firm. Being committed does not add any protection to a different file.

  3. 3.Why update AGENTS.md in the same commit as a change to a command?
    Show the answer and explanation

    Answer: A. A wrong instruction makes the assistant fail in confident ways. Git has no such rule, and length is not a goal. A shorter, true file is better than a long, stale one.

Frequently asked questions

What is AGENTS.md?

It is a plain text file in the root of a project that tells AI coding assistants how the project works. It holds commands, a folder map, rules and things not to touch. It is an open convention that many tools read, and each tool decides how it uses the file.

What is the difference between AGENTS.md and CLAUDE.md?

AGENTS.md is a tool-neutral name. CLAUDE.md is the file name that Claude Code reads. Some tools read their own file name, so check each tool's documentation and avoid keeping two long files that disagree.

How long should an AGENTS.md be?

As short as you can make it, often one or two screens. Include only what the assistant cannot work out from the code, and link to longer documents. A long file hides the rules that matter.

Can an assistant ignore my AGENTS.md?

Yes. The file is guidance, so an assistant may miss or misapply a rule. Review its work, run your checks and use ignore files and permissions for anything that must be protected.

Written by
PromptFable Editorial
Last updated 19 Nov 2026
Review
Reviewed by Waseem Nadir, Technical Reviewer
Last reviewed 27 Nov 2026

References

Primary sources for the technical details in this lesson. Vendor platforms change — check the official page if anything here looks different from what you see.

PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.