- Implement content for 200+ TODO placeholders across all documentation - Create complete documentation structure: Getting-Started, User-Guide, Developer-Guide, Reference - Add comprehensive guides for commands, agents, modes, MCP servers, flags, session management - Implement technical architecture, contributing, testing, and security documentation - Create examples cookbook, troubleshooting guide, and best practices documentation - Update administrative files: CONTRIBUTING.md, SECURITY.md, PUBLISHING.md, CODE_OF_CONDUCT.md - Ensure factual accuracy based on actual SuperClaude implementation analysis - Maintain professional structure with progressive complexity and cross-references - Provide complete coverage from beginner to expert level usage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
54 KiB
Testing & Debugging SuperClaude Framework 🧪
This guide provides comprehensive testing and debugging strategies for SuperClaude Framework development. Whether you're contributing components, fixing bugs, or optimizing performance, these techniques will help you build robust, reliable code.
Developer-Focused Approach: Testing and debugging strategies specifically designed for the meta-framework architecture, component system, and intelligent orchestration patterns unique to SuperClaude.
Testing Framework
Development Testing Procedures
Test Structure:
tests/
├── unit/ # Component unit tests
│ ├── test_components.py # Component system tests
│ ├── test_agents.py # Agent system tests
│ └── test_mcp.py # MCP integration tests
├── integration/ # Integration tests
│ ├── test_installation.py # Installation process tests
│ ├── test_workflows.py # End-to-end workflow tests
│ └── test_coordination.py # Multi-component coordination
├── performance/ # Performance benchmarks
│ ├── test_memory.py # Memory usage tests
│ └── test_speed.py # Execution speed tests
└── fixtures/ # Test data and configurations
Running Tests:
# Run all tests
python -m pytest tests/
# Run specific test categories
python -m pytest tests/unit/
python -m pytest tests/integration/
python -m pytest tests/performance/
# Run with coverage
python -m pytest --cov=setup --cov-report=html tests/
# Run with verbose output
python -m pytest -v tests/
# Run specific test file
python -m pytest tests/unit/test_components.py -v
Test Coverage Requirements:
- Unit Tests: >90% coverage for core components
- Integration Tests: All major workflows covered
- Performance Tests: Memory and speed benchmarks
- Installation Tests: All component installation scenarios
Testing Standards:
# Example test structure
import pytest
from setup.components.base import BaseComponent
from setup.core.registry import ComponentRegistry
class TestComponentSystem:
def setup_method(self):
"""Set up test environment before each test"""
self.test_dir = Path('test-install')
self.registry = ComponentRegistry()
def teardown_method(self):
"""Clean up after each test"""
if self.test_dir.exists():
shutil.rmtree(self.test_dir)
def test_component_installation(self):
"""Test component installation process"""
# Test setup
component = CoreComponent()
# Execute test
result = component.install(self.test_dir)
# Assertions
assert result.success
assert (self.test_dir / 'CLAUDE.md').exists()
assert 'core' in self.registry.list_installed()
Debugging SuperClaude Components
Agent System Debugging
Agent Activation Debugging:
# Debug agent selection and activation
class AgentDebugger:
def debug_agent_selection(self, task_context):
print("🔍 Agent Selection Debug:")
# Show detected triggers
triggers = self._extract_triggers(task_context)
print(f" Detected triggers: {triggers}")
# Show selected agents
selected_agents = self._select_agents(triggers)
print(f" Selected agents: {selected_agents}")
# Show coordination pattern
pattern = self._determine_coordination(selected_agents)
print(f" Coordination pattern: {pattern}")
return selected_agents, pattern
# Usage in development
debugger = AgentDebugger()
agents, pattern = debugger.debug_agent_selection(task_context)
Agent Coordination Debugging:
# Enable agent debug mode
export SUPERCLAUDE_DEBUG_AGENTS=true
# Run with agent tracing
python -m SuperClaude install --debug-agents --dry-run
# Check agent activation logs
tail -f ~/.claude/logs/agent-activation.log
Common Agent Issues:
- Agent Not Activating: Check trigger patterns and keyword matching
- Wrong Agent Selected: Verify trigger priority and specificity
- Coordination Conflicts: Debug agent hierarchy and decision authority
Mode System Debugging
Mode Activation Debugging:
class ModeDebugger:
def debug_mode_selection(self, task_analysis):
print("🧠 Mode Selection Debug:")
# Complexity analysis
complexity = task_analysis.complexity_score
print(f" Complexity score: {complexity}")
# Trigger analysis
mode_triggers = self._analyze_mode_triggers(task_analysis)
for mode, triggers in mode_triggers.items():
print(f" {mode}: {triggers}")
# Final mode selection
selected_modes = self._select_modes(task_analysis)
print(f" Selected modes: {selected_modes}")
return selected_modes
Mode State Inspection:
# Enable mode debugging
export SUPERCLAUDE_DEBUG_MODES=true
# Inspect mode transitions
python -c "
from setup.core.mode_manager import ModeManager
manager = ModeManager()
print(manager.get_active_modes())
print(manager.get_mode_history())
"
MCP Server Debugging
MCP Connection Debugging:
class MCPDebugger:
def debug_server_connection(self, server_name):
print(f"🔌 MCP Server Debug: {server_name}")
# Check server configuration
config = self._get_server_config(server_name)
print(f" Configuration: {config}")
# Test connection
try:
connection = self._test_connection(server_name)
print(f" Connection: ✅ Success")
# Test basic functionality
response = connection.ping()
print(f" Ping response: {response}")
except Exception as e:
print(f" Connection: ❌ Failed - {e}")
# Check server health
health = self._check_server_health(server_name)
print(f" Health status: {health}")
# Usage
debugger = MCPDebugger()
debugger.debug_server_connection('context7')
MCP Communication Tracing:
# Enable MCP communication logging
export SUPERCLAUDE_DEBUG_MCP=true
# Trace MCP requests and responses
python -m SuperClaude debug --mcp-trace
# Check MCP server logs
tail -f ~/.claude/logs/mcp-*.log
Common MCP Issues:
- Server Won't Start: Check Node.js installation and server paths
- Connection Timeouts: Verify network connectivity and server health
- Request Failures: Debug request format and server compatibility
Session Management Debugging
Session Context Inspection:
class SessionDebugger:
def debug_session_state(self, session_id):
print(f"💾 Session Debug: {session_id}")
# Load session context
context = self._load_session_context(session_id)
print(f" Context size: {len(context)} items")
# Analyze memory usage
memory_usage = self._analyze_memory_usage(context)
print(f" Memory usage: {memory_usage}")
# Check context health
health = self._check_context_health(context)
print(f" Context health: {health}")
# Show recent activities
activities = context.get_recent_activities(limit=10)
for activity in activities:
print(f" {activity.timestamp}: {activity.action}")
# Usage
debugger = SessionDebugger()
debugger.debug_session_state('current-session')
Session Lifecycle Tracing:
# Enable session debugging
export SUPERCLAUDE_DEBUG_SESSIONS=true
# Trace session operations
python -c "
from setup.services.session_manager import SessionManager
manager = SessionManager()
manager.enable_debug_mode()
# Load session with tracing
session = manager.load_session('project-session')
print(session.debug_info())
"
# Check session storage
ls -la ~/.claude/sessions/
cat ~/.claude/sessions/session-metadata.json
Memory Debugging:
class MemoryDebugger:
def debug_memory_usage(self):
print("🧠 Memory Usage Debug:")
# System memory
import psutil
memory = psutil.virtual_memory()
print(f" System memory: {memory.percent}% used")
# SuperClaude memory
sc_memory = self._get_superclaude_memory()
print(f" SuperClaude memory: {sc_memory}")
# Session memory breakdown
sessions = self._get_active_sessions()
for session_id, session in sessions.items():
size = session.get_memory_size()
print(f" {session_id}: {size}")
# Memory leak detection
leaks = self._detect_memory_leaks()
if leaks:
print(f" 🚨 Potential leaks: {leaks}")
Development Testing Patterns
Unit Testing Patterns
Component Testing Pattern:
class TestComponentBase:
"""Base class for component testing"""
@pytest.fixture
def temp_install_dir(self):
"""Provide temporary installation directory"""
temp_dir = Path(tempfile.mkdtemp())
yield temp_dir
shutil.rmtree(temp_dir)
@pytest.fixture
def mock_registry(self):
"""Provide mock component registry"""
registry = ComponentRegistry()
registry.components = {} # Clean state
return registry
class TestAgentComponent(TestComponentBase):
def test_agent_installation(self, temp_install_dir, mock_registry):
"""Test agent component installation"""
# Setup
agent_component = AgentComponent()
# Execute
result = agent_component.install(temp_install_dir)
# Verify
assert result.success
assert (temp_install_dir / 'AGENT_SecurityEngineer.md').exists()
# Verify content
content = (temp_install_dir / 'AGENT_SecurityEngineer.md').read_text()
assert 'security' in content
assert 'vulnerability' in content
Integration Testing Pattern:
class TestComponentIntegration:
def test_full_installation_workflow(self):
"""Test complete installation workflow"""
# Setup clean environment
test_config = self._create_test_config()
# Install core components
installer = InstallationOrchestrator()
result = installer.install_components(['core'], test_config)
assert result.success
assert test_config.install_dir.exists()
# Verify core functionality
claude_md = test_config.install_dir / 'CLAUDE.md'
assert claude_md.exists()
content = claude_md.read_text()
assert '@FLAGS.md' in content
assert '@RULES.md' in content
def test_mcp_integration(self):
"""Test MCP server integration"""
# Install MCP component
mcp_component = MCPComponent()
result = mcp_component.install(self.test_dir)
# Verify MCP configuration
mcp_config = self.test_dir / '.claude.json'
assert mcp_config.exists()
config_data = json.loads(mcp_config.read_text())
assert 'mcpServers' in config_data
assert 'context7' in config_data['mcpServers']
Test-Driven Development Pattern:
# 1. Write test first (Red)
def test_new_agent_activation():
"""Test new data science agent activation"""
agent_system = AgentSystem()
# Should activate on data science keywords
task_context = TaskContext(
input_text="analyze this dataset with pandas",
file_types=['.csv', '.ipynb']
)
selected_agents = agent_system.select_agents(task_context)
assert 'data-scientist' in selected_agents
# 2. Implement minimal code (Green)
class AgentSystem:
def select_agents(self, task_context):
if 'dataset' in task_context.input_text:
return ['data-scientist']
return []
# 3. Refactor (Refactor)
class AgentSystem:
def select_agents(self, task_context):
selected = []
# Data science triggers
data_triggers = ['dataset', 'pandas', 'numpy', 'analytics']
if any(trigger in task_context.input_text for trigger in data_triggers):
selected.append('data-scientist')
return selected
Performance Testing
Performance Testing Methodologies
Memory Performance Testing:
class MemoryPerformanceTest:
def test_memory_usage_limits(self):
"""Test memory usage stays within limits"""
import psutil
import gc
# Baseline memory
gc.collect()
baseline = psutil.Process().memory_info().rss
# Load large session
session_manager = SessionManager()
large_session = session_manager.create_large_test_session()
# Measure memory increase
current = psutil.Process().memory_info().rss
memory_increase = current - baseline
# Assert reasonable memory usage (< 500MB increase)
assert memory_increase < 500 * 1024 * 1024
def test_session_loading_speed(self):
"""Test session loading performance"""
import time
session_manager = SessionManager()
# Create test session with known size
test_session = session_manager.create_test_session(size='large')
# Measure loading time
start_time = time.time()
loaded_session = session_manager.load_session(test_session.id)
load_time = time.time() - start_time
# Assert reasonable load time (< 5 seconds)
assert load_time < 5.0
assert loaded_session.is_valid()
Component Performance Benchmarks:
class ComponentPerformanceBenchmark:
def benchmark_component_installation(self):
"""Benchmark component installation speed"""
import timeit
def install_core():
installer = InstallationOrchestrator()
temp_dir = Path(tempfile.mkdtemp())
installer.install_components(['core'], InstallOptions(install_dir=temp_dir))
shutil.rmtree(temp_dir)
# Run benchmark
execution_time = timeit.timeit(install_core, number=10)
avg_time = execution_time / 10
# Assert reasonable installation time (< 2 seconds average)
assert avg_time < 2.0
def benchmark_agent_selection(self):
"""Benchmark agent selection performance"""
agent_system = AgentSystem()
# Create complex task context
complex_context = TaskContext(
input_text="complex microservices security performance analysis",
file_count=100,
complexity_score=0.9
)
# Measure selection time
start_time = time.time()
selected_agents = agent_system.select_agents(complex_context)
selection_time = time.time() - start_time
# Assert fast selection (< 100ms)
assert selection_time < 0.1
assert len(selected_agents) > 0
Load Testing:
class LoadTest:
def test_concurrent_installations(self):
"""Test concurrent component installations"""
import threading
import concurrent.futures
def install_component(component_name):
installer = InstallationOrchestrator()
temp_dir = Path(tempfile.mkdtemp())
try:
result = installer.install_components([component_name],
InstallOptions(install_dir=temp_dir))
return result.success
finally:
shutil.rmtree(temp_dir)
# Test concurrent installations
components = ['core', 'agents', 'modes', 'mcp']
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
futures = [executor.submit(install_component, comp) for comp in components]
results = [future.result() for future in futures]
# All installations should succeed
assert all(results)
Integration Testing
Component Integration Testing
Multi-Component Workflow Testing:
class TestComponentIntegration:
def test_full_workflow_integration(self):
"""Test complete workflow with multiple components"""
# Install all components
installer = InstallationOrchestrator()
components = ['core', 'agents', 'modes', 'mcp']
result = installer.install_components(components, self.test_config)
assert result.success
# Test agent-mode integration
agent_system = AgentSystem()
mode_system = ModeSystem()
# Complex task requiring multiple agents and modes
task_context = TaskContext(
input_text="analyze security vulnerabilities in microservices architecture",
complexity_score=0.8,
file_count=50
)
# Should activate security-engineer + system-architect + introspection mode
selected_agents = agent_system.select_agents(task_context)
selected_modes = mode_system.select_modes(task_context)
assert 'security-engineer' in selected_agents
assert 'system-architect' in selected_agents
assert 'introspection' in selected_modes
def test_mcp_agent_coordination(self):
"""Test MCP server and agent coordination"""
# Setup MCP servers
mcp_manager = MCPManager()
mcp_manager.connect_server('context7')
mcp_manager.connect_server('sequential')
# Setup agents
agent_system = AgentSystem()
# Task requiring both MCP and agents
task_context = TaskContext(
input_text="implement React authentication with best practices",
domain='frontend'
)
# Should coordinate frontend-architect + security-engineer + context7 + magic
coordination_plan = agent_system.create_coordination_plan(task_context)
assert 'frontend-architect' in coordination_plan.agents
assert 'security-engineer' in coordination_plan.agents
assert 'context7' in coordination_plan.mcp_servers
assert 'magic' in coordination_plan.mcp_servers
End-to-End Workflow Testing:
class TestEndToEndWorkflows:
def test_complete_development_workflow(self):
"""Test complete development workflow simulation"""
# 1. Project initialization
session_manager = SessionManager()
session = session_manager.create_session('test-project')
# 2. Requirements discovery (brainstorming mode)
brainstorm_task = TaskContext(
input_text="build e-commerce platform",
session_id=session.id
)
result = self._execute_task(brainstorm_task)
assert result.mode == 'brainstorming'
assert result.agents == ['system-architect', 'requirements-analyst']
# 3. Implementation planning (task management mode)
planning_task = TaskContext(
input_text="implement user authentication system",
session_id=session.id,
complexity_score=0.7
)
result = self._execute_task(planning_task)
assert result.mode == 'task-management'
assert 'security-engineer' in result.agents
# 4. Code implementation (orchestration mode)
implementation_task = TaskContext(
input_text="create React login components with JWT",
session_id=session.id,
file_count=15
)
result = self._execute_task(implementation_task)
assert result.mode == 'orchestration'
assert 'context7' in result.mcp_servers
assert 'magic' in result.mcp_servers
# 5. Session persistence
session_manager.save_session(session.id)
# 6. Session restoration
restored_session = session_manager.load_session(session.id)
assert restored_session.context_size > 0
assert restored_session.has_memory('authentication-implementation')
Cross-Platform Integration Testing:
class TestCrossPlatformIntegration:
@pytest.mark.parametrize("platform", ["linux", "macos", "windows"])
def test_installation_cross_platform(self, platform):
"""Test installation across different platforms"""
if platform == "windows":
expected_executable = "SuperClaude.exe"
path_separator = "\"
else:
expected_executable = "SuperClaude"
path_separator = "/"
# Platform-specific installation
installer = InstallationOrchestrator()
config = PlatformConfig(platform=platform)
result = installer.install_components(['core'], config)
assert result.success
# Verify platform-specific behavior
install_path = config.install_dir
assert install_path.exists()
# Test executable permissions (Unix-like systems)
if platform != "windows":
executable_path = install_path / "bin" / expected_executable
assert executable_path.exists()
assert os.access(executable_path, os.X_OK)
Debugging Tools & Utilities
Built-in Debugging Tools
SuperClaude Debug Command:
# Comprehensive system diagnostics
SuperClaude debug --comprehensive
# Component-specific debugging
SuperClaude debug --components agents,mcp
# Performance debugging
SuperClaude debug --performance --memory
# Session debugging
SuperClaude debug --sessions --verbose
# MCP server debugging
SuperClaude debug --mcp-servers --trace
Debug Environment Variables:
# Enable debug logging
export SUPERCLAUDE_DEBUG=true
export SUPERCLAUDE_LOG_LEVEL=debug
# Component-specific debugging
export SUPERCLAUDE_DEBUG_AGENTS=true
export SUPERCLAUDE_DEBUG_MODES=true
export SUPERCLAUDE_DEBUG_MCP=true
export SUPERCLAUDE_DEBUG_SESSIONS=true
# Performance debugging
export SUPERCLAUDE_DEBUG_PERFORMANCE=true
export SUPERCLAUDE_DEBUG_MEMORY=true
# MCP communication tracing
export SUPERCLAUDE_TRACE_MCP=true
Development Debugging Utilities:
# setup/utils/debug.py
class DebugUtils:
@staticmethod
def enable_comprehensive_debugging():
"""Enable all debugging features"""
logging.basicConfig(level=logging.DEBUG)
os.environ.update({
'SUPERCLAUDE_DEBUG': 'true',
'SUPERCLAUDE_DEBUG_AGENTS': 'true',
'SUPERCLAUDE_DEBUG_MODES': 'true',
'SUPERCLAUDE_DEBUG_MCP': 'true'
})
@staticmethod
def create_debug_session():
"""Create session with debug instrumentation"""
session = DebugSession()
session.enable_tracing()
session.enable_memory_monitoring()
return session
@staticmethod
def dump_system_state():
"""Dump complete system state for analysis"""
state = {
'components': ComponentRegistry().get_status(),
'agents': AgentSystem().get_status(),
'mcp_servers': MCPManager().get_status(),
'sessions': SessionManager().get_status(),
'memory': MemoryManager().get_usage()
}
with open('debug-system-state.json', 'w') as f:
json.dump(state, f, indent=2)
return state
# Usage in development
if __name__ == "__main__":
DebugUtils.enable_comprehensive_debugging()
state = DebugUtils.dump_system_state()
print(f"System state dumped: {len(state)} components")
Custom Debugging Tools:
class ComponentDebugger:
"""Advanced component debugging and analysis"""
def __init__(self):
self.trace_buffer = []
self.performance_metrics = {}
def trace_component_lifecycle(self, component):
"""Trace complete component lifecycle"""
tracer = ComponentTracer(component)
# Hook into lifecycle events
tracer.on_install = self._trace_install
tracer.on_activate = self._trace_activate
tracer.on_execute = self._trace_execute
tracer.on_deactivate = self._trace_deactivate
return tracer
def analyze_performance_bottlenecks(self):
"""Analyze performance bottlenecks in traces"""
bottlenecks = []
for trace in self.trace_buffer:
if trace.duration > 1.0: # > 1 second
bottlenecks.append({
'component': trace.component,
'operation': trace.operation,
'duration': trace.duration,
'stack_trace': trace.stack_trace
})
return bottlenecks
def generate_debug_report(self):
"""Generate comprehensive debug report"""
report = {
'execution_traces': self.trace_buffer,
'performance_metrics': self.performance_metrics,
'bottlenecks': self.analyze_performance_bottlenecks(),
'memory_usage': self._get_memory_analysis(),
'recommendations': self._generate_recommendations()
}
return report
# Usage
debugger = ComponentDebugger()
tracer = debugger.trace_component_lifecycle(agent_component)
# Execute component operations
agent_component.install(test_dir)
# Generate debug report
report = debugger.generate_debug_report()
Log Analysis Tools:
class LogAnalyzer:
"""Analyze SuperClaude logs for issues and patterns"""
def analyze_installation_logs(self, log_file):
"""Analyze installation logs for failures"""
issues = []
with open(log_file, 'r') as f:
for line_num, line in enumerate(f, 1):
# Check for error patterns
if 'ERROR' in line:
issues.append({
'line': line_num,
'type': 'error',
'message': line.strip()
})
elif 'TIMEOUT' in line:
issues.append({
'line': line_num,
'type': 'timeout',
'message': line.strip()
})
elif 'FAILED' in line:
issues.append({
'line': line_num,
'type': 'failure',
'message': line.strip()
})
return issues
def extract_performance_metrics(self, log_file):
"""Extract performance metrics from logs"""
metrics = {
'component_install_times': {},
'agent_activation_times': {},
'mcp_response_times': {}
}
# Parse log patterns for timing information
# Implementation details...
return metrics
# Usage
analyzer = LogAnalyzer()
issues = analyzer.analyze_installation_logs('~/.claude/logs/installation.log')
metrics = analyzer.extract_performance_metrics('~/.claude/logs/performance.log')
Common Development Issues
Installation & Configuration Issues
Component Installation Failures:
# Issue: Component dependencies not resolved
ERROR: Component 'mcp' requires 'core' but it's not installed
# Solution: Install in dependency order
SuperClaude install --components core mcp --resolve-dependencies
# Issue: Permission denied during installation
ERROR: Permission denied: '/home/user/.claude/CLAUDE.md'
# Solution: Fix permissions
sudo chown -R $USER ~/.claude
chmod 755 ~/.claude
MCP Server Connection Issues:
# Issue: Context7 server fails to start
ERROR: MCP server 'context7' failed to connect
# Debug: Check Node.js and server path
node --version # Should be 16+
which context7 # Verify installation path
# Solution: Reinstall MCP servers
SuperClaude install --components mcp --force
npm install -g @context7/mcp-server
Configuration Conflicts:
# Issue: CLAUDE.md import conflicts
ERROR: Circular import detected: CLAUDE.md -> FLAGS.md -> CLAUDE.md
# Debug: Check import structure
def debug_import_structure():
with open('~/.claude/CLAUDE.md', 'r') as f:
content = f.read()
imports = re.findall(r'@(\w+\.md)', content)
print(f"Imports detected: {imports}")
# Check for circular references
for import_file in imports:
import_path = Path('~/.claude') / import_file
if import_path.exists():
with open(import_path, 'r') as f:
nested_imports = re.findall(r'@(\w+\.md)', f.read())
if 'CLAUDE.md' in nested_imports:
print(f"Warning: Circular import: {import_file} -> CLAUDE.md")
# Solution: Remove circular imports
# Edit problematic files to remove @CLAUDE.md references
Component Development Issues
Agent System Issues:
# Issue: Agent not activating for expected keywords
class AgentActivationDebugger:
def debug_activation_failure(self, input_text, expected_agent):
print(f"Debugging agent activation failure:")
print(f" Input: '{input_text}'")
print(f" Expected: {expected_agent}")
# Check trigger patterns
agent_config = self._get_agent_config(expected_agent)
triggers = agent_config.get('triggers', [])
print(f" Agent triggers: {triggers}")
# Check keyword matching
matches = []
for trigger in triggers:
if trigger.lower() in input_text.lower():
matches.append(trigger)
print(f" Matched triggers: {matches}")
if not matches:
print(" No triggers matched - consider adding new keywords")
# Suggest new triggers
suggestions = self._suggest_triggers(input_text)
print(f" Suggested triggers: {suggestions}")
return matches
# Usage
debugger = AgentActivationDebugger()
debugger.debug_activation_failure("implement secure login", "security-engineer")
Mode Selection Issues:
# Issue: Wrong behavioral mode activated
class ModeSelectionDebugger:
def debug_mode_selection(self, task_context):
print("Mode selection debug:")
# Analyze complexity score
complexity = self._calculate_complexity(task_context)
print(f" Complexity score: {complexity}")
# Check mode thresholds
mode_thresholds = {
'brainstorming': 0.2,
'task_management': 0.6,
'orchestration': 0.8,
'introspection': 0.5 # Special conditions
}
for mode, threshold in mode_thresholds.items():
if complexity >= threshold:
print(f" {mode}: {complexity} >= {threshold}")
else:
print(f" {mode}: {complexity} < {threshold}")
# Check special conditions
special_triggers = self._check_special_triggers(task_context)
print(f" Special triggers: {special_triggers}")
return self._select_final_mode(complexity, special_triggers)
# Usage
context = TaskContext(
input_text="fix authentication bug",
file_count=5,
error_present=True
)
debugger = ModeSelectionDebugger()
selected_mode = debugger.debug_mode_selection(context)
Issue Escalation & Resolution Process
Development Issue Classification:
class IssueClassifier:
SEVERITY_LEVELS = {
'critical': {
'description': 'System unusable, data loss risk',
'examples': ['Installation completely fails', 'Session data corruption'],
'response_time': '2 hours',
'escalation': 'immediate'
},
'high': {
'description': 'Major functionality broken',
'examples': ['MCP servers not connecting', 'Agent system not activating'],
'response_time': '24 hours',
'escalation': 'next business day'
},
'medium': {
'description': 'Feature partially working',
'examples': ['Some agents not activating', 'Performance degradation'],
'response_time': '1 week',
'escalation': 'weekly review'
},
'low': {
'description': 'Minor issues or enhancements',
'examples': ['Documentation improvements', 'Edge case handling'],
'response_time': '1 month',
'escalation': 'monthly review'
}
}
def classify_issue(self, issue_description):
"""Classify issue severity based on description"""
description_lower = issue_description.lower()
# Critical indicators
critical_keywords = ['data loss', 'corruption', 'completely broken', 'system unusable']
if any(keyword in description_lower for keyword in critical_keywords):
return 'critical'
# High severity indicators
high_keywords = ['not working', 'major failure', 'broken functionality']
if any(keyword in description_lower for keyword in high_keywords):
return 'high'
# Medium severity indicators
medium_keywords = ['performance', 'slow', 'partially working']
if any(keyword in description_lower for keyword in medium_keywords):
return 'medium'
return 'low'
# Usage
classifier = IssueClassifier()
severity = classifier.classify_issue("MCP servers not connecting after installation")
print(f"Issue severity: {severity}")
print(f"Response expectation: {classifier.SEVERITY_LEVELS[severity]['response_time']}")
Development Support Workflow:
# Step 1: Self-diagnosis
SuperClaude debug --comprehensive > debug-report.txt
# Step 2: Check common issues
python -c "
from setup.utils.troubleshooter import AutoTroubleshooter
troubleshooter = AutoTroubleshooter()
solutions = troubleshooter.suggest_solutions('mcp server connection failed')
for solution in solutions:
print(f'Solution: {solution}')
"
# Step 3: Community support
# Search existing issues: https://github.com/SuperClaude-Org/SuperClaude_Framework/issues
# Join discussions: https://github.com/SuperClaude-Org/SuperClaude_Framework/discussions
# Step 4: Create detailed issue report
# Include:
# - SuperClaude version: SuperClaude --version
# - System info: uname -a
# - Python version: python --version
# - Debug report: debug-report.txt
# - Steps to reproduce
# - Expected vs actual behavior
Quality Assurance
Quality Assurance Processes
Pre-Development Quality Gates:
class PreDevelopmentQA:
def validate_requirements(self, requirements):
"""Validate requirements before development starts"""
validations = {
'completeness': self._check_completeness(requirements),
'testability': self._check_testability(requirements),
'consistency': self._check_consistency(requirements),
'feasibility': self._check_feasibility(requirements)
}
return all(validations.values()), validations
def _check_completeness(self, requirements):
"""Check if requirements are complete"""
required_sections = ['purpose', 'acceptance_criteria', 'dependencies']
return all(section in requirements for section in required_sections)
def _check_testability(self, requirements):
"""Check if requirements are testable"""
# Requirements should have measurable outcomes
return 'acceptance_criteria' in requirements and len(requirements['acceptance_criteria']) > 0
# Usage
qa = PreDevelopmentQA()
requirements = {
'purpose': 'Add new security agent',
'acceptance_criteria': ['Agent activates on security keywords', 'Integrates with MCP servers'],
'dependencies': ['core', 'agents']
}
is_valid, details = qa.validate_requirements(requirements)
Development Quality Gates:
class DevelopmentQA:
def validate_component(self, component_path):
"""Comprehensive component validation"""
validations = {
'code_quality': self._check_code_quality(component_path),
'test_coverage': self._check_test_coverage(component_path),
'documentation': self._check_documentation(component_path),
'integration': self._check_integration(component_path),
'performance': self._check_performance(component_path)
}
score = sum(validations.values()) / len(validations)
return score >= 0.8, validations, score
def _check_code_quality(self, component_path):
"""Check code quality metrics"""
# Run linting and complexity analysis
lint_score = self._run_linter(component_path)
complexity_score = self._check_complexity(component_path)
return (lint_score + complexity_score) / 2
def _check_test_coverage(self, component_path):
"""Check test coverage percentage"""
coverage_report = self._run_coverage_analysis(component_path)
return coverage_report.percentage / 100
def _check_documentation(self, component_path):
"""Check documentation completeness"""
# Verify docstrings, README, examples
has_docstrings = self._check_docstrings(component_path)
has_readme = self._check_readme(component_path)
has_examples = self._check_examples(component_path)
return (has_docstrings + has_readme + has_examples) / 3
# Usage
qa = DevelopmentQA()
passes_qa, details, score = qa.validate_component('setup/components/new_agent.py')
print(f"QA Score: {score:.2f}")
Integration Quality Gates:
class IntegrationQA:
def validate_integration(self, component_name):
"""Validate component integration with framework"""
integration_tests = {
'installation': self._test_installation(component_name),
'activation': self._test_activation(component_name),
'coordination': self._test_coordination(component_name),
'compatibility': self._test_compatibility(component_name),
'rollback': self._test_rollback(component_name)
}
passing_tests = sum(integration_tests.values())
total_tests = len(integration_tests)
return passing_tests == total_tests, integration_tests
def _test_installation(self, component_name):
"""Test component installs correctly"""
try:
installer = TestInstaller()
result = installer.install_component(component_name, dry_run=True)
return result.success
except Exception:
return False
def _test_activation(self, component_name):
"""Test component activates correctly"""
try:
registry = ComponentRegistry()
component = registry.get_component(component_name)
return component.can_activate()
except Exception:
return False
# Usage
qa = IntegrationQA()
passes_integration, test_results = qa.validate_integration('security_agent')
Code Review Criteria
Automated Code Review Checklist:
class CodeReviewBot:
def __init__(self):
self.review_criteria = {
'style': {
'weight': 0.2,
'checks': ['pep8_compliance', 'naming_conventions', 'imports_organized']
},
'functionality': {
'weight': 0.3,
'checks': ['methods_work', 'error_handling', 'edge_cases']
},
'testing': {
'weight': 0.25,
'checks': ['unit_tests', 'integration_tests', 'coverage_80_plus']
},
'documentation': {
'weight': 0.15,
'checks': ['docstrings', 'type_hints', 'examples']
},
'integration': {
'weight': 0.1,
'checks': ['framework_compatibility', 'backwards_compatible']
}
}
def review_pull_request(self, pr_path):
"""Automated pull request review"""
results = {}
total_score = 0
for category, config in self.review_criteria.items():
category_score = 0
category_results = {}
for check in config['checks']:
check_result = self._run_check(check, pr_path)
category_results[check] = check_result
category_score += check_result
category_score = category_score / len(config['checks'])
results[category] = {
'score': category_score,
'details': category_results
}
total_score += category_score * config['weight']
return total_score, results
def _run_check(self, check_name, pr_path):
"""Run individual code review check"""
check_methods = {
'pep8_compliance': self._check_pep8,
'naming_conventions': self._check_naming,
'unit_tests': self._check_unit_tests,
'coverage_80_plus': self._check_coverage,
'docstrings': self._check_docstrings,
'framework_compatibility': self._check_framework_compat
}
check_method = check_methods.get(check_name, lambda x: 0.5)
return check_method(pr_path)
# Usage
reviewer = CodeReviewBot()
score, details = reviewer.review_pull_request('pull_requests/add-data-scientist-agent')
print(f"Review Score: {score:.2f}")
if score >= 0.8:
print("✅ Pull request meets quality standards")
else:
print("❌ Pull request needs improvement")
for category, result in details.items():
if result['score'] < 0.7:
print(f" Improve {category}: {result['score']:.2f}")
Human Code Review Guidelines:
class HumanReviewGuidelines:
REVIEW_CHECKLIST = {
'architecture': [
'Does the component follow SuperClaude patterns?',
'Is the component properly integrated with the registry?',
'Are dependencies clearly defined and minimal?',
'Does it follow the single responsibility principle?'
],
'security': [
'Are user inputs validated and sanitized?',
'Is sensitive information properly handled?',
'Are file operations secure (no path traversal)?',
'Are external commands properly escaped?'
],
'performance': [
'Are there any obvious performance bottlenecks?',
'Is memory usage reasonable?',
'Are there unnecessary loops or operations?',
'Is caching used appropriately?'
],
'maintainability': [
'Is the code readable and well-organized?',
'Are complex operations properly documented?',
'Are magic numbers and strings avoided?',
'Is error handling comprehensive?'
],
'testing': [
'Are all public methods tested?',
'Are edge cases covered?',
'Are integration points tested?',
'Is test data realistic and comprehensive?'
]
}
def generate_review_template(self, component_type):
"""Generate review template based on component type"""
base_template = "## Code Review Checklist
"
for category, questions in self.REVIEW_CHECKLIST.items():
base_template += f"### {category.title()}
"
for question in questions:
base_template += f"- [ ] {question}
"
base_template += "
"
# Add component-specific considerations
if component_type == 'agent':
base_template += "### Agent-Specific
"
base_template += "- [ ] Trigger patterns are comprehensive
"
base_template += "- [ ] Agent coordination is properly implemented
"
base_template += "- [ ] MCP server integration works correctly
"
elif component_type == 'mode':
base_template += "### Mode-Specific
"
base_template += "- [ ] Activation conditions are clear and correct
"
base_template += "- [ ] Mode behavior is well-defined
"
base_template += "- [ ] Interaction with other modes is handled
"
base_template += "## Overall Assessment
"
base_template += "- [ ] Ready to merge
"
base_template += "- [ ] Needs minor changes
"
base_template += "- [ ] Needs major changes
"
base_template += "- [ ] Needs redesign
"
return base_template
# Usage
guidelines = HumanReviewGuidelines()
review_template = guidelines.generate_review_template('agent')
print(review_template)
Quality Standards & Metrics
Quality Metrics Dashboard:
class QualityMetrics:
def __init__(self):
self.metrics = {
'code_coverage': {'target': 90, 'current': 0},
'complexity_score': {'target': 7, 'current': 0}, # Cyclomatic complexity
'documentation_coverage': {'target': 95, 'current': 0},
'integration_test_pass': {'target': 100, 'current': 0},
'performance_benchmark': {'target': 100, 'current': 0} # % of baseline
}
def collect_metrics(self, component_path):
"""Collect all quality metrics for a component"""
self.metrics['code_coverage']['current'] = self._measure_coverage(component_path)
self.metrics['complexity_score']['current'] = self._measure_complexity(component_path)
self.metrics['documentation_coverage']['current'] = self._measure_docs(component_path)
self.metrics['integration_test_pass']['current'] = self._measure_integration(component_path)
self.metrics['performance_benchmark']['current'] = self._measure_performance(component_path)
return self.metrics
def generate_quality_report(self):
"""Generate comprehensive quality report"""
report = "# Quality Metrics Report
"
overall_score = 0
total_weight = 0
for metric_name, metric_data in self.metrics.items():
target = metric_data['target']
current = metric_data['current']
# Calculate score (0-100)
if metric_name == 'complexity_score':
# Lower is better for complexity
score = max(0, 100 - (current - target) * 10) if current > target else 100
else:
# Higher is better for other metrics
score = min(100, (current / target) * 100)
status = "✅" if score >= 80 else "⚠️" if score >= 60 else "❌"
report += f"## {metric_name.replace('_', ' ').title()}
"
report += f"{status} **Score: {score:.1f}/100**
"
report += f"- Target: {target}
"
report += f"- Current: {current}
"
overall_score += score
total_weight += 1
overall_score = overall_score / total_weight
overall_status = "✅" if overall_score >= 80 else "⚠️" if overall_score >= 60 else "❌"
report += f"## Overall Quality Score
"
report += f"{overall_status} **{overall_score:.1f}/100**
"
return report, overall_score
# Usage
metrics = QualityMetrics()
component_metrics = metrics.collect_metrics('setup/components/agents.py')
report, score = metrics.generate_quality_report()
print(report)
Continuous Quality Monitoring:
class QualityMonitor:
def __init__(self):
self.quality_history = []
self.alerts = []
def monitor_quality_trends(self, component_path):
"""Monitor quality trends over time"""
current_metrics = QualityMetrics().collect_metrics(component_path)
# Add timestamp
current_metrics['timestamp'] = datetime.now()
self.quality_history.append(current_metrics)
# Check for quality degradation
if len(self.quality_history) >= 2:
self._check_degradation_alerts()
return current_metrics
def _check_degradation_alerts(self):
"""Check for quality degradation and generate alerts"""
current = self.quality_history[-1]
previous = self.quality_history[-2]
for metric_name in current.keys():
if metric_name == 'timestamp':
continue
current_value = current[metric_name]['current']
previous_value = previous[metric_name]['current']
# Check for significant degradation (>10% drop)
if current_value < previous_value * 0.9:
alert = {
'type': 'quality_degradation',
'metric': metric_name,
'previous': previous_value,
'current': current_value,
'degradation': ((previous_value - current_value) / previous_value) * 100,
'timestamp': current['timestamp']
}
self.alerts.append(alert)
def generate_quality_dashboard(self):
"""Generate quality dashboard HTML"""
# Implementation would generate interactive dashboard
# showing quality trends, alerts, and recommendations
pass
# Usage
monitor = QualityMonitor()
current_quality = monitor.monitor_quality_trends('setup/components/core.py')
if monitor.alerts:
print("🚨 Quality Alerts:")
for alert in monitor.alerts:
print(f" {alert['metric']}: {alert['degradation']:.1f}% degradation")
Related Resources
Essential Development Resources
Core Documentation:
- Technical Architecture - Framework design and patterns
- Contributing Code - Development setup and guidelines
- Best Practices - Optimization and quality standards
Testing Resources:
- Examples Cookbook - Practical testing examples
- Troubleshooting Guide - Common issues and solutions
Component Development:
- Agents Guide - Agent system development
- Modes Guide - Behavioral mode development
- MCP Servers - MCP integration development
External Testing Tools
Python Testing Ecosystem:
# Core testing tools
pip install pytest pytest-cov pytest-mock pytest-benchmark
# Performance testing
pip install memory-profiler py-spy
# Code quality
pip install flake8 black isort mypy
# Coverage visualization
pip install coverage[toml] pytest-html
Testing Frameworks Integration:
# pytest configuration (conftest.py)
import pytest
import tempfile
import shutil
from pathlib import Path
@pytest.fixture(scope="session")
def test_environment():
"""Set up test environment for SuperClaude testing"""
test_dir = Path(tempfile.mkdtemp(prefix="superclaude_test_"))
# Setup test configuration
os.environ['SUPERCLAUDE_TEST_MODE'] = 'true'
os.environ['SUPERCLAUDE_CONFIG_DIR'] = str(test_dir)
yield test_dir
# Cleanup
shutil.rmtree(test_dir)
os.environ.pop('SUPERCLAUDE_TEST_MODE', None)
os.environ.pop('SUPERCLAUDE_CONFIG_DIR', None)
@pytest.fixture
def mock_mcp_servers():
"""Mock MCP servers for testing"""
from unittest.mock import Mock
mock_servers = {
'context7': Mock(),
'sequential': Mock(),
'magic': Mock()
}
# Configure mock responses
mock_servers['context7'].query.return_value = {'status': 'success'}
mock_servers['sequential'].analyze.return_value = {'complexity': 0.7}
return mock_servers
CI/CD Integration:
# .github/workflows/test.yml
name: SuperClaude Tests
on: [push, pull_request]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.8, 3.9, 3.10, 3.11]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run tests
run: |
pytest tests/ --cov=setup --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
Community Resources
Development Community:
- GitHub Discussions - Technical discussions
- GitHub Issues - Bug reports and feature requests
- Contributing Guidelines - Contribution process
Learning Resources:
- Quick Start Guide - Framework overview
- Installation Guide - Setup instructions
- Commands Reference - Usage examples
Advanced Topics:
- Session Management - Persistent workflows
- Flags Guide - Behavioral control
- Technical Roadmap - Future development
Development Support: For testing and debugging assistance, join our community discussions or create an issue with detailed reproduction steps and system information.