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

Master OpenClaw on Your Android Smartphone: A Comprehensive Tutorial
Curious about harnessing the potential of OpenClaw on your Android smartphone? This tutorial provides step-by-step guidance on getting started, covering essential tips and tricks from the vibrant OpenClaw community.

Guide to Setting Up Safety Layers for Coding with Claude Code
A step-by-step guide shows how to implement defense-in-depth safety layers for coding with Claude Code, covering pre-commit hooks, CLAUDE.md files, local review agents, GitHub Actions CI, and branch protection.

OpenClaw v2.0 update requires manual checks before installation
OpenClaw's latest update includes 12 breaking changes, a new plugin system, and 30+ security patches. The update will silently break setups if users run npm update without first checking environment variables, state directories, and browser automation configurations.

NemoClaw Windows Setup Issues and Fixes
NemoClaw installations on Windows fail with three specific errors: unsupported environment on Git Bash, port 18789 already in use, and Docker build failing on OpenClaw install. The root cause is that NemoClaw wasn't built with Windows in mind, requiring WSL2 Ubuntu for successful setup.