CLAUDE.md Hierarchy, Scoping, and Modular Organisation: Worked Example — Claude Code Configuration & Workflows (Claude Certified Architect)
Introduction to CLAUDE.md Hierarchy and Modular Organisation In configuring Claude Code for team workflows, a well-structured CLAUDE.md project...
Introduction to CLAUDE.md Hierarchy and Modular Organisation
In configuring Claude Code for team workflows, a well-structured CLAUDE.md project memory and instruction file hierarchy is essential. This ensures clarity, maintainability, and scalability in agentic applications. This worked example demonstrates how to design and organise CLAUDE.md files using scoping and modular principles for a realistic multi-feature project.
Scenario Overview
Imagine a team developing a customer support assistant powered by Claude. The assistant handles tasks such as ticket classification, FAQ answering, and escalation routing. The project requires modular memory files for each feature, scoped instructions, and integration into CI/CD pipelines.
Step 1: Define Top-Level CLAUDE.md Structure
Start by creating a root CLAUDE.md file that acts as the entry point for the project. This file contains global context and references to feature-specific modules.
- Root CLAUDE.md includes:
- Project overview and global instructions
- Links to submodules: ticket_classification.md, faq_module.md, escalation_routing.md
This modular approach avoids clutter and allows teams to work independently on features.
Step 2: Create Scoped Feature Modules
Each feature has its own CLAUDE.md file with scoped instructions and memory relevant only to that feature.
- ticket_classification.md: Contains training examples, classification rules, and fallback strategies.
- faq_module.md: Stores curated FAQ pairs, context for common questions, and update instructions.
- escalation_routing.md: Defines criteria for escalation, routing logic, and priority handling.
This scoping ensures that Claude’s context remains focused and efficient when executing tasks.
Step 3: Apply Path-Specific Conventions
Organise files in a directory structure reflecting their scope:
- /CLAUDE.md (root)
- /modules/ticket_classification.md
- /modules/faq_module.md
- /modules/escalation_routing.md
Use relative paths in the root CLAUDE.md to include these modules. This convention supports modular loading and easier updates.
Step 4: Iterative Refinement of Instructions
Within each module, iteratively refine instructions based on testing feedback:
- Start with broad instructions.
- Use example-driven clarifications.
- Adjust fallback and error handling based on observed failures.
This process improves accuracy and robustness over time.
Step 5: Worked Example of Root CLAUDE.md
Root CLAUDE.md Content
Project: Customer Support Assistant
Global Instructions
- Always prioritise customer satisfaction.
- Use polite, concise language.
Modules
@include ./modules/ticket_classification.md @include ./modules/faq_module.md @include ./modules/escalation_routing.md
Explanation: The root file sets global tone and includes feature modules via @include directives, enabling modular loading.
Step 6: Worked Example of a Feature Module
ticket_classification.md Content
Ticket Classification Module
Instructions
- Classify tickets into categories: Billing, Technical, General.
- If unclear, ask clarifying questions.
Examples
- "My internet is down" → Technical
- "I want to update my payment method" → Billing
Fallback
- Route to human agent if classification confidence < 70%
Explanation: This scoped module contains all relevant instructions and examples for ticket classification, isolated from other features.
Step 7: Integration into CI/CD Pipelines
Store all CLAUDE.md files in version control. Use automated scripts to validate syntax and run test prompts against the configured memory files during CI/CD. This ensures changes do not break workflows and maintain consistency.
Summary
This worked example illustrates how to organise CLAUDE.md files hierarchically and modularly for a team project. Key takeaways include:
- Use a root CLAUDE.md to define global context and include scoped modules.
- Create feature-specific modules with focused instructions and examples.
- Apply path conventions for clarity and modular loading.
- Iteratively refine instructions based on testing.
- Integrate into CI/CD pipelines for automated validation.
Following these principles enables scalable, maintainable Claude Code workflows that support complex agentic architectures.
More in this topic
Ready to test your knowledge?
Put what you've learned into practice with a quick quiz and track your progress.
Test your knowledge →