| name | modulite |
| description | Manage module boundaries and dependency rules. Run validation, add new modules, update dependency declarations, diagnose violations. Use when adding cross-module imports or creating new libs. |
| argument-hint | [check | add-dep <module> <dependency> | add-module <name> | diagnose] |
| allowed-tools | Read, Edit, Write, Grep, Glob, Bash |
Modulite — Module Boundary Manager
Inspired by VK Modulite (https://github.com/VKCOM/modulite).
Action: $ARGUMENTS
If no argument — run check.
Configuration
- Rules:
modulite.php — module definitions (namespace, path, requires)
- Validator:
tools/modulite-check.php — scans use statements, reports violations
Current Dependency Graph
Kernel (foundation, no internal deps)
^
|
McpServer --> Kernel
^
|
API ---------> Kernel, McpServer
^
|
Cli ---------> Kernel, API, McpServer
Testing (independent, no internal deps)
Adapter/Yii3 -----> Kernel, API, Cli, McpServer
Adapter/Symfony ---> Kernel, API, Cli, McpServer
Adapter/Laravel ---> Kernel, API, Cli, McpServer
Adapter/Yii2 -----> Kernel, API, Cli, McpServer
Adapter/Cycle -----> API
Actions
check (default)
Run the modulite boundary validator:
php tools/modulite-check.php
If violations found, analyze each one:
- Is it a legitimate new dependency? ->
add-dep
- Is it an architecture violation? -> suggest refactoring
- Is it a misplaced class? -> suggest moving it
add-dep <module> <dependency>
Add a dependency declaration to modulite.php.
Steps:
- Read
modulite.php
- Find the module entry
- Add the dependency to
requires array
- Run
php tools/modulite-check.php to verify
- Update CLAUDE.md dependency table if it exists
Validation rules before adding:
- No circular dependencies — verify the new edge doesn't create a cycle
- No adapter-to-adapter — adapters must NEVER depend on other adapters
- Kernel stays pure — kernel cannot require any other internal module
- Testing stays independent — testing cannot require internal modules
add-module <name>
Register a new module in modulite.php.
Steps:
- Ask for: namespace, path (or array of paths), required modules
- Add entry to
modulite.php
- Run
php tools/modulite-check.php to verify
- Update CLAUDE.md dependency table
diagnose
Deep analysis of current module health:
php tools/modulite-check.php --format=json
Then analyze:
- Violations — list and categorize each
- Dependency weight — count internal refs per module pair
- Potential issues — modules with too many dependencies
- Suggestions — possible simplifications
Architecture Rules (Hard Constraints)
These rules must NEVER be violated:
- Acyclic — no circular dependencies between modules
- Kernel is foundation — depends on nothing internal
- Testing is independent — depends on nothing internal
- Adapters never cross-depend — adapter-symfony cannot import from adapter-laravel
- Layer order — Kernel < McpServer < API < Cli < Adapters
- External deps are free — vendor namespaces are not governed
Output
After any action, always run the check and report results:
Modulite: X modules, Y files, Z internal refs, N violations
If violations exist, show them as a table:
| Module | File | Line | Imports | From Module | Status |
|---|
Status: VIOLATION (undeclared), OK (declared), BLOCKED (architectural rule prevents it)