$ recombobulate _
home / tips / add-claudemd-files-in-subdirectories-for-module-specific-instructions
176

Add CLAUDE.md Files in Subdirectories for Module-Specific Instructions

recombobulate @recombobulate · Mar 30, 2026 · Configuration
add-claudemd-files-in-subdirectories-for-module-specific-instructions

A single root CLAUDE.md works great for small projects, but larger codebases have modules with their own conventions, dependencies, and quirks. Subdirectory CLAUDE.md files let you layer context so Claude gets the right instructions for whichever part of the code it's working in.

my-project/
├── CLAUDE.md                    # Global rules: coding style, commit conventions
├── app/
│   ├── CLAUDE.md                # Backend rules: use form requests, never raw SQL
│   └── Services/
│       └── CLAUDE.md            # Service layer: always inject dependencies
├── resources/views/
│   └── CLAUDE.md                # Frontend: use Flux UI components, Tailwind v4
└── tests/
    └── CLAUDE.md                # Testing: use Pest, always use factories

When Claude works on a file, it reads CLAUDE.md files from the project root down to the file's directory — instructions stack and get more specific as you go deeper.

This means your root CLAUDE.md handles the universal stuff:

# Root CLAUDE.md
- Use strict types in all PHP files
- Run `vendor/bin/pint --dirty` after PHP changes
- Commit messages: imperative mood, under 72 chars

And subdirectory files handle module-specific context:

# tests/CLAUDE.md
- Use Pest, not PHPUnit directly
- Always use model factories, never create models manually
- Use RefreshDatabase trait on all feature tests
- Run tests with: php artisan test --compact

This keeps each CLAUDE.md focused and short — Claude only loads what's relevant to the files it's touching, rather than wading through a massive root file with sections for every module.

It's especially powerful for monorepos where packages have completely different tech stacks — your Go service and your React frontend can each have their own CLAUDE.md with the right language, framework, and tooling instructions.

One CLAUDE.md per module keeps instructions focused — Claude gets exactly the context it needs, right where the code lives.

via Claude Code

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Describe Your Users in CLAUDE.md So Claude Writes Appropriate Copy, Error Messages, and UX

When Claude writes error messages, button labels, validation text, or onboarding flows, it defaults to generic developer-speak. Add a "Users" section to your CLAUDE.md describing who your actual users are — their technical level, industry jargon, and what they care about — so Claude writes copy that makes sense to THEM, not to developers.

recombobulate @recombobulate · 1 day ago
1
Create Custom Agents with --agent for Scoped Sessions

Use the --agent flag with custom markdown files in .claude/agents/ to launch purpose-built Claude sessions with restricted tools and scoped system prompts.

recombobulate @recombobulate · 1 day ago
106
Add Known Gotchas and Pitfalls to Your CLAUDE.md So Claude Avoids Mistakes Your Team Already Made

Every project has traps — the billing module that silently fails if you forget to queue the job, the legacy table with column names that don't match the model, the config value that must be set before tests run. Document these gotchas in your CLAUDE.md so Claude avoids the same mistakes your team spent days debugging.

recombobulate @recombobulate · 1 day ago