Major documentation update focused on technical accuracy and developer clarity: Documentation Changes: - Rewrote README.md with focus on hooks system architecture - Updated all core docs (Overview, Integration, Performance) to match implementation - Created 6 missing configuration docs for undocumented YAML files - Updated all 7 hook docs to reflect actual Python implementations - Created docs for 2 missing shared modules (intelligence_engine, validate_system) - Updated all 5 pattern docs with real YAML examples - Added 4 essential operational docs (INSTALLATION, TROUBLESHOOTING, CONFIGURATION, QUICK_REFERENCE) Key Improvements: - Removed all marketing language in favor of humble technical documentation - Fixed critical configuration discrepancies (logging defaults, performance targets) - Used actual code examples and configuration from implementation - Complete coverage: 15 configs, 10 modules, 7 hooks, 3 pattern tiers - Based all documentation on actual file review and code analysis Technical Accuracy: - Corrected performance targets to match performance.yaml - Fixed timeout values from settings.json (10-15 seconds) - Updated module count and descriptions to match actual shared/ directory - Aligned all examples with actual YAML and Python implementations The documentation now provides accurate, practical information for developers working with the Framework-Hooks system, focusing on what it actually does rather than aspirational features. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
5.0 KiB
Framework-Hooks
Framework-Hooks is a hook system for Claude Code that provides intelligent session management and context adaptation. It runs Python hooks at different points in Claude Code's lifecycle to optimize performance and adapt behavior based on usage patterns.
What it does
The system runs 7 hooks that execute at specific lifecycle events:
session_start.py- Initializes session context and activates appropriate featurespre_tool_use.py- Prepares for tool execution and applies optimizationspost_tool_use.py- Records tool usage patterns and updates learning datapre_compact.py- Applies compression before context compactionnotification.py- Handles system notifications and adaptive responsesstop.py- Performs cleanup and saves session data at shutdownsubagent_stop.py- Manages subagent cleanup and coordination
Components
Hooks
Each hook is a Python script that runs at a specific lifecycle point. Hooks share common functionality through shared modules and can access configuration through YAML files.
Shared Modules
framework_logic.py- Core logic for SuperClaude framework integrationcompression_engine.py- Context compression and optimizationlearning_engine.py- Adaptive learning from usage patternsmcp_intelligence.py- MCP server coordination and routingpattern_detection.py- Project and usage pattern detectionlogger.py- Structured logging for hook operationsyaml_loader.py- Configuration loading utilitiesvalidate_system.py- System validation and health checks
Configuration
12 YAML configuration files control different aspects:
session.yaml- Session lifecycle settingsperformance.yaml- Performance targets and limitscompression.yaml- Context compression settingsmodes.yaml- Mode activation thresholdsmcp_orchestration.yaml- MCP server coordinationorchestrator.yaml- General orchestration settingslogging.yaml- Logging configurationvalidation.yaml- System validation rules- Others for specialized features
Patterns
3-tier pattern system for adaptability:
minimal/- Basic project detection patterns (3-5KB each)dynamic/- Feature-specific patterns loaded on demand (8-12KB each)learned/- User-specific adaptations that evolve with usage (10-20KB each)
Cache
The system maintains JSON cache files for:
- User preferences and adaptations
- Project-specific patterns
- Learning records and effectiveness data
- Session state and metrics
Installation
- Ensure Python 3.8+ is available
- Place Framework-Hooks directory in your SuperClaude installation
- Claude Code will automatically discover and use the hooks
Usage
Framework-Hooks runs automatically when Claude Code starts a session. You don't need to invoke it manually.
The system will:
- Detect your project type and load appropriate patterns
- Activate relevant modes and MCP servers based on context
- Apply learned preferences from previous sessions
- Optimize performance based on resource constraints
- Learn from your usage patterns to improve future sessions
How it works
Session Flow
Session Start → Load Config → Detect Project → Apply Patterns →
Activate Features → Work Session → Record Learning → Save State
Hook Coordination
Hooks coordinate through shared state and configuration. Earlier hooks prepare context for later ones, and the system maintains consistency across the entire session lifecycle.
Learning System
The system tracks what works well for your specific projects and usage patterns. Over time, it adapts thresholds, preferences, and feature activation to match your workflow.
Performance Targets
- Session initialization: <50ms
- Pattern loading: <100ms per pattern
- Hook execution: <30ms per hook
- Cache operations: <10ms
Architecture
Framework-Hooks operates as a lightweight layer between Claude Code and the SuperClaude framework. It provides just-in-time intelligence loading instead of loading comprehensive framework documentation upfront.
The hook system allows Claude Code sessions to:
- Start faster by loading only necessary context
- Adapt to project-specific needs automatically
- Learn from usage patterns over time
- Coordinate MCP servers intelligently
- Apply compression and optimization transparently
Development
Adding Hooks
Create new hooks by:
- Adding a Python file in
hooks/directory - Following existing hook patterns for initialization
- Using shared modules for common functionality
- Adding corresponding configuration if needed
Modifying Configuration
YAML files in config/ control hook behavior. Changes take effect on next session start.
Pattern Development
Add new patterns in appropriate patterns/ subdirectories following existing YAML structure.
Troubleshooting
Logs are written to cache/logs/ directory. Check these files if hooks aren't behaving as expected.
The system includes validation utilities in validate_system.py for checking configuration and installation integrity.