This skill helps create and maintain CLAUDE.md project memories by capturing non-obvious conventions, patterns, and gotchas beyond code inspection.
npx playbooks add skill sammcj/agentic-coding --skill authoring-claude-md
Create effective CLAUDE.md files and .claude/rules/ rule files that serve as project-specific memory for AI coding agents.
CLAUDE.md files and rule files provide AI agents with:
Not for: obvious patterns, duplicating documentation, or generic coding advice.
Use headings for clear organisation. Common sections: Architecture, Conventions, Gotchas, Testing. Use 2-4 sections and only include what adds value.
.claude/rules/ InsteadFor larger projects, break instructions into separate files under .claude/rules/. Each .md file covers one topic. Prefer rules over a single CLAUDE.md when:
your-project/
├── .claude/
│ ├── CLAUDE.md # Main project instructions
│ └── rules/
│ ├── code-style.md # Always loaded
│ ├── testing.md # Always loaded
│ └── security.md # Always loaded
Files are discovered recursively, so subdirectories like frontend/ and backend/ work. Rules without paths frontmatter load at launch with the same priority as .claude/CLAUDE.md.
The same authoring principles apply to rule files: signal over noise, actionable context, no obvious information.
Scope rules to specific files using YAML frontmatter with the paths field. These only load when Claude reads files matching the glob patterns, reducing noise and saving context.
---
paths:
- "src/api/**/*.ts"
---
# API Development Rules
- All API endpoints must include input validation
- Use the standard error response format
- Include OpenAPI documentation comments
Rules without a paths field apply unconditionally. Path-scoped rules trigger on file read, not on every tool use.
Personal rules that apply across all your projects live at ~/.claude/rules/. These load before project rules, giving project rules higher priority.
~/.claude/rules/
├── preferences.md # Personal coding preferences
└── workflows.md # Preferred workflows
Rules load every session (or when matching files are opened). For task-specific instructions that don't need constant context, use skills instead. Skills load only when invoked or when Claude determines they're relevant.
Architectural decisions: Why microservices over monolith, event-driven patterns, state management
Non-obvious conventions:
_internal suffix for private APIs not caught by linter"/queries"Recurring issues:
verify() uses Buffer.from(secret, 'base64')"Project patterns: Error handling, logging, API versioning, migrations
src/auth/middleware.ts" not "line 42"Before adding a line, check it against what else is already loaded: the user-level ~/.claude/CLAUDE.md, sibling rule files, and any skill covering the same ground. Instructions that clash ("leave documentation as appropriate" next to "never add comments") make the agent resolve the contradiction before it can start work, and it won't resolve it the same way every session.
Keep each topic in one place:
/legacy keeps its existing formatting")Path-scoped rules refine the root CLAUDE.md for the files they match; they shouldn't reverse it.
Point to existing docs rather than duplicating content. Provide context about when to read them:
Good:
# Architecture
Event-driven architecture using AWS EventBridge.
- For database schema: see src/database/SCHEMA.md when working with data models
- For auth flows: see src/auth/README.md when working with authentication
Bad: Copying schema tables, pasting deployment steps, or duplicating API flows into CLAUDE.md
Be specific:
refreshToken() in src/auth/refresh.ts"Be concise:
/queries"Use active voice:
npm run migrate:prod"Add to CLAUDE.md when:
Don't add anything covered under What to Exclude (one-off fixes, temporary workarounds, info already in docs, verbose explanations).
Always use Australian English spelling
# Architecture
Event-driven architecture using AWS EventBridge. Services communicate via events, not direct calls.
Auth: JWT tokens with refresh mechanism. See src/auth/README.md for detailed flows when working on authentication.
Database schema and relationships: see src/database/SCHEMA.md when working with data models.
# Conventions
- API routes: Plural nouns (`/users`, `/orders`), no verbs in paths
- Error codes: 4-digit format `ERRR-1001`, defined in src/errors/codes.ts
- Feature flags: Check in middleware, not in business logic
- Dates: Always UTC in database, format client-side via src/utils/dates.ts
- Documentation: Use DocBlocks for public functions, never use "smart" formatting markdown
# Gotchas
**Cache race conditions**: Always acquire lock before checking cache status
**Background job authentication**: Tokens expire after 1 hour. Refresh using
`refreshToken()` in src/auth/refresh.ts before making API calls.
# Testing
- Tests should never have external API calls or dependencies.
- Run `make test` before committing.
Aim for 1k-4k tokens for CLAUDE.md. Most projects fit in 100-300 lines. A single CLAUDE.md is fine for most projects - if exceeding budget, consider whether splitting into .claude/rules/ files would help (especially if some content only applies to specific file types). If exceeding:
Estimate token count with wc -c CLAUDE.md, then divide the character count by roughly 4.
Before finalising:
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.