skills/managing-claude-memory/SKILL.md
Expert guidance for creating, updating, and maintaining CLAUDE.md memory files following best practices for hierarchical memory, structure, content organization, and team collaboration
npx skillsauth add agdev/claude-code managing-claude-memoryInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
CLAUDE.md files are persistent memory documents that help Claude understand codebases, preferences, and working patterns across sessions. They serve as a bridge between sessions, maintaining context and enforcing guidelines.
Claude searches for CLAUDE.md files in a hierarchical memory system with four levels (highest to lowest priority):
Enterprise Policy (/etc/claude-code/CLAUDE.md on Linux, /Library/Application Support/ClaudeCode/CLAUDE.md on macOS)
Project Memory (./CLAUDE.md or ./.claude/CLAUDE.md)
User Memory (~/.claude/CLAUDE.md)
Project Memory (Local) (./CLAUDE.local.md)
CLAUDE.md supports importing other files using @path/to/import syntax:
## Architecture
@./docs/architecture-guide.md
## Testing Standards
@./specs/testing-requirements.md
Features:
# [Project Name]
[One-sentence description]
## Quick Reference (Optional: for files >150 lines)
## Commands
## Project Structure
## Code Style
## Architecture Patterns
## Critical Rules
## Environment Variables
## Common Pitfalls
## Testing
## Additional Resources
#, ##, ###) to organize informationModel Preferences
Project Structure Rules
Code & Architecture Standards
Commands with Context
Environment Variables
Common Pitfalls
Testing Conventions
Important Restrictions
Documentation References
Sensitive Data - NEVER include API keys, passwords, tokens, secrets
Large Code Blocks - Keep concise
Frequently Changing Information
Tool Configurations
.claude/settings.json insteadVerbose Paragraphs
Obvious Explanations
Rule: Keep CLAUDE.md files concise. Every line consumes tokens on every request.
❌ Too verbose:
This project uses TypeScript with strict mode enabled, which means that
all code must be properly typed and we don't allow the use of the 'any'
type anywhere in the codebase because it defeats the purpose.
✅ Concise:
- **TypeScript strict mode** - No implicit any, strict null checks
- **No any types** - Use `unknown` if type is truly unknown
Rule: Use emphasis markers (IMPORTANT, ALWAYS, NEVER, MUST) for critical rules.
Example:
## Critical Rules
- **IMPORTANT:** All imports MUST include `.js` extension (ES modules)
- **NEVER delete users** - Use `active: false` for soft delete
- **ALWAYS validate requests** with Zod schemas before controllers
Rule: Document mistakes with ❌ (wrong) and ✅ (correct) code examples.
Example:
### Import Extensions
❌ `import { User } from './models/user'`
✅ `import { User } from './models/user.js'`
### Error Handling
❌ `throw 'User not found'`
✅ `throw new NotFoundError('User not found')`
Rule: Group commands by purpose with comments explaining when to use.
Example:
### Development
```bash
npm run dev # Start server with hot reload on port 4000
npm run typecheck # Type check without emit (run before commits)
npm run lint:fix # Auto-fix linting issues
### 5. Hierarchical Structure for Monorepos
**Rule:** Root CLAUDE.md provides overview, subdirectory files provide specifics.
**Example:**
```markdown
## Monorepo Structure
**Directory-specific guidance:**
- See `client/CLAUDE.md` for React/Vite patterns
- See `server/CLAUDE.md` for Express/Node patterns
- See `shared/CLAUDE.md` for shared library development
Rule: For complex projects (>150 lines), start with Quick Reference.
Example:
## Quick Reference
**Full Documentation:**
- **API Reference:** `README.md` (1,663 lines)
- **Migration Guide:** `docs/MIGRATION.md` (1,051 lines)
**Package:** `@app-master/[email protected]`
**Test Coverage:** 96.73% (329 passing tests)
Rule: Use @path/to/file syntax to help Claude discover related docs.
Example:
## Common Workflows
- **Modify AI Behavior**: @server/systemInstructions/CLAUDE.md
- **Add New Tags**: @docs/tag-system.md
- **Database Schema**: @docs/database.md
User-level (~/.claude/CLAUDE.md):
Project-level (./CLAUDE.md):
Rule: Never duplicate content. Keep project-specific rules at project level only.
Use when: Small projects, prototypes, POCs, simple utilities
# [Project Name]
[One-sentence description]
## Tech Stack
- [Framework/Language with version]
- [Key dependencies]
## Commands
### Development
```bash
[start command] # [Description]
[test command] # [Description]
[directory tree with brief descriptions]
### Template 2: Standard (100-200 lines)
**Use when:** Most full-featured applications, team projects
```markdown
# [Project Name]
[2-3 sentence description including purpose and key features]
## Tech Stack
- [Framework versions]
- [Key dependencies]
## Commands
### Development
```bash
[commands with inline comments]
[test commands]
[build/deploy commands]
[directory tree with purpose explanations]
Key Files:
[file] - [Purpose][file] - [Purpose][Brief explanation with code example]
[Brief explanation]
[VAR] - [Description][VAR] - [Description with default]❌ [Wrong way with code] ✅ [Right way with code]
### Template 3: Monorepo Root
**Use when:** Multiple related projects in one repository
```markdown
# [Monorepo Name]
[Description of overall system]
## Monorepo Structure
project-root/ ├── [package1]/ - [Description] (see [package1]/CLAUDE.md) ├── [package2]/ - [Description] (see [package2]/CLAUDE.md) └── [shared]/ - [Description] (see [shared]/CLAUDE.md)
**Directory-specific guidance:**
- See `[package1]/CLAUDE.md` for [topic]
- See `[package2]/CLAUDE.md` for [topic]
## Development
### Terminal Setup
```bash
# Terminal 1: [Service]
[command]
# Terminal 2: [Service]
[command]
# Test [package1]
[command]
# Test [package2]
[command]
❌ [Wrong approach] ✅ [Right approach]
### Template 4: Shared Library
**Use when:** Reusable packages/libraries consumed by multiple projects
```markdown
# [Library Name]
[One-line description of library purpose]
## Quick Reference
**Full Documentation:**
- **API Reference:** `README.md` - [Brief description]
**Package:** `[package-name]@[version]`
**Test Coverage:** [percentage]
## Installation
### Build the Library
```bash
[build commands]
{
"dependencies": {
"[package-name]": "[path or version]"
}
}
[Code example with explanation]
src/
├── [module]/ - [Purpose]
[Example]
[Example]
❌ WRONG: [Code example] ✅ CORRECT: [Code example]
### Template 5: User-Level
**Use when:** Personal preferences across all projects
```markdown
# Personal Claude Code Preferences
## Model Usage
### Planning Mode
[Preferred model]
### Execution Mode
[Preferred model]
## Project Structure Conventions
- [Universal folder patterns]
- [Backup file locations]
## Code Style
- [Naming preferences]
- [Comment style]
- [Import organization]
## Documentation Guidelines
### When to Create Documentation
- **NEVER** create documentation files unless explicitly requested
- Only create when user specifically asks
### Documentation Structure
- [Folder organization if you create docs]
## Design Principles
- [Your coding philosophy]
- [Simplicity vs complexity preferences]
## Git Conventions
- [Commit message style]
- [Never commit without explicit instruction]
Use when: Educational repositories, course materials, learning resources
# [Course/Tutorial Name]
[Description of learning objectives]
## Repository Structure
### Core Directories
- `[dir]/` - [Purpose and what learners do]
- `[subdir]/` - [Purpose]
### Key File Patterns
- `[filename]` - [What it demonstrates]
## Development Setup
### Environment Setup
```bash
[Setup commands with explanations]
[How to run required services]
[command] # [Explanation]
Key packages:
[package] - [Purpose]This repository works with:
## Good Examples
### Example 1: Monorepo Root Overview
```markdown
# App Master - Internal user and application management system
Monorepo with React frontend and Express backend.
## Monorepo Structure
project-root/ ├── client/ - React 19 + Vite + TypeScript (port 3000) ├── server/ - Express + TypeScript + MongoDB (port 4000) └── docs/ - PRD and documentation
**Directory-specific guidance:**
- See `client/CLAUDE.md` for React/Vite patterns
- See `server/CLAUDE.md` for Express/Node patterns
## Critical Business Rules
- **NEVER delete users/applications** - Set `active: false` for soft delete
- **NEVER commit .env files** - Use .env.sample templates
- **ALWAYS validate inputs** - Both frontend and backend
Why this is good:
## Code Style
### Import/Export
- **ES modules only** - All imports require `.js` extension
- **Path aliases** - Use `@/` for `src/`
- **No default exports** - Use named exports
### Error Handling
- **Use AppError classes** - NotFoundError, ValidationError, etc.
- **Wrap async routes** - Use `asyncHandler()`
- **Never throw strings** - Always throw Error instances
## Common Pitfalls
### Import Extensions
❌ `import { User } from './models/user'`
✅ `import { User } from './models/user.js'`
### Async Routes
❌ `router.get('/users', async (req, res) => { ... })`
✅ `router.get('/users', asyncHandler(async (req, res) => { ... }))`
## Quick Reference
**Full Documentation:**
- **API Reference:** `README.md` (1,663 lines)
- **Migration Guide:** `docs/MIGRATION.md` (1,051 lines)
**Package:** `@app-master/[email protected]`
**Test Coverage:** 96.73% (329 passing tests)
## Common Usage Patterns
### Subpath Imports (Recommended for Tree-Shaking)
**IMPORTANT:** Use subpath imports to minimize bundle size
```typescript
// Types
import { User, UserRole } from '@app-master/auth/types';
// Validation schemas
import { loginSchema } from '@app-master/auth/schemas';
❌ WRONG (imports everything):
import { User, loginSchema } from '@app-master/auth';
✅ CORRECT (granular imports):
import { User } from '@app-master/auth/types';
import { loginSchema } from '@app-master/auth/schemas';
## Anti-Patterns to Avoid
### Anti-Pattern 1: Duplicating User-Level File
**Problem:**
```markdown
# Project CLAUDE.md that duplicates user-level content
# Model usage
## Planning mode
Opus when available
## Execution mode
Sonnet
[... exact copy of user-level CLAUDE.md ...]
Why this is bad:
Correct approach:
# Project Name
[Only project-specific content here]
# User-level CLAUDE.md already provides model selection
Problem:
## Project Structure [in ~/.claude/CLAUDE.md]
- Place all test files in 'test-ground' folder at root
Why this is bad:
Correct approach:
Problem:
- Follow project-specific CLAUDE.md in backend/ subdirectory
Why this is bad:
Correct approach:
- **Backend:** @backend/CLAUDE.md - FastAPI patterns, Burr workflows
Problem:
- `src/api/client.ts` - Axios instance (to be created)
Why this is bad:
Correct approach:
**Planned (Not Yet Implemented):**
- `src/api/client.ts` - Axios instance with httpOnly cookies
Problem:
Correct approach:
Before committing CLAUDE.md, verify:
Structure & Organization:
Content Quality:
Technical Accuracy:
Token Efficiency:
Security:
Completeness:
Hierarchy:
# key during conversation/init command for auto-generation/memory commanddevelopment
Expert guidance for writing clean, simple, and effective unit, integration, component, microservice, and API tests. Use this skill when reviewing existing tests for violations, writing new tests, or refactoring tests. NOT for end-to-end tests that span multiple processes - use testing-e2e skill instead. Covers AAA pattern, data factories, mocking strategies, DOM testing, database testing, and assertion best practices.
tools
Expert guidance for writing resilient end-to-end tests that span multiple processes and components. Use this skill when reviewing, writing, or refactoring system-wide e2e tests. Covers user-facing scenarios, helper functions, data factories, ARIA-based selectors, and auto-retriable assertions. NOT for unit/integration tests - use testing-unit-integration skill instead. See references/playwright-resilience.md for detailed selector patterns.
tools
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
tools
Expert guidance for creating effective Claude Code agents (subagents). Use when users want to create a new agent, update an existing agent, or learn agent design best practices. Covers agent architecture, prompt engineering, tool selection, model choice, and common pitfalls. Integrates with skill-creator when agent needs accompanying skills.