<aside> ℹ️
Difficulty: Advanced • Time: 45 minutes • Tools: Claude Code
</aside>
Every new session with an AI assistant starts from zero. It doesn't remember your coding conventions, your architectural decisions, or that you spent three sessions last week establishing a pattern it's about to contradict. You explain the same things, correct the same mistakes, and watch it cheerfully ignore context that should be obvious by now.
This is the single biggest friction point in AI-assisted development, and most people just live with it. They re-explain, re-correct, and chalk it up to the cost of using the tool.
It doesn't have to work that way. Claude Code has a layered system for persistent knowledge — files and directories that carry your rules, your learned patterns, and your workflows across every session. By the end of this guide, you'll have a working knowledge system that makes your AI assistant meaningfully smarter about your projects, every time you open a terminal.
Claude Code's knowledge system isn't a single file — it's four layers that build on each other, from broad rules down to specific workflows. Understanding the layers before you start building saves you from putting the wrong thing in the wrong place.
At the foundation, CLAUDE.md sets the rules — what your project cares about, how code should be written, what to always or never do. On top of that, Memory captures learned patterns: things Claude discovers about your project during sessions that should persist, like architectural decisions and naming conventions. Commands encode repeatable workflows, turning multi-step tasks into single slash commands. And Skills handle the complex workflows that need metadata and structure — commands with more scaffolding.
Each layer has a purpose. Mixing them up — shoving workflow instructions into CLAUDE.md, or encoding one-off decisions into memory — creates noise instead of signal. Here's how to build each one.
CLAUDE.md is a markdown file at the root of your project. Claude Code reads it at the start of every session, before you say a word. Anything in this file becomes part of the AI's baseline context for your project.
Create it:
touch CLAUDE.md
Then open it and start writing rules. A good CLAUDE.md is specific, testable, and short. Here's what belongs in it:
# Project Rules
## Code Style
- Use TypeScript strict mode — no `any` types
- Prefer named exports over default exports
- Error handling: use Result types, not try/catch
## Testing
- Run `npm test` before every commit
- Integration tests go in `__tests__/integration/`
- Mock external services, never hit real APIs in tests
## Architecture
- All API routes go through `/src/routes/`
- Database queries live in `/src/db/` — never inline SQL in route handlers
- Use the repository pattern for data access
Notice what's in there: specific instructions Claude can follow and you can verify. "Write clean code" is useless. "No any types" is something Claude can actually enforce.