Rule File

Rule File

A rule file is a text file in a software project that gives an AI assistant persistent instructions – for example, which programming language applies or which style is desired. The assistant automatically reads it along with every request, so the same guidelines don't have to be repeated constantly.

Programs today are often written with the help of AI assistants. You type a request into a text field, and the program suggests matching code. This creates an annoying problem: the assistant forgets everything again after every conversation. A rule file solves this. It is a simple text file located in the project folder that contains fixed instructions. The assistant automatically reads it along every time before responding.

The file contains no program code, just text in plain language. Typical sentences are: “Write all comments in English” or “Don’t use external libraries without asking first.” You can think of it as a cheat sheet that the assistant always has in front of it. Well-known file names are AGENTS.md, CLAUDE.md, or .cursorrules – depending on which tool you use.

Why developers want to avoid repeating themselves

Without a rule file, every conversation starts from zero. The developer has to explain that the project uses a particular language, that tests are required, and that a certain folder is off-limits. With ten requests a day, that’s the same preamble ten times over. It costs time, and it’s easy to forget a point.

Even more important is consistency within a team. If five people work on the same project, each would give the assistant slightly different instructions. The result would be code in five different styles. A rule file, on the other hand, lives in the project itself and automatically applies to everyone. It gets versioned like any other file, meaning it’s stored with a change history.

But there is also a downside. Every line in the rule file is sent along with every request and takes up space in the model’s limited working memory. Anyone who writes a hundred rules is displacing space that could go toward the actual code. In practice, short, clear files work better than long sets of rules.

What happens when a request is sent

Technically, a rule file is unspectacular. The development tool searches for a file with a predefined name at startup. If it finds one, it copies its content to the beginning of the request sent to the AI model. Only after that comes the user’s question. The model thus sees a single long text, with the rules placed at the front.

Some tools allow multiple files with different scopes. One file might apply to the entire project, another only to a specific subfolder. There are also rules that only become active for matching file types – for example, design guidelines that only apply when working on a webpage. This keeps the text sent along lean.

A common misconception: a rule file is not a lock. It’s a request, not a technical prohibition. The model can disregard rules, especially if they contradict each other or are very long. Anyone who really wants to prevent an assistant from modifying certain files needs actual access restrictions in the system. The rule file does not replace them.

Rule files in editors and command-line assistants

You’ll mainly encounter this term in programming tools with built-in AI. The editor Cursor popularized the concept with the .cursorrules file. GitHub Copilot, Claude Code, and Google's Gemini CLI have followed with their own variants. In 2025, several providers began agreeing on the common name AGENTS.md, so a project doesn’t need a separate file for every tool.

In the news, the term usually comes up in connection with security. Researchers showed that invisible characters can be hidden in a rule file. A developer then sees a harmless file, but the model reads additional instructions. This type of attack is called prompt injection. That’s why rule files from third-party projects should be checked just as carefully as third-party code.

Related but not the same is the system prompt. It is set by the chatbot’s provider and determines its fundamental behavior. A rule file, on the other hand, belongs to the project and can be changed by any team member. Anyone contributing to larger software today will sooner or later open such a file and add to it.

Subscribe free. Unsubscribe the second it sucks.

High-signal news across AI, business, UX, and tech. Every morning.