promptgarden ๐ŸŒฑ
๐ŸŒ ES
Guideโ—โ—โ—‹3 min ยท +40 XP

CLAUDE.md / AGENTS.md: Give Your Agent Memory & Rules

A CLAUDE.md file is a cheat sheet your coding agent automatically reads before every task.

The problem without memory

An AI agent starts from zero every new session. It doesn't know your team's coding rules, which commands run your tests, or that you never push straight to the main branch โ€” unless you tell it again every single time.

The fix: a rules file

CLAUDE.md (some tools call it AGENTS.md) is a plain markdown file in your project's root folder. The agent reads it automatically at the start of every session and treats its content as standing instructions โ€” like a memory that persists across individual chats.

What belongs in it?

  • Project context ("This is a React frontend with an Express backend")
  • Commands ("Run tests with npm test")
  • Rules ("Never push directly to main", "Always run tests before committing")
  • Code style preferences
  • Known gotchas in the project

Why it works

Without this file, you'd repeat the same rules every new session. With it, the ground rules are always present โ€” the agent behaves more consistently and makes fewer avoidable mistakes.

EXAMPLE

# CLAUDE.md - Tests: `npm test` - Never force-push to main - Commit messages in English, short, imperative mood

QUICK QUIZ

When does a coding agent typically read the CLAUDE.md file?

SOURCES

RELATED TOPICS

Claude Code: Anthropic's CLI Agent โ—โ—โ—‹System Prompt vs. User Prompt โ—โ—โ—‹Pattern: Feed Context Instead of Asking Vaguely โ—โ—‹โ—‹