@endgame-build/claude-workflows
Version:
Claude Code workflow system with commands, agents, and templates for AI-native development
136 lines (106 loc) • 3.74 kB
Markdown
description: Perform deep analysis of code, architecture, or system behavior
argument-hint: <scope> <specific focus area or question>
# /eg:analyze
You are tasked with performing deep analysis of code, architecture, or system behavior, including code quality metrics, performance characteristics, security assessment, and architectural compliance.
Input: `$ARGUMENTS`
## Step 1: Parse Arguments
Parse the arguments to extract:
- Scope (first word - e.g., "codebase", "module:auth", "file:src/api.js", "security", "performance")
- Focus area or question (everything after first space)
## Step 2: Determine Analysis Type
Based on scope and focus:
- `codebase`: Analyze entire project
- `module:<name>`: Focus on specific module/package
- `file:<path>`: Analyze specific file(s)
- `security`: Security-focused analysis
- `performance`: Performance-focused analysis
- `architecture`: Architectural analysis
## Step 3: Perform Analysis
Use appropriate tools based on analysis type:
```
# For code quality analysis
!find . -name "*.js" -o -name "*.ts" -o -name "*.py" | wc -l # Count files
!cloc . 2>/dev/null || echo "cloc not installed" # Lines of code
# For dependency analysis
!if [ -f "package.json" ]; then
npm list --depth=0 2>/dev/null | grep -E "(UNMET|PEER)" || echo "No dependency issues"
fi
# For security quick scan
!grep -r "password\|secret\|api_key" --include="*.js" --include="*.env*" . 2>/dev/null | head -20
```
Invoke analysis tools:
```
Task(
description="Perform {analysis-type} analysis",
prompt=`
Perform deep {analysis-type} analysis on {scope}
Focus on: {focus-area}
Analysis areas based on type:
Code Quality:
- Complexity metrics (cyclomatic, cognitive)
- Code duplication
- Technical debt
- Maintainability
- Test coverage gaps
Performance:
- Algorithm complexity (Big O)
- Database query patterns
- Memory usage patterns
- Potential bottlenecks
- Caching opportunities
Security:
- Common vulnerabilities (OWASP Top 10)
- Authentication/authorization
- Input validation
- Dependency vulnerabilities
- Secret management
Architecture:
- Design pattern compliance
- Module coupling and cohesion
- Dependency direction
- Layer separation
- SOLID principles
Provide:
- Executive summary
- Key findings with severity
- Specific code examples
- Actionable recommendations
- Metrics where applicable
`,
subagent_type="general-purpose"
)
```
## Step 4: Generate Report
Create structured analysis report using the template:
```
Task(
description="Generate analysis report",
prompt=`
Create a comprehensive analysis report based on the findings.
Use the analysis template from .claude/templates/analysis.template.md
Include:
- Executive summary of findings
- Key metrics (files, LOC, complexity, debt)
- Categorized findings (strengths, improvements, critical issues)
- Detailed analysis by category (architecture, quality, performance, security)
- Prioritized recommendations (immediate, short-term, long-term)
- Implementation roadmap with timeline
Ensure all findings are:
- Evidence-based with specific examples
- Actionable with clear next steps
- Prioritized by impact and effort
Save the report to: analysis-report-$(date +%Y%m%d-%H%M%S).md
`,
subagent_type="summarizer"
)
```
## Step 5: Provide Summary
Summarize findings with:
- Overall assessment
- Top 3-5 critical issues
- Quick wins for improvement
- Long-term recommendations
- Suggested follow-up commands
The analysis should be actionable and prioritized for maximum impact.