Coding with AI tools

Stage 2 · Lesson 2 of 6

Writing project rules in .cursor/rules

Setup and project context

's live in .cursor/rules as .mdc files, with a small block (settings between two lines of three dashes) at the top. A plain .md file in that folder is ignored. The frontmatter decides when a rule loads: alwaysApply: true for every chat, globs for matching files, a description so the Agent pulls it in when relevant, or none of these so it loads only when you @-mention it.

Type /create-rule in the Agent to draft one. Cursor also reads in the root and in subfolders, and User Rules in settings apply to all your projects. Cursor's docs suggest keeping each rule under 500 lines and adding rules only when the Agent repeats a mistake.

Common trapsaving a rule with the .md extension and wondering why the Agent never follows it.

A question to check yourself, an AI practice session and 3 cheat sheet entries come when you add the roadmap to your account. Add it

Resources for this stage

Start with

  • GuideFree
    Cursor Documentation

    Anysphere

    Work through the quickstart, then the Rules and Ignore file pages

Keep handy

  • The shared format your tool can read, with examples of what to put in it

Also worth your time

Mark this stage as not done?