UNPKG

claude-buddy

Version:

Your friendly AI development companion for Claude Code - supercharge Claude Code with intelligent workflows and safety features

182 lines (146 loc) 7.19 kB
# ADR-002: 12-Persona Intelligent System Architecture **Status**: Accepted **Date**: 2024-07-22 **Authors**: Claude Code Buddy Contributors **Reviewers**: Development Team ## Context Claude Code Buddy needed an intelligent system to provide specialized AI assistance for different development tasks. The challenge was designing a system that could: - Automatically activate appropriate domain experts based on context - Support manual persona override when needed - Enable multi-persona collaboration for complex tasks - Learn from user interactions and improve recommendations - Scale to support additional personas in the future Traditional single-persona approaches were insufficient for the diverse range of development tasks that Claude Code users encounter, from security reviews to performance optimization to architecture decisions. ## Decision Implement a 12-persona intelligent coordination system with four core components: 1. **PersonaSystem**: Main coordinator for the entire system 2. **PersonaManager**: Central persona lifecycle and collaboration management 3. **PersonaActivationEngine**: Context-driven auto-detection and recommendation 4. **PersonaLearningEngine**: Adaptive pattern recognition and user preference learning The system features 12 specialized personas organized into three categories: - **Technical Specialists**: Security, Performance, Frontend, Backend, DevOps - **Process Experts**: Architect, QA, Refactorer, PO (Product Owner) - **Knowledge Specialists**: Analyzer, Mentor, Scribe ## Options Considered ### Option 1: Single General-Purpose Assistant - **Pros**: - Simple implementation - No context switching complexity - Consistent response style - **Cons**: - Lacks domain expertise - Generic responses for specialized tasks - No adaptation to user needs ### Option 2: Simple Rule-Based Persona Selection - **Pros**: - Predictable behavior - Easy to debug - Clear activation logic - **Cons**: - Inflexible to context nuances - No learning capabilities - Manual rule maintenance overhead ### Option 3: 12-Persona Intelligent System (Selected) - **Pros**: - Domain expertise for specialized tasks - Intelligent auto-activation based on context - Multi-persona collaboration capabilities - Learning and adaptation over time - Extensible architecture - **Cons**: - Higher implementation complexity - More sophisticated testing requirements - Potential for activation conflicts ### Option 4: Large Number of Micro-Personas (20+) - **Pros**: - Highly specialized expertise - Fine-grained activation control - **Cons**: - Excessive complexity - User confusion - Activation conflicts and overlap ## Consequences ### Positive Outcomes - **Specialized Expertise**: Each persona provides deep domain knowledge for specific tasks - **Intelligent Activation**: Context-driven selection reduces manual configuration - **Collaboration Patterns**: Multi-persona workflows for comprehensive analysis - **Adaptive Learning**: System improves recommendations based on usage patterns - **Extensibility**: Clear architecture for adding new personas - **User Experience**: Relevant expertise automatically available when needed ### Negative Outcomes - **Implementation Complexity**: Sophisticated coordination and collaboration logic - **Testing Overhead**: Complex interaction patterns require comprehensive test coverage - **Memory Usage**: Managing multiple persona definitions and session state - **Activation Conflicts**: Potential for inappropriate or competing persona selection ### Neutral Impacts - **Response Time**: Minimal impact due to efficient activation algorithms - **Configuration**: Requires persona definitions but provides sensible defaults ## Implementation ### Core Architecture Components 1. **PersonaSystem Class**: - Main entry point for all persona functionality - Coordinates between manager, activation engine, and learning system - Handles flag parsing and manual overrides - Integrates learning recommendations into activation decisions 2. **PersonaManager**: - Loads and manages 12 persona definitions from markdown files - Implements collaboration planning and validation chains - Generates persona-aware prompts for Claude Code - Records interaction data for learning 3. **PersonaActivationEngine**: - Multi-factor scoring algorithm (keywords 30%, context 40%, files 20%, history 10%) - Confidence threshold management - Session context tracking - Integration with learning recommendations 4. **PersonaLearningEngine**: - Pattern recognition for successful persona combinations - User preference tracking and adaptation - Feedback integration and rating analysis - Long-term usage analytics ### Persona Categories and Specializations **Technical Specialists**: - Security: Threat assessment, vulnerability analysis, secure coding - Performance: Optimization, profiling, scalability analysis - Frontend: UI/UX, accessibility, browser compatibility - Backend: APIs, databases, server architecture - DevOps: CI/CD, deployment, infrastructure **Process Experts**: - Architect: System design, patterns, technical decisions - QA: Testing strategies, quality assurance, validation - Refactorer: Code improvement, technical debt, maintainability - PO: Product requirements, user stories, strategic planning **Knowledge Specialists**: - Analyzer: Code analysis, investigation, problem diagnosis - Mentor: Learning guidance, best practices, skill development - Scribe: Documentation, commit messages, technical writing ### Activation Algorithm ```typescript function calculatePersonaScore(persona, context) { const keywordScore = matchKeywords(persona.keywords, context.input) * 0.3; const contextScore = analyzeContext(persona.patterns, context) * 0.4; const fileScore = matchFilePatterns(persona.filePatterns, context.files) * 0.2; const historyScore = getUserHistory(persona.name, context.user) * 0.1; return keywordScore + contextScore + fileScore + historyScore; } ``` ## Monitoring and Success Criteria Success indicators: - ✅ Activation accuracy >90% for clear domain-specific requests - ✅ User satisfaction ratings >4.0/5.0 for persona recommendations - ✅ Multi-persona collaboration working for complex tasks - ✅ Learning system improving activation quality over time - ✅ All 12 personas properly loaded and functional Ongoing monitoring: - Persona activation frequency and success rates - User feedback and rating trends - Collaboration pattern effectiveness - Learning system adaptation metrics - Performance impact of activation decisions ## Related ADRs - [ADR-001](./ADR-001-typescript-migration.md) - TypeScript enables robust persona type safety - [ADR-004](./ADR-004-hook-system-security.md) - Security persona integrates with hook validation ## References - [Persona System API Documentation](../api/classes/PersonaSystem.md) - [Persona Specialist Definitions](../../src/personas/specialists/) - [Multi-Agent AI Systems Research](https://arxiv.org/abs/2302.04048) - [Context-Aware Recommendation Systems](https://dl.acm.org/doi/10.1145/1134271.1134294)