Claude Code for builders: CLAUDE.md memory, rules, skills, plugins and hooks
How Claude Code remembers your project (CLAUDE.md, AGENTS.md, rules and auto memory), where files go, how to write good instructions, and how skills, plugins and hooks extend it.
Key ideas
How it works
1. Where instructions live
| Scope | Location | Shared with |
|---|---|---|
| Managed policy | macOS /Library/Application Support/ClaudeCode/CLAUDE.md, Linux/WSL /etc/claude-code/CLAUDE.md, Windows C:\Program Files\ClaudeCode\CLAUDE.md | Everyone on the machine (set by IT) |
| User | ~/.claude/CLAUDE.md | Only you, all projects |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md | The team, through Git |
| Local | ./CLAUDE.local.md (add to .gitignore) | Only you, this project |
Run /init in a repository to have Claude draft a CLAUDE.md from the code, and /memory to open and edit memory files.
2. Write a CLAUDE.md that works
# SkillNavora website
## Build and test
- Regenerate pages with `python3 tools/gen_site.py`; never hand-edit generated HTML.
- Before publishing: no broken internal links, no file over 25 MB, headless check of changed pages.
## Conventions
- Plain English, Indian number format, no model names in commit messages.
- Secrets live in Cloudflare settings, never in the repository.
## Where things are
- Lessons: tools/aiguides/*.py Pages: generated into the repo root
@docs/architecture.md- Target under 200 lines per file. Use headings and bullets; avoid contradictions.
- Write instructions you can verify ("run X before committing"), not wishes ("write good code").
- Import other files with
@path/to/file; they load with the CLAUDE.md that references them. - CLAUDE.md is guidance, not enforcement. To block an action, use a PreToolUse hook or permission rules.
3. Rules for parts of the codebase
Put rules that only matter for some files in .claude/rules/, with a paths list in the frontmatter:
---
paths:
- "src/api/**/*.ts"
---
# API rules
- Every endpoint validates input and returns typed errors.
- Add a test in tests/api for each new route.4. AGENTS.md and other tools
If your repository already has an AGENTS.md (used by several coding agents), Claude Code reads it when there is no CLAUDE.md in your working folder or above. To keep one source for every tool, put @AGENTS.md inside CLAUDE.md so both are used.
5. Auto memory
| CLAUDE.md | Auto memory | |
|---|---|---|
| Who writes it | You | Claude |
| Contains | Instructions and rules | Learnings and patterns from your corrections |
| Scope | Project, user or organisation | Per repository, shared across worktrees |
| Loaded | Every session | Every session (first 200 lines or 25 KB) |
Review auto memory now and then with /memory, and delete notes that are wrong or outdated.
6. Skills, plugins and hooks in Claude Code
- Skills:
~/.claude/skills/<name>/SKILL.mdfor you,.claude/skills/<name>/SKILL.mdfor the project. Run with/<name>; manage with/skills. - Plugins: install from marketplaces with the
/plugincommand, or use plugins synced from your claude.ai account (run/reload-pluginsafter adding one on the web). - Connectors you added on claude.ai are available in Claude Code when you sign in with the same account.
- Hooks: shell commands that run on events such as before a tool call; use them to block risky commands or run formatters automatically.
- Subagents: specialists defined as files in
.claude/agents/that Claude delegates to.
The full Claude Code walkthrough (install, plan mode, permissions, MCP, hooks, subagents, automation) is in the SkillNavora lesson Claude Code complete tutorial.
Common mistakes and fixes
| Mistake | Fix |
|---|---|
| A 600-line CLAUDE.md that nobody reads | Keep it under 200 lines; move details into imported files or path-scoped rules. |
| Relying on CLAUDE.md to stop dangerous commands | Use permission rules or a PreToolUse hook to enforce. |
| Committing CLAUDE.local.md with personal URLs | Add CLAUDE.local.md to .gitignore. |
| Different instructions in CLAUDE.md and AGENTS.md | Import AGENTS.md from CLAUDE.md so there is one source. |
Practice
- Run /init in a small repository and cut the draft CLAUDE.md to the 20 lines that matter.
- Add one path-scoped rule in .claude/rules/ and check that Claude follows it when editing those files.
- Copy your Lesson 5 skill into .claude/skills/ and run it with /its-name.
Quick check
Which file holds your personal instructions for all projects?
~/.claude/CLAUDE.md
How do you include another file in CLAUDE.md?
With an @path/to/file import.
Is CLAUDE.md enforced?
No, it is context. Use permission rules or hooks to enforce behaviour.
How much of auto memory loads each session?
The first 200 lines or 25 KB.