Project Context Files

Encode your project's rules once in a context file (CLAUDE.md, AGENTS.md, .cursor/rules) so every prompt starts with them.

TL;DR

  1. A context file encodes your conventions once so the assistant applies them to every task.
  2. CLAUDE.md, AGENTS.md, and .cursor/rules hold stack, commands, conventions, and guardrails.
  3. Keep it short and high-signal; version it like code and scope rules to the right directories.

What It Is

    Standing Prompt

    The part of every prompt you would otherwise retype, written once.

    Conventions + commands + guardrails
    -> loaded on every task.
    Tool Files

    Each assistant reads its own file for persistent instructions.

    CLAUDE.md / AGENTS.md /
    .cursor/rules/*.mdc
    Versioned

    It lives in the repo and changes through review like code.

    git add CLAUDE.md  # it's project
    knowledge

What To Put In It

    Stack & Commands

    Versions and the exact build, test, and lint commands.

    "TS 5.x, Node 20. Test: pnpm test.
    Lint: pnpm lint."
    Conventions

    Naming, structure, and patterns new code should follow.

    "Named exports only. Zod for
    validation. No default exports."
    Guardrails

    Hard rules the assistant must always respect.

    "No new deps without approval.
    Never edit generated files."

Keep It Sharp

    High Signal

    Crisp rules and commands beat long explanatory prose.

    Bullets and commands, not essays.
    Scope By Path

    Apply rules only where they belong using globs or nesting.

    api/**  -> backend rules
    app/**  -> frontend rules
    Prune Often

    Remove outdated rules so the file stays small and current.

    Delete stale rules; they mislead
    and cost context.

Make It Work For You

    Enable Self-Check

    Commands in the file let an agent run tests and lint on its own.

    "After changes, run pnpm test and
    fix failures."
    Point To Examples

    Reference canonical files the assistant should imitate.

    "Follow the pattern in
    src/features/orders."
    State What Not To Do

    Call out past mistakes so they are not repeated.

    "Do not use the deprecated
    `legacyFetch`."

Tips

  1. Put the build/test/lint commands in the file so the agent can verify its own work.
  2. Scope rules to paths (e.g. .cursor/rules globs) so backend rules do not apply to frontend files.

Warnings

  1. A bloated context file wastes the window on every call and buries the rules that matter.
  2. Stale instructions are worse than none; update the file when conventions change.

In Practice

FAQ