memory-management

Guide for managing Claude Code memory effectively. Use when setting up project memory, optimizing CLAUDE.md files, configuring rules directories, or establishing cross-session knowledge patterns. Covers memory hierarchy, best practices, and context optimization.

16 stars

Best use case

memory-management is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Guide for managing Claude Code memory effectively. Use when setting up project memory, optimizing CLAUDE.md files, configuring rules directories, or establishing cross-session knowledge patterns. Covers memory hierarchy, best practices, and context optimization.

Teams using memory-management should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/memory-management/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/memory-management/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/memory-management/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How memory-management Compares

Feature / Agentmemory-managementStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Guide for managing Claude Code memory effectively. Use when setting up project memory, optimizing CLAUDE.md files, configuring rules directories, or establishing cross-session knowledge patterns. Covers memory hierarchy, best practices, and context optimization.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Memory Management

Master Claude Code's memory system for persistent context across sessions, projects, and teams.

## Quick Reference

| Memory Type | Location | Scope | Priority | Use For |
|-------------|----------|-------|----------|---------|
| Global | `~/.claude/CLAUDE.md` | All projects | Lowest | Personal preferences, global conventions |
| Project Root | `./CLAUDE.md` | Project-wide | Medium | Project context, tech stack, conventions |
| Project Config | `./.claude/CLAUDE.md` | Project-wide | Medium | Same as root (alternative location) |
| Rules | `./.claude/rules/*.md` | Conditional | Highest | Modular, file-specific instructions |

## Memory Hierarchy

Claude Code reads memory files in this order (later overrides earlier):

```
~/.claude/CLAUDE.md           # Your global preferences
  |
  v
./CLAUDE.md                   # Project root instructions
  |
  v
./.claude/CLAUDE.md           # Project config directory
  |
  v
./.claude/rules/*.md          # Conditional rules (when matched)
```

### Priority Rules

1. **Rules always win** - When a rule file matches, its instructions take precedence
2. **Project overrides global** - Project CLAUDE.md supersedes global settings
3. **Later loads override earlier** - Last-loaded content has highest priority
4. **Explicit beats implicit** - Specific rules override general guidelines

## When to Use Each Memory Type

### Use Global Memory (`~/.claude/CLAUDE.md`) For

- Personal coding preferences (tabs vs spaces, quote style)
- Universal tool preferences (Bun over npm, rg over find)
- Cross-project conventions you always follow
- Personal workflow shortcuts

**Example:**
```markdown
# Global Preferences

## Code Style
- Use single quotes for strings
- Prefer for-loops over forEach
- Use Bun instead of npm

## Tools
- Use ripgrep (rg) for searching, not grep
- Prefer Edit over Write for modifications
```

### Use Project Memory (`./CLAUDE.md` or `./.claude/CLAUDE.md`) For

- Project-specific tech stack (React, Bun, Drizzle, etc.)
- Build and test commands
- Architecture overview
- Team conventions
- File structure explanations

**Example:**
```markdown
# Project: E-Commerce API

## Tech Stack
- Runtime: Bun
- Framework: Hono
- Database: PostgreSQL with Drizzle ORM
- Testing: Bun test

## Commands
- `bun dev` - Start development server
- `bun test` - Run all tests
- `bun db:migrate` - Run database migrations

## Architecture
- `/src/routes` - API route handlers
- `/src/services` - Business logic
- `/src/db` - Database schema and queries
```

### Use Rules (`./.claude/rules/*.md`) For

- File-type-specific instructions (TypeScript, React, SQL)
- Conditional guidance based on file paths
- Modular memory that loads only when relevant
- Team standards that apply to specific areas

**Example:**
```
.claude/rules/
  react-components.md     # Globs: src/components/**/*.tsx
  api-routes.md           # Globs: src/routes/**/*.ts
  database.md             # Globs: src/db/**/*.ts, *.sql
  tests.md                # Globs: **/*.test.ts, **/*.spec.ts
```

## CLAUDE.md Structure

A well-structured CLAUDE.md file includes:

```markdown
# Project Name

Brief description (1-2 sentences).

## Commands
- `bun install` - Install dependencies
- `bun dev` - Start development
- `bun test` - Run tests
- `bun build` - Build for production

## Tech Stack
- Runtime/Framework
- Database
- Key libraries

## Architecture
Brief overview of project structure.

## Code Style
Project-specific conventions.

## Important Notes
Critical information Claude should always know.
```

For detailed CLAUDE.md guidance, see [CLAUDE-MD.md](./CLAUDE-MD.md).

## Rules Directory

The `.claude/rules/` directory contains modular memory files that load conditionally.

### Rule File Anatomy

```yaml
---
globs: ["src/components/**/*.tsx", "src/ui/**/*.tsx"]
description: React component conventions for this project
alwaysApply: false
---

# React Components

Follow these patterns for React components...
```

### Glob Matching

- **Exact match**: `src/utils.ts`
- **Directory**: `src/components/**/*`
- **Extension**: `**/*.tsx`
- **Multiple**: `["*.ts", "*.tsx"]`

For complete rules documentation, see [RULES.md](./RULES.md).

## Best Practices

### Do Include

- Commands with exact syntax
- Tech stack overview
- Key architectural decisions
- Non-obvious conventions
- Error-prone areas

### Do NOT Include

- Code that's easily discoverable (read the files instead)
- Verbose documentation (link instead)
- Information that changes frequently
- Full API documentation

### Keep Memory Focused

```markdown
## Good - Actionable and Specific

- Use Drizzle ORM for database queries
- Run `bun test` before committing
- Components go in `src/components/{feature}/`

## Avoid - Vague or Obvious

- Write clean code
- Test your changes
- Follow best practices
```

### Reference, Don't Duplicate

```markdown
## Good - Reference External Docs

See API documentation at `docs/api.md`.
Architecture diagrams in `docs/architecture/`.

## Avoid - Duplicating Content

[Pasting entire API documentation here]
```

## Memory Strategies

### Project Onboarding

When starting with a new project:

1. **Create minimal CLAUDE.md** with commands and tech stack
2. **Add rules** for the main file types you work with
3. **Expand gradually** as you discover project quirks
4. **Update regularly** when conventions change

### Team Conventions

For team projects:

1. **Commit CLAUDE.md** and `.claude/rules/` to version control
2. **Keep personal preferences** in `~/.claude/CLAUDE.md`
3. **Document decisions** in rules files, not code comments
4. **Review memory files** during onboarding

### Cross-Session Continuity

To maintain context across sessions:

1. **Session hooks** can inject recent context at start
2. **Weave framework** captures learnings for future sessions
3. **Project memory** persists architectural decisions
4. **Rules files** encode learned patterns

For advanced memory strategies, see [STRATEGIES.md](./STRATEGIES.md).

## Common Patterns

### Monorepo Pattern

```
project/
  CLAUDE.md                    # Shared conventions
  .claude/
    rules/
      frontend.md              # Globs: apps/web/**/*
      backend.md               # Globs: apps/api/**/*
      packages.md              # Globs: packages/**/*
  apps/
    web/
      CLAUDE.md                # Web-specific context
    api/
      CLAUDE.md                # API-specific context
```

### Feature Flag Pattern

```markdown
# .claude/rules/feature-flags.md
---
globs: ["src/**/*.ts", "src/**/*.tsx"]
---

## Feature Flags

Active flags:
- `ENABLE_NEW_CHECKOUT` - New checkout flow (enabled in staging)
- `DARK_MODE` - Dark mode support (enabled everywhere)

Check flags with: `useFeatureFlag('FLAG_NAME')`
```

### Migration Pattern

```markdown
# .claude/rules/migrations.md
---
globs: ["src/db/migrations/**/*.ts"]
---

## Database Migrations

1. Generate: `bun db:generate`
2. Run: `bun db:migrate`
3. Rollback: `bun db:rollback`

Naming: `NNNN_description.ts`
Always include down migration.
```

## Reference Files

| File | Contents |
|------|----------|
| [CLAUDE-MD.md](./CLAUDE-MD.md) | Deep dive on CLAUDE.md structure and content |
| [RULES.md](./RULES.md) | Complete rules directory documentation |
| [STRATEGIES.md](./STRATEGIES.md) | Advanced memory strategies |

## Validation Checklist

Before finalizing memory setup:

- [ ] Global preferences in `~/.claude/CLAUDE.md`
- [ ] Project context in `./CLAUDE.md` or `./.claude/CLAUDE.md`
- [ ] Modular rules for file-specific guidance
- [ ] Commands section with exact syntax
- [ ] Tech stack clearly documented
- [ ] No duplicated documentation
- [ ] Rules have appropriate glob patterns
- [ ] Memory files committed to version control

## Common Mistakes

| Mistake | Fix |
|---------|-----|
| Putting everything in global | Use project memory for project-specific content |
| Giant CLAUDE.md files | Split into rules files for modular loading |
| Duplicating docs | Reference external documentation instead |
| Vague instructions | Be specific and actionable |
| Stale content | Review and update memory periodically |
| Missing commands | Always include build/test/run commands |

Related Skills

moai-foundation-memory

16
from diegosouzapw/awesome-omni-skill

Persistent memory across sessions using MCP Memory Server for user preferences, project context, and learned patterns

memorylane

16
from diegosouzapw/awesome-omni-skill

Zero-config persistent memory for Claude with automatic cost savings. Use when you need to remember project context, reduce API token costs, track learned patterns, manage memories across sessions, or curate/clean up memories. Automatically compresses context 6x and saves 84% on API costs. Keywords: memory, remember, recall, context, cost savings, reduce tokens, learn, patterns, insights, curate, clean up memories, review memories.

memory-sync

16
from diegosouzapw/awesome-omni-skill

Guided workflow for maintaining strategic redundancy between Serena memories and project documentation. Use after significant code changes, phase completions, or when new architectural patterns are discovered.

memory

16
from diegosouzapw/awesome-omni-skill

Manages memory, SSOT files, and Plans.md operations. Use when user mentions メモリ, memory, SSOT, decisions.md, patterns.md, マージ, merge, Plans.md, 移行, migrate. Do NOT load for: 実装作業, レビュー, 一時的なメモ, セッション中の作業記録.

memory-conventions

16
from diegosouzapw/awesome-omni-skill

This skill should be used when persisting context between sessions, saving project state, loading previous session context, or managing longitudinal memory beyond beads issue tracking.

memory-capture

16
from diegosouzapw/awesome-omni-skill

Capture and organize memories, decisions, and learnings to a memories.md file. Use when you want to save context for future sessions.

memory-bank

16
from diegosouzapw/awesome-omni-skill

Persistent project documentation system that maintains context across sessions. Creates structured Memory Bank files to preserve project knowledge, decisions, and progress.

Library Management

16
from diegosouzapw/awesome-omni-skill

User library, favorites, and reading progress

heir-sync-management

16
from diegosouzapw/awesome-omni-skill

Master-Heir synchronization, contamination prevention, and promotion workflows

file-management-rules

16
from diegosouzapw/awesome-omni-skill

Specifies file management guidelines, including including full file paths as comments, updating project structure in AI.MD, and maintaining package.json. This rule ensures organized and well-documente

database-management

16
from diegosouzapw/awesome-omni-skill

Database schema design, migrations, query optimization, and ORM best practices. Use for database setup, performance tuning, and data modeling.

context-memory

16
from diegosouzapw/awesome-omni-skill

Advanced context and memory management system for AI agents. Provides persistent memory across sessions through daily logs (memory/YYYY-MM-DD.md), long-term curated memory (MEMORY.md), conversation archives with semantic search, and automatic behavioral learning from user satisfaction tracking. Use when you need to: (1) Remember information across sessions, (2) Archive conversations before context loss, (3) Search past discussions, (4) Track and learn from user satisfaction patterns, (5) Maintain session continuity, (6) Implement proactive memory maintenance. Includes conversation-archiver.py and satisfaction-tracker.py scripts, session startup routines, and periodic reflection workflows.