โ† Back to list
yebot

memory-hierarchy

by yebot

Claude Code plugin marketplace - Supercharge your AI-assisted development workflow ๐Ÿง 

โญ 3๐Ÿด 0๐Ÿ“… Dec 29, 2025

SKILL.md


Claude Code Memory Hierarchy

Complete reference for Claude Code's memory management system.

Memory Locations (Highest to Lowest Priority)

Memory TypeLocationPurposeShared With
Enterprise policymacOS: /Library/Application Support/ClaudeCode/CLAUDE.mdLinux: /etc/claude-code/CLAUDE.mdWindows: C:\Program Files\ClaudeCode\CLAUDE.mdOrganization-wide standards (IT/DevOps managed)All org users
Project memory./CLAUDE.md or ./.claude/CLAUDE.mdTeam-shared project instructionsTeam via git
Project rules./.claude/rules/*.mdModular, topic-specific instructionsTeam via git
User memory~/.claude/CLAUDE.mdPersonal preferences for all projectsJust you
User rules~/.claude/rules/*.mdPersonal modular rulesJust you
Project local./CLAUDE.local.mdPersonal project-specific preferencesJust you (gitignored)

Key: Files higher in hierarchy load first; more specific memories take precedence.

Memory Discovery

Claude Code discovers memory files by:

  1. Upward recursion: From cwd up to (not including) root /
  2. Subtree discovery: Nested CLAUDE.md loaded when reading files in those subtrees
  3. Automatic loading: All .claude/rules/*.md files loaded with same priority as .claude/CLAUDE.md

View loaded memories: Run /memory command

Import Syntax

CLAUDE.md files can import other files using @path/to/file:

# Project Instructions

See @README.md for project overview.
See @docs/architecture.md for system design.
API reference: @docs/api/README.md

# Personal preferences (not in git)
@~/.claude/my-project-prefs.md

Features:

  • Relative and absolute paths supported
  • Home directory imports (@~/...) for personal preferences
  • Not evaluated inside code blocks or code spans
  • Recursive imports (max 5 hops)

Modular Rules (.claude/rules/)

Basic Structure

project/
โ”œโ”€โ”€ .claude/
โ”‚   โ”œโ”€โ”€ CLAUDE.md           # Main project instructions
โ”‚   โ””โ”€โ”€ rules/
โ”‚       โ”œโ”€โ”€ code-style.md   # Code style guidelines
โ”‚       โ”œโ”€โ”€ testing.md      # Testing conventions
โ”‚       โ”œโ”€โ”€ security.md     # Security requirements
โ”‚       โ””โ”€โ”€ api/
โ”‚           โ””โ”€โ”€ validation.md  # API-specific rules

Path-Specific Rules

Use YAML frontmatter to scope rules to specific files:

---
paths: src/api/**/*.ts
---

# API Development Rules

- All endpoints must include input validation
- Use the standard error response format

Glob Patterns

PatternMatches
**/*.tsAll TypeScript files
src/**/*All files under src/
*.mdMarkdown files in root
src/**/*.{ts,tsx}TS and TSX in src/
{src,lib}/**/*.tsTS in src/ or lib/
tests/**/*.test.tsTest files

Multiple patterns:

---
paths: {src,lib}/**/*.ts, tests/**/*.test.ts
---

Subdirectory Organization

.claude/rules/
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ react.md
โ”‚   โ””โ”€โ”€ styles.md
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ api.md
โ”‚   โ””โ”€โ”€ database.md
โ””โ”€โ”€ general.md

All .md files discovered recursively.

Share rules across projects:

ln -s ~/shared-claude-rules .claude/rules/shared
ln -s ~/company-standards/security.md .claude/rules/security.md

User-Level Configuration

User Memory (~/.claude/CLAUDE.md)

Personal preferences applying to ALL projects:

  • Code style preferences
  • Tooling shortcuts
  • Workflow habits

User Rules (~/.claude/rules/)

~/.claude/rules/
โ”œโ”€โ”€ preferences.md    # Personal coding preferences
โ””โ”€โ”€ workflows.md      # Preferred workflows

User rules load before project rules; project rules take higher priority.

Quick Memory Addition

# Shortcut

Start input with #:

# Always use descriptive variable names

Prompts for which memory file to store in.

/memory Command

Opens memory file in system editor for extensive additions.

/init Command

Bootstrap a CLAUDE.md for your codebase.

When to Use Each Memory Type

ScenarioRecommended Location
Team coding standards./CLAUDE.md
Build/test/lint commands./CLAUDE.md
Topic-specific rules (testing, API, security)./.claude/rules/{topic}.md
File-type-specific patterns./.claude/rules/ with paths:
Personal code style~/.claude/CLAUDE.md
Your local dev URLs/setup./CLAUDE.local.md
Org-wide complianceEnterprise policy (IT managed)

Decision Tree: Choosing Memory Structure

Project Analysis
โ”‚
โ”œโ”€ Small project (<500 files, <50 dirs)?
โ”‚   โ””โ”€ Single ./CLAUDE.md
โ”‚       โ””โ”€ Use @imports for large documentation
โ”‚
โ”œโ”€ Medium project with topic diversity?
โ”‚   โ””โ”€ ./CLAUDE.md + .claude/rules/
โ”‚       โ”œโ”€ testing.md
โ”‚       โ”œโ”€ code-style.md
โ”‚       โ””โ”€ {topic}.md
โ”‚
โ”œโ”€ Monorepo / microservices?
โ”‚   โ””โ”€ Multiple ./CLAUDE.md (one per package/service)
โ”‚       โ””โ”€ Each can have own .claude/rules/
โ”‚
โ”œโ”€ File-type-specific patterns?
โ”‚   โ””โ”€ Path-specific rules with paths: frontmatter
โ”‚
โ””โ”€ Personal dev setup needed?
    โ””โ”€ ./CLAUDE.local.md (gitignored automatically)

Best Practices

Content Guidelines

  • Be specific: "Use 2-space indentation" > "Format code properly"
  • Use structure: Bullet points under descriptive headings
  • Review periodically: Update as project evolves

Rules Organization

  • Keep rules focused: Each file covers one topic
  • Use descriptive filenames: testing.md, api-design.md, security.md
  • Use paths: sparingly: Only when rules truly apply to specific file types
  • Organize with subdirectories: Group related rules

Project vs Personal

  • Project memory: What the team needs to know
  • User memory: Your personal preferences
  • Local memory: Your dev environment specifics

File Priority Summary

When the same topic is covered in multiple files:

  1. Enterprise policy (highest)
  2. Project .claude/rules/ (path-specific first)
  3. Project CLAUDE.md
  4. User ~/.claude/rules/
  5. User ~/.claude/CLAUDE.md
  6. Project CLAUDE.local.md (lowest, but most specific to you)

Common Patterns

Imports for Documentation

# Project Overview

See @README.md for getting started.
Architecture details: @docs/architecture.md
API reference: @docs/api/README.md

Topic-Specific Rules

.claude/rules/
โ”œโ”€โ”€ testing.md          # Test patterns, mocking, coverage
โ”œโ”€โ”€ api-design.md       # REST conventions, error handling
โ”œโ”€โ”€ database.md         # Query patterns, migrations
โ””โ”€โ”€ security.md         # Auth, validation, secrets

Path-Specific API Rules

---
paths: src/api/**/*.ts, src/routes/**/*.ts
---

# API Endpoint Rules

- Validate all inputs with zod
- Use consistent error response format
- Include OpenAPI documentation comments

Personal Local Setup

./CLAUDE.local.md:

# My Local Setup

## Dev URLs
- API: http://localhost:3001
- Frontend: http://localhost:3000
- Database: postgresql://localhost:5432/mydb

## Debug Commands
```bash
DEBUG=api:* npm run dev

Score

Total Score

50/100

Based on repository quality metrics

โœ“SKILL.md

SKILL.mdใƒ•ใ‚กใ‚คใƒซใŒๅซใพใ‚Œใฆใ„ใ‚‹

+20
โ—‹LICENSE

ใƒฉใ‚คใ‚ปใƒณใ‚นใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

0/10
โ—‹่ชฌๆ˜Žๆ–‡

100ๆ–‡ๅญ—ไปฅไธŠใฎ่ชฌๆ˜ŽใŒใ‚ใ‚‹

0/10
โ—‹ไบบๆฐ—

GitHub Stars 100ไปฅไธŠ

0/15
โ—‹ๆœ€่ฟ‘ใฎๆดปๅ‹•

3ใƒถๆœˆไปฅๅ†…ใซๆ›ดๆ–ฐใŒใ‚ใ‚‹

0/10
โ—‹ใƒ•ใ‚ฉใƒผใ‚ฏ

10ๅ›žไปฅไธŠใƒ•ใ‚ฉใƒผใ‚ฏใ•ใ‚Œใฆใ„ใ‚‹

0/5
โœ“Issue็ฎก็†

ใ‚ชใƒผใƒ—ใƒณIssueใŒ50ๆœชๆบ€

+5
โœ“่จ€่ชž

ใƒ—ใƒญใ‚ฐใƒฉใƒŸใƒณใ‚ฐ่จ€่ชžใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+5
โ—‹ใ‚ฟใ‚ฐ

1ใคไปฅไธŠใฎใ‚ฟใ‚ฐใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

0/5

Reviews

๐Ÿ’ฌ

Reviews coming soon