Complete guide to Claude MPM's codebase organization.
claude-mpm/
├── src/claude_mpm/ # Main package
│ ├── agents/ # Agent system
│ ├── services/ # Service layer
│ ├── hooks/ # Hook system
│ ├── mcp/ # MCP gateway
│ └── cli/ # CLI interface
├── docs/ # Documentation
├── tests/ # Test suite
├── scripts/ # Utility scripts
└── skills/ # Bundled skills
Core Modules:
__init__.py- Package initialization__main__.py- CLI entry pointversion.py- Version informationconstants.py- Global constantsexceptions.py- Custom exceptions
Agent discovery, loading, and management:
agents/
├── __init__.py
├── registry.py # Agent discovery and loading
├── deployment.py # Agent lifecycle management
├── management.py # Agent services
├── capabilities.py # Capability definitions
└── schema.py # Agent schema validation
Key Components:
- AgentRegistry: Three-tier agent discovery (PROJECT > USER > SYSTEM)
- AgentDeployment: Agent initialization and lifecycle
- CapabilityManager: Capability matching and routing
Five specialized service domains:
services/
├── core/ # Foundation services
│ ├── interfaces.py # Service contracts
│ ├── base.py # Base classes
│ └── container.py # DI container
├── agents/ # Agent services
│ ├── deployment.py # Agent deployment
│ ├── management.py # Agent management
│ └── registry.py # Agent registry
├── communication/ # Real-time communication
│ ├── socketio.py # SocketIO server
│ └── websocket.py # WebSocket handling
├── project/ # Project services
│ ├── analyzer.py # Stack detection
│ └── registry.py # Project config
└── utility/ # Supporting services
├── logging.py # Logging utilities
└── filesystem.py # File operations
Service Interfaces:
IServiceContainer- Dependency injectionIAgentRegistry- Agent discoveryIHealthMonitor- Service healthIConfigurationManager- Configuration
See developer/api-reference.md for API details.
Event-driven extension points:
hooks/
├── __init__.py
├── manager.py # Hook manager
├── handlers.py # Built-in handlers
└── context.py # Hook context
Hook Types:
pre_tool_use- Before tool executionpost_tool_use- After tool executionsession_start- Session initializationsession_end- Session cleanup
See developer/pretool-use-hooks.md for details.
Model Context Protocol integration:
mcp/
├── __init__.py
├── gateway.py # MCP gateway
├── servers/ # MCP server implementations
│ ├── filesystem.py # Filesystem server
│ ├── github.py # GitHub server
│ └── browser.py # Browser automation
└── tools/ # MCP tool definitions
See developer/13-mcp-gateway/README.md for MCP integration.
Command-line interface:
cli/
├── __init__.py
├── main.py # Main CLI entry
├── commands.py # Command implementations
└── formatting.py # Output formatting
Organized by audience and topic:
docs/
├── README.md # Documentation hub
├── guides/ # How-to guides
│ └── FAQ.md # Frequently asked questions
├── user/ # End-user docs
│ ├── getting-started.md # Quick start guide
│ ├── user-guide.md # Complete user guide
│ ├── installation.md # Installation guide
│ ├── troubleshooting.md # User troubleshooting
│ └── skills-guide.md # Skills system guide
├── developer/ # Developer docs
│ ├── ARCHITECTURE.md # System architecture
│ ├── api-reference.md # API documentation
│ ├── extending.md # Extension development
│ └── publishing-guide.md # Release process
├── agents/ # Agent docs
│ ├── pm-workflow.md # PM orchestration
│ ├── creating-agents.md # Agent development
│ └── agent-patterns.md # Agent design patterns
├── reference/ # Reference docs
│ ├── DEPLOY.md # Deployment guide
│ ├── STRUCTURE.md # This file
│ ├── SERVICES.md # Service reference
│ ├── QA.md # Testing guide
│ └── MEMORY.md # Memory system
└── examples/ # Examples and tutorials
└── resume-log-examples.md # Resume log examples
See README.md for documentation hub.
Comprehensive test coverage (85%+):
tests/
├── unit/ # Unit tests
│ ├── test_agents.py
│ ├── test_services.py
│ └── test_hooks.py
├── integration/ # Integration tests
│ ├── test_workflow.py
│ └── test_mcp.py
├── fixtures/ # Test fixtures
│ ├── agents/ # Test agents
│ └── data/ # Test data
└── conftest.py # Pytest configuration
Testing Standards:
- 85%+ code coverage required
- Unit tests for all services
- Integration tests for workflows
- Fixtures for common scenarios
See reference/QA.md for testing guide.
Utility and automation scripts:
scripts/
├── manage_version.py # Version management
├── setup_dev.sh # Development setup
├── run_tests.sh # Test execution
└── deploy.sh # Deployment automation
Important: ALL scripts must go in /scripts/, NEVER in project root.
Bundled skills included with Claude MPM:
skills/
├── git-workflow.md
├── tdd.md
├── code-review.md
├── systematic-debugging.md
├── api-documentation.md
├── refactoring-patterns.md
└── ... (20 bundled skills)
Skill Tiers:
- Bundled:
/skills/- Included with installation - User:
~/.config/claude-mpm/skills/- Personal skills - Project:
.claude-mpm/skills/- Project-specific skills
See user/skills-guide.md for skills documentation.
claude-mpm/
├── pyproject.toml # Package metadata and dependencies
├── setup.py # Setup configuration
├── setup.cfg # Build configuration
├── MANIFEST.in # Package manifest
└── VERSION # Version file
claude-mpm/
├── .pre-commit-config.yaml # Pre-commit hooks
├── .flake8 # Flake8 linting
├── .mypy.ini # MyPy type checking
├── pytest.ini # Pytest configuration
└── .gitignore # Git ignore rules
claude-mpm/
├── Makefile # Development tasks
├── .ruff.toml # Ruff linting
└── .black.toml # Black formatting
/usr/local/share/claude-mpm/
└── configuration.yaml # System defaults
~/.claude-mpm/
├── configuration.yaml # User configuration
├── agents/ # Custom agents
├── skills/ # Custom skills
├── cache/ # Runtime cache
├── logs/ # Log files
│ ├── mpm.log # Main log
│ ├── agents.log # Agent logs
│ └── mcp.log # MCP logs
└── sessions/ # Session data
.claude-mpm/
├── configuration.yaml # Project configuration
├── agents/ # Project agents
├── skills/ # Project skills
├── resume-logs/ # Session resume logs
└── sessions/ # Project sessions
Python Modules:
- Use snake_case:
agent_registry.py - Private modules:
_internal.py - Test modules:
test_agent_registry.py
Documentation:
- Use UPPERCASE for top-level:
README.md,ARCHITECTURE.md - Use kebab-case for guides:
getting-started.md - Use descriptive names:
resume-log-architecture.md
Agents:
- Use kebab-case:
python-engineer.md - Version in frontmatter:
version: 2.3.0
Skills:
- Use kebab-case:
git-workflow.md - Version in frontmatter:
version: 0.1.0
- Scripts: ALL scripts go in
/scripts/, NEVER in project root - Tests: ALL tests go in
/tests/, NEVER in project root - Modules: ALL Python code goes in
/src/claude_mpm/ - Docs: ALL documentation goes in
/docs/ - Skills: Bundled skills go in
/skills/
Service-Oriented:
- Business logic in service layer
- Interface-based contracts
- Dependency injection
- Clear separation of concerns
Module Structure:
# Service module template
from claude_mpm.services.core import BaseService
from claude_mpm.services.core.interfaces import IServiceInterface
class MyService(BaseService, IServiceInterface):
"""Service implementation."""
def __init__(self, container):
super().__init__(container)
def my_method(self):
"""Method implementation."""
passGenerated Files:
build/ # Build directory
dist/ # Distribution packages
*.egg-info/ # Package metadata
__pycache__/ # Python cache
.pytest_cache/ # Pytest cache
.mypy_cache/ # MyPy cache
These are ignored by git (.gitignore).
- Architecture - System design
- Developer Guide - Development docs
- API Reference - API documentation
- Testing Guide - Testing standards
- Services Reference - Service architecture
For developer guidelines: See CONTRIBUTING.md