authoring-claude-md
Creating and maintaining CLAUDE.md project memory files and .claude/rules/ rule files that provide non-obvious codebase context. Use when (1) creating a new CLAUDE.md for a project, (2) adding architectural patterns or design decisions to existing CLAUDE.md, (3) capturing project-specific conventions that aren't obvious from code inspection, (4) organising instructions into path-scoped rule files.
What this skill does
# CLAUDE.md and Rules Authoring Create effective CLAUDE.md files and `.claude/rules/` rule files that serve as project-specific memory for AI coding agents. ## Purpose CLAUDE.md files and rule files provide AI agents with: - Non-obvious conventions, architectural patterns and gotchas - Confirmed solutions to recurring issues - Project-specific context not found in standard documentation - Path-scoped instructions that only load when relevant files are touched **Not for Obvious patterns, duplicating documentation, or generic coding advice.**: ## Core Principles - **Signal over noise**: Every sentence must add non-obvious value. If an AI agent could infer it from reading the codebase, omit it. - **Actionable context**: Focus on "what to do" and "why it matters", not descriptions of what exists. - **Solve real friction, not theoretical concerns**: Add to CLAUDE.md based on actual problems encountered, not hypothetical scenarios. If you repeatedly explain the same thing to Claude, document it. If you haven't hit the problem yet, don't pre-emptively solve it. ## Structure - Use headings for clear organisation. Suggested sections: - Use 2-4 sections. Only include what adds value. ## When to Use `.claude/rules/` Instead For larger projects, break instructions into separate files under `.claude/rules/`. Each `.md` file covers one topic. Prefer rules over a single CLAUDE.md when: - Instructions are growing beyond 200 lines - Different rules apply to different parts of the codebase (frontend vs backend, API vs CLI) - Multiple team members maintain different sections - Some instructions only matter when working with specific file types ### Rule File Basics ``` 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. ### Path-Specific Rules 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. ```markdown --- 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. ### User-Level Rules 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 vs Skills 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. ## What to Include **Architectural decisions**: Why microservices over monolith, event-driven patterns, state management **Non-obvious conventions**: - "Use `_internal` suffix for private APIs not caught by linter" - "Date fields always UTC, formatting happens client-side" - "Avoid ORM for reports, use raw SQL in `/queries`" **Recurring issues**: - "TypeError in auth: ensure `verify()` uses Buffer.from(secret, 'base64')" - "Cache race condition: acquire lock before checking status" **Project patterns**: Error handling, logging, API versioning, migrations ## What to Exclude - Line numbers: Files change, references break. Use descriptive paths: "in `src/auth/middleware.ts`" not "line 42" - Obvious information: "We use React" (visible in package.json) - Setup steps: Belongs in README unless highly non-standard - Generic advice: "Write good tests" adds no project-specific value - Temporary notes: "TODO: refactor this" belongs in code comments - Duplicate content: If it's in README, don't repeat it - Formatting over-emphasis: You don't need to bold the start of every sentence or bullet point, only add emphasis for stand out important statements or warnings that truly warrant it ## Anti-Patterns - Code style guidelines: Don't document code formatting rules, naming conventions, or code patterns that linters enforce. Use ESLint, Prettier, Black, golangci-lint, or similar tools. LLMs are in-context learners and will pick up patterns from codebase exploration. Configure Claude Code Hooks to run formatters if needed. - Task-specific minutiae: Database schemas, API specifications, deployment procedures belong in their own documentation. Link to them from CLAUDE.md rather than duplicating content. - Kitchen sink approach: Not every gotcha needs CLAUDE.md. Ask: "Is this relevant across most coding sessions?" If no, it belongs in code comments or specific documentation files. ## Linking to Existing Documentation Point to existing docs rather than duplicating content. Provide context about when to read them: **Good**: ```markdown # 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 Use `file:line` references for specific code: "See error handling in src/utils/errors.ts:45-67" ## Writing Style **Be specific**: - ❌ "Use caution with the authentication system" - ✅ "Auth tokens expire after 1 hour. Background jobs must refresh tokens using `refreshToken()` in `src/auth/refresh.ts`" **Be concise**: - ❌ "It's important to note that when working with our database layer, you should be aware that..." - ✅ "Database queries: Use Prisma for CRUD, raw SQL for complex reports in `/queries`" **Use active voice**: - ❌ "Migrations should be run before deployment" - ✅ "Run migrations before deployment: `npm run migrate:prod`" ## When to Update Add to CLAUDE.md when: - Discovering a non-obvious pattern after codebase exploration or complex problem resolution - Solving an issue that took significant investigation that will be encountered again by other agents - Finding a gotcha that's not immediately clear from code Don't add: - One-off fixes for specific bugs - Information easily found in existing docs - Temporary workarounds (these belong in code comments) - Verbose descriptions or explanations ## Spelling Conventions Always use Australian English spelling ## Example Structure ```markdown # 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. ``` ## Token Budget Aim for 1k-4k token
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.