home / skills / petekp / claude-code-setup / claude-md-author

claude-md-author skill

/skills/claude-md-author

This skill helps you create a concise CLAUDE.md with WHAT-WHY-HOW context to guide Claude across projects.

npx playbooks add skill petekp/claude-code-setup --skill claude-md-author

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
5.0 KB
---
name: claude-md-author
description: This skill should be used when the user asks to "create a CLAUDE.md", "write a CLAUDE.md", "set up CLAUDE.md", "configure Claude for this project", "add project instructions for Claude", "initialize Claude context", or mentions needing project-specific Claude instructions.
---

# CLAUDE.md Authoring Guide

This skill guides the creation of effective CLAUDE.md files that provide Claude with essential project context.

## Core Principle

LLMs are stateless—they have no memory between sessions. The only thing Claude knows about a codebase is the tokens provided to it. CLAUDE.md enters every conversation, making it the primary tool for context management.

## The WHAT-WHY-HOW Framework

Structure CLAUDE.md content around three categories:

| Category | Purpose | Examples |
|----------|---------|----------|
| **WHAT** | Technology stack, project structure, codebase organization | "This is a Next.js app using TypeScript and Prisma" |
| **WHY** | Project purpose, component functions | "The auth module handles OAuth2 flow for enterprise SSO" |
| **HOW** | Commands, testing procedures, verification methods | "Run `npm test` before commits; lint with `npm run lint`" |

## Critical Constraints

### Instruction Budget

Frontier LLMs reliably follow approximately 150-200 instructions. Claude Code's system prompt already contains ~50 instructions, leaving limited budget for CLAUDE.md. Smaller models degrade exponentially as instructions increase.

### Size Guidelines

- Target under 300 lines
- Aim for under 60 lines if possible (HumanLayer's CLAUDE.md achieves this)
- Every line should provide universal value across all sessions

## What to Include

**Essential elements:**
- Build and test commands (the HOW)
- Project structure overview (the WHAT)
- Key architectural decisions (the WHY)
- Patterns and conventions specific to this codebase
- File references using `file:line` format (not code snippets)

**Example build/test section:**
```markdown
## Commands
- Build: `npm run build`
- Test: `npm test`
- Lint: `npm run lint`
- Type check: `npx tsc --noEmit`
```

## What to Avoid

### Never Use as a Linter

"Never send an LLM to do a linter's job." Code style guidelines waste tokens and degrade performance. Use deterministic tools (ESLint, Prettier, Biome) instead. Configure hooks to run formatters automatically.

### Avoid Auto-Generation

CLAUDE.md is one of the highest leverage points for Claude's effectiveness. Manually craft it rather than using `/init` commands. Auto-generated content tends to be verbose and generic.

### Skip Universally Irrelevant Content

Claude may ignore CLAUDE.md entirely if content seems task-irrelevant. The system explicitly reminds Claude that "this context may or may not be relevant to your tasks."

### No Duplicate Information

Avoid copying code snippets—they become outdated quickly. Use `file:line` pointers instead.

## Progressive Disclosure Strategy

Store task-specific guidance in separate files rather than bloating CLAUDE.md:

```
.claude/
├── CLAUDE.md              # Core context (universal)
├── docs/
│   ├── testing.md         # Testing procedures
│   ├── deployment.md      # Deployment guide
│   └── architecture.md    # Architecture decisions
└── plans/                 # Implementation plans
```

Reference these in CLAUDE.md:
```markdown
## Documentation
- Testing procedures: `.claude/docs/testing.md`
- Deployment guide: `.claude/docs/deployment.md`
```

## Alternative Mechanisms

Consider using Claude Code's other features instead of cramming everything into CLAUDE.md:

| Need | Better Approach |
|------|-----------------|
| Code formatting | Hooks that run formatters |
| Task-specific instructions | Slash commands linking to guides |
| Recent changes context | Commands referencing version control |
| One-time procedures | Separate markdown files |

## Creation Workflow

To create an effective CLAUDE.md:

1. **Audit the codebase**: Identify build commands, test procedures, key patterns
2. **Draft minimal content**: Start with WHAT-WHY-HOW essentials only
3. **Remove task-specific content**: Move specialized instructions to `.claude/docs/`
4. **Use pointers**: Replace code snippets with `file:line` references
5. **Test for universality**: Ask "Will this help in every Claude session?"

## Template

```markdown
# Project Name

Brief one-line description of what this project does.

## Stack
- [Primary language/framework]
- [Database/storage]
- [Key dependencies]

## Commands
- Build: `command`
- Test: `command`
- Lint: `command`

## Structure
- `src/` - Application code
- `tests/` - Test files
- [Other key directories]

## Key Patterns
- [Pattern 1 with file:line reference]
- [Pattern 2 with file:line reference]

## Notes
- [Important architectural decision]
- [Gotcha or non-obvious behavior]
```

## Additional Resources

For detailed examples and anti-patterns, consult:
- **`references/examples.md`** - Real CLAUDE.md examples
- **`references/anti-patterns.md`** - Common mistakes to avoid

Overview

This skill creates an effective CLAUDE.md that gives Claude the minimal, high-value project context it should load into every session. It focuses on WHAT (stack and structure), WHY (purpose and key decisions) and HOW (build/test/verify commands) to keep prompts compact and useful. Use this to initialize or refine project-specific Claude instructions so responses are accurate and actionable.

How this skill works

It inspects the repository for build/test commands, key folders, architectural decisions, and common patterns, then drafts a concise CLAUDE.md following the WHAT-WHY-HOW framework. It replaces code excerpts with file:line references, limits lines to a strict budget, and points to separate docs for task-specific procedures. The result is a focused, universal context file that Claude will include in every conversation.

When to use it

  • Initializing Claude context for a new repo
  • Adding or updating project context so Claude understands architecture
  • Preparing a codebase for consistent automated code review or generation
  • Refining instructions after major refactors or dependency changes
  • Reducing noise when Claude is producing irrelevant or verbose output

Best practices

  • Keep CLAUDE.md minimal: prioritize build/test commands, structure, and key decisions
  • Follow WHAT-WHY-HOW and avoid task-specific step-by-step details in the core file
  • Use file:line references instead of code snippets to avoid staleness
  • Move one-off or detailed procedures into .claude/docs/ and reference them
  • Aim for under 300 lines and prefer under ~60 lines to conserve instruction budget

Example use cases

  • Create CLAUDE.md for a TypeScript Next.js app with Prisma and CI commands
  • Update CLAUDE.md after introducing a new auth module and SSO flow
  • Add a short commands section so Claude can run correct build/test steps
  • Refactor an oversized CLAUDE.md by moving testing/deployment details to .claude/docs/
  • Provide Claude quick pointers to architecture decisions using file:line references

FAQ

How long should CLAUDE.md be?

Target under 300 lines, ideally below ~60 lines; every line should provide universal value.

Should I include code snippets?

No. Use file:line references instead to avoid outdated snippets and save tokens.