Understanding the .claude/ folder structure for Claude Code configuration

Project and global configuration folders
There are two .claude directories: one in your project root for team configuration that gets committed to git, and another in your home directory (~/.claude/) for personal preferences and machine-local state like session history.
CLAUDE.md: The instruction manual
CLAUDE.md is loaded into Claude's system prompt at the start of each session and followed throughout the conversation. You can have CLAUDE.md at project root, in ~/.claude/ for global preferences, or in subdirectories for folder-specific rules.
Effective CLAUDE.md content includes:
- Build, test, and lint commands (npm run test, make build, etc.)
- Key architectural decisions
- Non-obvious gotchas
- Import conventions, naming patterns, error handling styles
- File and folder structure for main modules
Keep CLAUDE.md under 200 lines. Files longer than that start eating too much context and Claude's instruction adherence drops.
Example CLAUDE.md structure
# Project: Acme APICommands
npm run dev # Start dev server npm run test # Run tests (Jest) npm run lint # ESLint + Prettier check npm run build # Production build
Architecture
- Express REST API, Node 20
- PostgreSQL via Prisma ORM
- All handlers live in src/handlers/
- Shared types in src/types/
Conventions
- Use zod for request validation in every handler
- Return shape is always { data, error }
- Never expose stack traces to the client
- Use the logger module, not console.log
Watch out for
- Tests use a real local DB, not mocks. Run
npm run db:test:resetfirst - Strict TypeScript: no unused imports, ever
Personal overrides with CLAUDE.local.md
Create CLAUDE.local.md in your project root for personal preferences that don't apply to the whole team. Claude reads it alongside the main CLAUDE.md, and it's automatically gitignored so personal tweaks never land in the repository.
Modular instructions with rules/ folder
For larger teams, the rules/ folder provides modular instructions that scale better than a single large CLAUDE.md file.
📖 Read the full source: HN AI Agents
👀 See Also

Practical AI Coding Strategies from 1000 Hours of Experience
A Reddit post outlines specific prompting levels and workflow strategies for using AI coding agents effectively, including treating AI as a junior developer, phased implementation, and using instruction files.

Model Routing Baselines for Claude and OpenAI Usage
A developer shares their model routing strategy using Claude Haiku 4.5, Sonnet 4.6, Opus 4.6, and ChatGPT 5.3 Codex for different task types, with fallbacks to GPT-5 Mini and GPT-5.4 when needed.

How to safely run llama.cpp native tools (exec_shell_command) with multi-sandboxing on Linux
A practical guide to enabling llama.cpp native tools, especially exec_shell_command, and running them inside multiple sandboxes (Firejail + tiny Alpine VM) for safe web fetching and command execution via the llama-server web UI.

How to Set Up Sub-Agents with Separate Workspaces in OpenClaw
A community solution for configuring multiple sub-agents with isolated workspaces and different models