How to write a CLAUDE.md or AGENTS.md file

A CLAUDE.md or AGENTS.md file is a project instruction file for AI coding assistants. It should tell the agent how the repo works, what commands to run, and what behavior to avoid.

Start with durable project facts

Include the stack, package manager, app structure, test commands, build commands, and deployment assumptions. Keep it factual and current.

Avoid long philosophy unless it changes implementation decisions. The agent needs operational truth.

Write rules that prevent mistakes

Good rules are specific: do not remove postbuild scripts, do not hard-code SEO metadata, use Layout for pages, preserve trailing slash behavior.

Weak rules are vague: write good code, make it clean, be careful. Those do not help an agent make a decision.

Add verification steps

Tell the agent which checks prove the work is done: build, tests, route inspection, browser QA, or schema validation.

For content-heavy sites, include SEO checks such as unique titles, descriptions, canonical URLs, and structured data.

Use Riflet to share the file

When asking an AI to work on a repo, include CLAUDE.md or AGENTS.md near the top of the context bundle along with the relevant source files.

Build better AI context with Riflet

Collect the files, notes, websites, and docs that matter. Export one portable bundle for any AI.

Download Riflet free

Frequently asked questions

Is how to write a claude.md or agents.md file only useful for developers?

No. The same context principles apply to research, writing, legal review, client work, product planning, and any workflow where the AI needs project-specific source material.

Does more context always produce better AI output?

No. Relevant, well-structured context usually beats a large dump of loosely related files. Large context windows make preparation more important, not less important.

Where does Riflet fit in this workflow?

Riflet is the assembly step. It helps gather source material, filter it, estimate the token budget, and export one portable file for the AI tool you choose.

Does Riflet replace RAG or AI project features?

Not always. RAG is useful for large retrieval systems. AI project features are useful inside one platform. Riflet is best when you want explicit, portable context you can inspect before using.