writing-claude-md-files

Use when creating or updating CLAUDE.md files for projects or subdirectories - covers top-level vs domain-level organization, capturing architectural intent and contracts, and mandatory freshness dates

16 stars

Best use case

writing-claude-md-files is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when creating or updating CLAUDE.md files for projects or subdirectories - covers top-level vs domain-level organization, capturing architectural intent and contracts, and mandatory freshness dates

Teams using writing-claude-md-files 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/writing-claude-md-files/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/writing-claude-md-files/SKILL.md"

Manual Installation

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

How writing-claude-md-files Compares

Feature / Agentwriting-claude-md-filesStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when creating or updating CLAUDE.md files for projects or subdirectories - covers top-level vs domain-level organization, capturing architectural intent and contracts, and mandatory freshness dates

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

# Writing CLAUDE.md Files

## Core Principle

CLAUDE.md files bridge Claude's statelessness. They preserve context so humans don't re-explain architectural intent every session.

**Key distinction:**
- **Top-level**: HOW to work in this codebase (commands, conventions)
- **Subdirectory**: WHY this piece exists and what it PROMISES (contracts, intent)

## File Hierarchy

Claude automatically reads CLAUDE.md files from current directory up to root:

```
project/
├── CLAUDE.md                    # Project-wide: tech stack, commands, conventions
└── src/
    └── domains/
        ├── auth/
        │   └── CLAUDE.md        # Auth domain: purpose, contracts, invariants
        └── billing/
            └── CLAUDE.md        # Billing domain: purpose, contracts, invariants
```

**Depth guideline:** Typically one level (domain). Occasionally two (subdomain). Rarely more.

## Top-Level CLAUDE.md

Focuses on project-wide WHAT and HOW.

### What to Include

| Section | Purpose |
|---------|---------|
| Tech Stack | Framework, language, key dependencies |
| Commands | Build, test, run commands |
| Project Structure | Directory overview with purposes |
| Conventions | Naming, patterns used project-wide |
| Boundaries | What Claude can/cannot edit |

### Template

```markdown
# [Project Name]

Last verified: [DATE - use `date +%Y-%m-%d`]

## Tech Stack
- Language: TypeScript 5.x
- Framework: Next.js 14
- Database: PostgreSQL
- Testing: Vitest

## Commands
- `npm run dev` - Start dev server
- `npm run test` - Run tests
- `npm run build` - Production build

## Project Structure
- `src/domains/` - Domain modules (auth, billing, etc.)
- `src/shared/` - Cross-cutting utilities
- `src/infrastructure/` - External adapters (DB, APIs)

## Conventions
- Functional Core / Imperative Shell pattern
- Domain modules are self-contained
- See domain CLAUDE.md files for domain-specific guidance

## Boundaries
- Safe to edit: `src/`
- Never touch: `migrations/` (immutable), `*.lock` files
```

## Subdirectory CLAUDE.md (Domain-Level)

Focuses on WHY and CONTRACTS. The code shows WHAT; these files explain intent.

### What to Include

| Section | Purpose |
|---------|---------|
| Purpose | WHY this domain exists (not what it does) |
| Contracts | What this domain PROMISES to others |
| Dependencies | What it uses, what uses it, boundaries |
| Key Decisions | ADR-lite: decisions and rationale |
| Invariants | Things that must ALWAYS be true |
| Gotchas | Non-obvious traps |

### Template

```markdown
# [Domain Name]

Last verified: [DATE - use `date +%Y-%m-%d`]

## Purpose
[1-2 sentences: WHY this domain exists, what problem it solves]

## Contracts
- **Exposes**: [public interfaces - what callers can use]
- **Guarantees**: [promises this domain keeps]
- **Expects**: [what callers must provide]

## Dependencies
- **Uses**: [domains/services this depends on]
- **Used by**: [what depends on this domain]
- **Boundary**: [what should NOT be imported here]

## Key Decisions
- [Decision]: [Rationale]

## Invariants
- [Thing that must always be true]

## Key Files
- `index.ts` - Public exports
- `types.ts` - Domain types
- `service.ts` - Main service implementation

## Gotchas
- [Non-obvious thing that will bite you]
```

## Freshness Dates: MANDATORY

Every CLAUDE.md MUST include a "Last verified" date.

**CRITICAL:** Use Bash to get the actual date. Do NOT hallucinate dates.

```bash
date +%Y-%m-%d
```

**Why mandatory:** Stale CLAUDE.md files are worse than none. The date signals when contracts were last confirmed accurate.

## Heuristics: Top-Level vs Subdirectory

| Question | Top-level | Subdirectory |
|----------|-----------|--------------|
| Applies project-wide? | Yes | |
| New engineer needs on day 1? | Yes | |
| About commands/conventions? | Yes | |
| About WHY a component exists? | | Yes |
| About contracts between parts? | | Yes |
| Changes when the domain changes? | | Yes |

**Rule of thumb:**
- Top-level = "How to work here"
- Subdirectory = "Why this exists and what it promises"

## When to Create Subdirectory CLAUDE.md

Create when:
- Domain has non-obvious contracts with other parts
- Architectural decisions affect how code should evolve
- Invariants exist that aren't obvious from code
- New sessions consistently need the same context re-explained

Don't create for:
- Trivial utility folders
- Implementation details that change frequently
- Content better captured in code comments

## Updating CLAUDE.md Files

When updating any CLAUDE.md:

1. **Update the freshness date** using Bash `date +%Y-%m-%d`
2. **Verify contracts still hold** - read the code, check invariants
3. **Remove stale content** - better short and accurate than long and wrong
4. **Keep token-efficient** - <300 lines top-level, <100 lines subdirectory

## Common Mistakes

| Mistake | Fix |
|---------|-----|
| Describing WHAT code does | Focus on WHY it exists, contracts it keeps |
| Missing freshness date | Always include, always use Bash for real date |
| Too much detail | Subdirectory files should be <100 lines |
| Duplicating parent content | Subdirectory inherits parent; don't repeat |
| Stale contracts | Update when domain changes; verify dates |

## Checklist

**Top-level:**
- [ ] Tech stack listed
- [ ] Key commands documented
- [ ] Project structure overview
- [ ] Freshness date (from `date +%Y-%m-%d`)

**Subdirectory:**
- [ ] Purpose explains WHY (not what)
- [ ] Contracts: exposes, guarantees, expects
- [ ] Dependencies and boundaries clear
- [ ] Key decisions with rationale
- [ ] Invariants documented
- [ ] Freshness date (from `date +%Y-%m-%d`)
- [ ] Under 100 lines

Related Skills

writing-skills

16
from diegosouzapw/awesome-omni-skill

Use when creating new skills, editing existing skills, or verifying skills work before deployment

writing-ad-copy

16
from diegosouzapw/awesome-omni-skill

Creates platform-specific ad copy for paid campaigns with A/B variants. Use when the user asks about ad copy, PPC ads, Google Ads, Facebook ads, LinkedIn ads, or paid campaign copy.

superpowers-writing-skills

16
from diegosouzapw/awesome-omni-skill

Use when creating new skills, editing existing skills, or verifying skills work before deployment

setup-claude-code

16
from diegosouzapw/awesome-omni-skill

Claude Code 프로젝트 설정 생성

project-claude-initializer

16
from diegosouzapw/awesome-omni-skill

為新專案初始化 Claude Code 配置,建立標準化的 .claude 目錄、CLAUDE.md 和 gitignore。當使用者說「初始化 Claude 配置」、「設定專案 Claude」時使用。

planning-with-files

16
from diegosouzapw/awesome-omni-skill

Transforms workflow to use Manus-style persistent markdown files for planning, progress tracking, and knowledge storage. Use when starting complex tasks, multi-step projects, research tasks, or when the user mentions planning, organizing work, tracking progress, or wants structured output.

plan-writing

16
from diegosouzapw/awesome-omni-skill

Structured task planning with clear breakdowns, dependencies, and verification criteria. Use when implementing features, refactoring, or any multi-step work.

organizing-files

16
from diegosouzapw/awesome-omni-skill

Organizes macOS files across Desktop, Documents, Downloads, and iCloud Drive into a consistent structure. Use when the user asks to organize files, clean up folders, sort downloads, declutter desktop, tidy up documents, or structure their filesystem. Triggers on "organize", "clean up", "sort files", "declutter", "file mess", "tidy", or any request about file/folder structure on macOS.

multi-claude

16
from diegosouzapw/awesome-omni-skill

Run parallel Claude instances for writer+reviewer patterns, git worktrees, and specialist agents. Use for independent verification and parallel progress.

edit-claude

16
from diegosouzapw/awesome-omni-skill

Creates, updates, or optimizes CLAUDE.md files following Anthropic best practices. Use when user requests creating, updating, improving, or optimizing CLAUDE.md files for project context, coding standards, or persistent memory.

developing-claude-agent-sdk-agents

16
from diegosouzapw/awesome-omni-skill

Build AI agents with the Claude Agent SDK (TypeScript/Python). Covers creating agents, custom tools, hooks, subagents, MCP integration, permissions, sessions, and deployment. Use when building, reviewing, debugging, or deploying SDK-based agents. Invoke PROACTIVELY when user mentions Agent SDK, claude-agent-sdk, ClaudeSDKClient, query(), or building autonomous agents.

deepagents-filesystem

16
from diegosouzapw/awesome-omni-skill

Using FilesystemMiddleware with virtual filesystems, backends (State, Store, Filesystem, Composite), and context management for Deep Agents.