Analyze codebase (or specific section) for complexity and consistency using 5 specialized sub-agents. Each agent performs 3 iterative passes to identify and suggest simplifications while maintaining alignment with existing patterns.
Uses 5 specialized agents running in parallel to analyze your codebase for complexity, duplication, and inconsistencies. Each agent performs 3 iterative passes to identify simplification opportunities while preserving existing patterns. Generates a comprehensive report with prioritized refactoring recommendations and before/after code examples.
/plugin marketplace add aaronmaturen/claude-plugin/plugin install atm@aaronmaturen-pluginsAnalyze codebase (or specific section) for complexity and consistency using 5 specialized sub-agents. Each agent performs 3 iterative passes to identify and suggest simplifications while maintaining alignment with existing patterns.
Target Path: $ARGUMENTS (defaults to current directory)
Ensures code follows established patterns in the codebase.
Pass 1 - Pattern Discovery:
Pass 2 - Deviation Detection:
Pass 3 - Standardization Proposals:
Identifies and reduces unnecessary complexity.
Pass 1 - Complexity Metrics:
Pass 2 - Simplification Opportunities:
Pass 3 - Refactoring Recommendations:
Eliminates code duplication and promotes reusability.
Pass 1 - Duplication Detection:
Pass 2 - Abstraction Opportunities:
Pass 3 - Consolidation Plan:
Ensures appropriate levels of abstraction.
Pass 1 - Abstraction Analysis:
Pass 2 - Simplification Targets:
Pass 3 - De-abstraction Proposals:
Optimizes dependencies and coupling.
Pass 1 - Dependency Analysis:
Pass 2 - Optimization Opportunities:
Pass 3 - Restructuring Plan:
Create report structure:
REPORT_BASE="${REPORT_BASE:-$HOME/Documents/technical-analysis}"
PROJECT_NAME=$(basename $(git rev-parse --show-toplevel 2>/dev/null) || echo "unknown")
PARENT_DIR=$(basename $(dirname $(git rev-parse --show-toplevel 2>/dev/null)) || echo "projects")
DATE=$(date +%Y-%m-%d-%H%M)
REPORT_DIR="${REPORT_BASE}/code-analysis/${PARENT_DIR}/${PROJECT_NAME}"
mkdir -p "$REPORT_DIR"
REPORT_FILE="${REPORT_DIR}/simplification-analysis-${DATE}.md"
Report template:
# Code Simplification Analysis
**Date:** [Current Date]
**Analyzer:** Claude Simplification Framework
**Target Path:** [Path]
## Executive Summary
### Complexity Score: [Score]/100
**Current State:** [Complex|Moderate|Simple]
### Key Findings
- š **Patterns:** [X] inconsistencies found
- š **Duplication:** [X]% code duplication
- š **Complexity:** Average cyclomatic complexity: [X]
- š **Dependencies:** [X] circular dependencies
- šļø **Abstractions:** [X] over-engineered components
## Agent Analysis Results
### 1. Pattern Consistency Analysis
#### Established Patterns
- **Naming:** camelCase for functions, PascalCase for classes
- **Structure:** [Pattern description]
#### Inconsistencies Found
| File | Pattern Violation | Severity | Fix |
|------|------------------|----------|-----|
| file.ts:42 | snake_case function | Medium | Rename to camelCase |
### 2. Code Complexity Analysis
#### High Complexity Functions
| Function | Complexity | Lines | Recommendation |
|----------|------------|-------|----------------|
| processData() | 15 | 120 | Split into 3 functions |
#### Simplification Examples
```typescript
// Before (Complexity: 8)
function processUser(user) {
if (user) {
if (user.active) {
if (user.role === 'admin') {
// ...
}
}
}
}
// After (Complexity: 3)
function processUser(user) {
if (!user?.active) return;
if (user.role !== 'admin') return;
// ...
}
// Found in 5 locations
const validateEmail = (email) => {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(email);
};
// Recommendation: Extract to utils/validators.ts
graph LR
A[moduleA] --> B[moduleB]
B --> C[moduleC]
C --> A
| Metric | Current | Target | Improvement |
|---|---|---|---|
| Avg Complexity | 8.2 | 4.0 | 51% |
| Code Duplication | 18% | 5% | 72% |
| Bundle Size | 4.2MB | 3.1MB | 26% |
| Test Coverage | 67% | 85% | +18% |
[Specific examples with before/after]
[Specific examples with before/after]
[Specific examples with before/after]
Generated by Claude Simplification Framework Next Analysis Recommended: [Date + 1 month]
Initialize Analysis:
echo "Starting code simplification analysis..."
TARGET="${ARGUMENTS:-.}"
Run All Agents in Parallel:
Launch 5 concurrent sub-agents:
- Pattern Consistency Agent
- Code Complexity Agent
- DRY Principle Agent
- Abstraction Level Agent
- Dependency Simplification Agent
Each agent independently performs:
Pass 1: Analyze and collect data
Pass 2: Identify opportunities
Pass 3: Generate recommendations
Aggregate Results:
Save Report:
Command: atm-simplify
# or
Command: atm-simplify src/components
Output:
Running simplification analysis...
Launching 5 agents in parallel...
[Parallel Execution]
āā Pattern Consistency Agent: Analyzing...
āā Code Complexity Agent: Analyzing...
āā DRY Principle Agent: Analyzing...
āā Abstraction Level Agent: Analyzing...
āā Dependency Agent: Analyzing...
ā All agents completed (elapsed: 12.3s)
Results Summary:
ā Pattern Consistency Agent: Found 23 inconsistencies
ā Code Complexity Agent: Identified 8 high-complexity functions
ā DRY Principle Agent: Detected 18% code duplication
ā Abstraction Level Agent: Found 5 over-engineered components
ā Dependency Agent: Discovered 3 circular dependencies
Aggregating findings...
Generating simplification report...
ā Report saved to: ~/Documents/technical-analysis/code-analysis/projects/project/simplification-analysis-2024-01-15.md
Summary:
- Complexity Score: 72/100 (Moderate)
- Potential code reduction: ~1,200 lines
- Bundle size reduction: 1.1MB
- 15 high-priority simplifications identified
View full report for detailed recommendations.