Day 2, 25 minutes · beginner
Why it matters
Yesterday you wrote every rule into the task itself: plain HTML, prices that match, no extra files. That works once. By the tenth task you forget a rule, and Copilot does something you did not want. Custom instructions fix that. You write the rules of your project once in a file, and Copilot reads that file at the start of every session.
The same file does more than you might expect. The repository-wide instructions file is also read by the Copilot cloud agent and by Copilot code review on GitHub. So the rules you write today will guide the issue you hand to Copilot in lesson 4 and the review in lesson 5.
Today you let Copilot draft the file, cut it down to the rules that matter, check that Copilot really loads it, and test it with one small change that does not repeat any rule.
What goes in the file
GitHub's advice for this file is practical: what the project is, how to build and test it, and the conventions to follow. For a small site that is a handful of lines. A short file is easier to keep true, and every line of it costs a little context in every session.
Good rules are things Copilot cannot guess from the code:
- Which file is the source of truth. For Brindlewick Cheese, that is
cheeses.json. - What must change together. A new price goes into
cheeses.jsonand the table inindex.htmlin one change. - Formats. Euros per 100 g, two decimals.
- Limits. No frameworks, no build tools, never push to main.
- How to finish. List every changed file, so you know what to check.
Leave out what Copilot can read for itself, such as the names of the files in the folder, and leave out wishes like "write good code".
Where Copilot looks
Copilot CLI reads several kinds of instruction files and combines them all:
.github/copilot-instructions.mdfor rules for the whole repository. This is the file you make today..github/instructions/NAME.instructions.mdfor rules that apply only to some files, chosen with anapplyTopattern at the top.AGENTS.md,CLAUDE.mdandGEMINI.md, so a project that already has one of those for another agent keeps working.~/.copilot/copilot-instructions.mdfor your personal rules across all projects.
There is no fixed order between these files. If two of them disagree, Copilot gets both rules and has to guess. Keep one place for each rule. If you also use Claude Code, the Claude Code 101 course shows the same idea with CLAUDE.md.
The steps
- Let Copilot draft the file.
/initlooks at the project and writes.github/copilot-instructions.mdwith build commands, structure and conventions. For a two-file site the draft will be longer than you need. - Cut it down. Replace the draft with the five rules in the guide. Read each line and ask: would Copilot get this wrong without it?
- Start a new session. A running session does not see changes to instruction files. Exit and start again, or use
/new. - Check that the file is loaded.
/instructionslists every instruction file Copilot found for this session, and lets you switch one off. - Test it with a task that repeats no rule. Ask for a fourth cheese at "3.4 euros". If the file works, Copilot writes 3.40, updates both files and lists them.
- Commit the file. The cloud agent in lesson 4 only sees what is pushed to GitHub, so the file has to be in git.
Follow the guide for GitHub Copilot below for the exact commands.
Example: Roos's rules
The /init draft for Roos's site had a section about build commands, which the site does not have, and a list of the two files. She replaced it with the five rules. After a new session, /instructions showed the file switched on. She asked for Dune Goat at 3.4 euros. Copilot added it to cheeses.json and index.html as 3.40 and ended with "Changed: cheeses.json, index.html". She did not have to mention either file.
Common mistakes
- Testing in the old session. The change is not loaded until you start a new session, so the test proves nothing.
- A long file of general advice. Rules that only say "be careful" add context without changing what Copilot does.
- Rules in two places. A rule in
AGENTS.mdand a different one in.github/copilot-instructions.mdleave Copilot to choose. - Not committing the file. It works on your machine, and the cloud agent in lesson 4 never sees it.
Deeper dive
Today's actions
Ticks are not saved without an accountDo it in GitHub Copilot
GitHub Copilot
- In your terminal, go into the brindlewick-cheese folder and run
copilot. - Type
/initand press Enter. Copilot looks at the project and writes or updates.github/copilot-instructions.md. Approve the file change if it asks. - Type
/exit, open.github/copilot-instructions.mdin your editor and replace its text with these rules. Save the file.This repository is the website of Brindlewick Cheese, a small cheese shop. - Plain HTML and CSS only. No frameworks, no build tools, no npm packages. - cheeses.json is the source of truth for cheese names and prices. When a cheese or a price changes, update cheeses.json and the table in index.html in the same change. - Prices are in euros per 100 g, always with two decimals, for example 3.20. - Never push to the main branch. - When you finish, list every file you changed. - Run
copilotagain. Instruction changes only load in a new session. Type/instructionsand check that.github/copilot-instructions.mdis in the list and switched on. - Paste this task and press Enter. It does not repeat the rules, so you can see whether Copilot follows the file.
Add a fourth cheese: Dune Goat, a fresh goat's milk cheese, 3.4 euros per 100 g. - Check the result: Dune Goat should be in both cheeses.json and index.html, shown as 3.40, and Copilot should list the files it changed. Type
/exit. - Commit the instructions file and the new cheese yourself.
git add .github/copilot-instructions.md cheeses.json index.html git commit -m "Add custom instructions and Dune Goat"
Note: Inside a session, /new also starts a fresh session, and copilot --continue resumes the last one with the new instructions loaded. Copilot CLI also reads AGENTS.md, CLAUDE.md and GEMINI.md, and combines every file it finds without a fixed order, so avoid rules that contradict each other.
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