Sub topic 9
Standing Instructions and Project Conventions
Earlier chapters covered the context you choose for each request: files, selections, and errors. This chapter covers context that stays the same across requests. It assumes you can already write a focused request with a task statement, and that you have used an AI chat or coding assistant. Some experience with a test runner and a code editor helps too.
What standing instructions are
A standing instruction is a rule you write once and supply with every request. Typical examples are the language version, the test framework, naming rules, and how much the assistant should change at a time.
Without standing instructions, you repeat the same sentences in every request. You also risk forgetting them on a busy day. The assistant then guesses, and the guesses may not match your project. It might write tests in a different framework, or it might skip type hints.
Standing instructions are different from per-request context:
| Kind | Changes between requests? | Example |
|---|---|---|
| Per-request context | Yes | The failing file, the selected function, the traceback |
| Standing instructions | Rarely | "Tests use pytest. Add type hints to new code." |
Both kinds end up in the same context window. Standing instructions use part of your budget on every request, so they compete with the file, selection, and error you attach.
How tools supply them
Tools differ in how they load standing instructions. Common patterns are:
- A project file in the repository root that the tool reads automatically, often Markdown.
- A user-level settings file that applies to all your projects.
- A custom instruction field in the tool's settings.
- Text you paste at the top of a conversation.
Check your tool's documentation for the file names and the loading rules. Some tools load a file only when you ask for it, and some load several files and merge them. The principle is the same everywhere: the instructions must be in the context to have any effect. If the assistant never sees the file, the file does nothing.
A project file has one extra benefit. It lives in version control, so everyone on the team gives the assistant the same rules, and changes to the rules go through review like code.
A small example
Here is a minimal conventions file for the project used in this tutorial.
# Project conventions
- Language: Python 3
- Tests: pytest, files named test_*.py
- Keep functions small and add type hints to new codeEach line states a fact the assistant could not reliably infer or would otherwise have to guess. Now compare two requests for the same bug in stats.py, where average([]) raises ZeroDivisionError.
Without the conventions file, you would need to write this:
Context: stats.py (attached), selection: the average function (lines 1-2).
Error: ZeroDivisionError: division by zero when average([]) is called.
Task: Change average so an empty list returns None instead of raising. Keep the function signature and do not change other code.With the conventions file loaded, the request stays the same length. The assistant still knows to use type hints and pytest if it adds a test. You did not repeat those details.
Notice a tension in this example. The request says "keep the function signature", while the conventions say "add type hints to new code". Because average is existing code, the request wins: the signature stays as it is. A good assistant will follow the more specific, more recent instruction. You can avoid relying on that by making the scope explicit in the conventions, for example "add type hints to new code, not to existing functions unless asked".
What belongs in standing instructions
Put a rule in standing instructions when it meets three tests:
- It applies to most requests, not only one task.
- The assistant cannot easily infer it from the files you attach.
- A wrong guess is costly or annoying to fix.
Good candidates include:
- Language and runtime versions. "Python 3.11" prevents syntax from newer or older versions.
- Tools and commands. "Run tests with
pytest -q" tells the assistant how you verify work. - Layout. "Source in
src/, tests intests/" stops files from appearing in the wrong place. - Style rules that linters do not enforce. For example, "prefer early returns over nested conditions".
- Behavior limits. "Do not edit files outside the one I attached" or "ask before adding a dependency".
- Output preferences. "Show a diff, not the whole file."
What does not belong
Leave these out:
- Anything a tool already enforces. If a formatter fixes spacing on save, a spacing rule adds length and nothing else.
- One-off task details. "Fix the bug in
average" belongs in the request. - Long essays. A 3,000-word style guide uses budget on every request, and the rules that matter get diluted.
- Secrets. Never put API keys, passwords, or tokens in a standing file. A standing file is sent every time and is often committed to a repository.
- Vague aspirations. "Write clean, high-quality code" gives the assistant nothing to act on.
Writing rules the assistant can follow
Specific, checkable rules work better than general ones. Compare these pairs.
| Weak | Stronger |
|---|---|
| Write good tests | Tests use pytest, live in `tests/`, and cover one behavior each |
| Be careful with changes | Change only the selected code unless I say otherwise |
| Use modern Python | Target Python 3.11. Use `list[int]`, not `List[int]` |
| Handle errors properly | Return `None` for missing values. Raise `ValueError` for invalid input |
A good rule is short, uses concrete names, and could be checked by reading the output. Write each rule as an instruction ("Use pytest"), not a description ("We like pytest"). When a rule has an exception, include the exception in the same line, because the assistant may not see it otherwise.
Keep the file short. A page or less is a practical target. If the file grows, move detailed material into separate documents and mention them by name, then attach them only when a task needs them. That keeps the always-on cost low.
How standing instructions interact with the budget
Everything in the context window shares one limit. A conventions file of 300 words is cheap in a large window. In a small window, or in a long conversation, it still takes space from your attached files and traces.
Two habits help:
- Measure the file against its benefit. If a rule never changes an answer, delete it.
- Put the most important rules near the top. Long contexts can dilute attention, and the start of a list is usually the safest place for rules you cannot afford to lose.
Keeping the file current
A stale standing file is worse than none, because the assistant trusts it. If the project moves from unittest to pytest and the file still says unittest, the assistant will confidently write the wrong tests.
Review the file when you:
- change a tool, framework, or version,
- notice the assistant repeating the same mistake,
- add a new directory or workflow,
- find a rule you no longer follow yourself.
A useful trick is to treat repeated corrections as a signal. If you write "use type hints" in three requests in a row, move it into the standing file. The reverse also holds: if you keep overriding a standing rule, remove it or narrow it.
Where the rules apply
Rules often differ by area. A repository might have a Python backend and a TypeScript frontend, and a single global file cannot describe both well. Your options:
- One file with sections. Simple, but every request pays for every section.
- Separate files per directory or area. Cheaper per request, if your tool loads the right one for the files in play.
- A global user file plus a project file. Personal preferences go in the first, project rules in the second. Keep them from contradicting each other.
Pick the simplest layout that keeps each request's rules relevant. Start with one file and split it only when it becomes long or contradictory.
Failure modes
- Silent non-loading. The file has the wrong name or location, so the assistant never sees it. Test by asking it to state your conventions. If it cannot, the file is not in context.
- Conflicting rules. Two lines pull in opposite directions, such as "keep changes minimal" and "always refactor for clarity". The assistant picks one unpredictably.
- Over-constraint. So many rules that the assistant spends its effort on compliance and misses the actual task.
- Drift. The file describes the project as it was six months ago.
- Treating rules as guarantees. The assistant usually follows standing instructions but can miss them, especially in long conversations. Linters, formatters, and tests are what enforce rules. Standing instructions only make violations less likely.
Verifying that the rules work
Run a quick check after you create or edit the file:
- Start a fresh conversation.
- Ask the assistant to summarize your project conventions. Compare its answer with the file.
- Make a small request that the rules should affect, such as "add a test for
average([])". - Check the output against the rules: pytest, a
test_*.pyfilename, type hints on the new code.
If a rule fails, first check whether the assistant saw it. Then check whether the wording is vague or conflicts with another line. Adjust the text, not just the request, so the fix lasts.
Exercises
Exercise
A teammate's conventions file contains these lines: "Write clean code", "Tests use pytest", "We have a bug in average() with empty lists", and "API_KEY=sk-live-abc123". Which lines should be removed or rewritten, and why?
Show answer
Remove "API_KEY=sk-live-abc123" because secrets must never go in a standing file that is sent with every request and often committed. Remove "We have a bug in average() with empty lists" because it is a one-off task detail that belongs in a request and will become stale. Rewrite "Write clean code" as a specific, checkable rule, such as "Keep functions small and add type hints to new code". Keep "Tests use pytest".
Exercise
Your conventions file says "Add type hints to new code". You ask the assistant to fix average and say "keep the function signature". Why might this cause confusion, and how do you remove the risk?
Show answer
The standing rule suggests adding hints, while the request asks to leave the signature alone. The assistant has to decide which rule wins. Remove the risk by narrowing the standing rule ("not to existing functions unless asked") or by stating in the request that existing signatures stay unchanged.
Exercise
After editing your conventions file, the assistant still writes unittest-style tests. List the checks you would make, in order.
Show answer
First, confirm the assistant sees the file by asking it to state your conventions in a fresh conversation. If it cannot, fix the file name or location. Second, look for a conflicting line, such as an older mention of unittest elsewhere in the file or in a user-level file. Third, make the rule more specific, for example "Tests use pytest, files named test_*.py, plain assert statements". Finally, repeat a small test request and check the output.