5.1 KiB
5.1 KiB
description, allowed-tools, argument-hint
| description | allowed-tools | argument-hint | |
|---|---|---|---|
| Perform comprehensive code analysis including complexity, dependencies, and quality metrics | Read(*), Grep(*), Glob(*), Bash(*) |
|
Analyze Command
Perform comprehensive code analysis on the specified path or current directory.
Technology Adaptation
Configuration Source: CLAUDE.md
Consult CLAUDE.md for:
- Analysis Tools: (SonarQube, ESLint, Pylint, Roslyn Analyzers, etc.)
- Quality Metrics: Project-specific thresholds
- Package Manager: For dependency analysis
Instructions
-
Determine Scope
- If $ARGUMENTS provided: Analyze that specific path
- Otherwise: Analyze entire project
-
Load Previous Analysis Lessons ⚠️ IMPORTANT
- Use Serena MCP
list_memoriesto see past analysis results - Use
read_memoryto load relevant findings:"analysis-*"- Previous analysis reports"lesson-analysis-*"- Past analysis insights"pattern-*"- Known patterns in the codebase
- Compare current state with past analysis to identify trends
- Apply lessons learned from previous analyses
- Use Serena MCP
-
Gather Context
- Read CLAUDE.md for project structure and quality standards
- Identify primary language(s) from CLAUDE.md
- Use serena MCP to get codebase overview
-
Perform Analysis
- Code Complexity: Identify complex functions/classes
- Dependencies: Check for outdated or vulnerable packages
- Code Duplication: Find repeated code patterns
- Test Coverage: Assess test coverage (if tests exist)
- Code Style: Check against CLAUDE.md standards
- Documentation: Assess documentation completeness
- Compare with past analysis to identify improvements or regressions
-
Generate Report
- Summarize findings by category
- Highlight top issues to address
- Provide actionable recommendations
- Reference CLAUDE.md standards
MCP Server Usage
Serena MCP
Code Navigation:
get_symbols_overview- Analyze file structure and complexityfind_symbol- Locate specific components for detailed analysisfind_referencing_symbols- Understand dependencies and couplingsearch_for_pattern- Find code duplication and patterns
Persistent Memory (stored in .serena/memories/):
- Use
write_memoryto store analysis results:- "analysis-code-complexity-[date]"
- "analysis-dependencies-[date]"
- "analysis-technical-debt-[date]"
- "pattern-complexity-hotspots"
- Use
read_memoryto compare with past analyses and track trends - Use
list_memoriesto view analysis history
Memory MCP (Knowledge Graph)
Temporary Context (in-memory, cleared after session):
- Use
create_entitiesfor components being analyzed - Use
create_relationsto map dependencies and relationships - Use
add_observationsto document findings and metrics
Note: After analysis completes, store summary in Serena memory.
Context7 MCP
- Use
get-library-docsfor best practices and quality standards for the tech stack
Output Format
## Analysis Report
### Project: [Name]
**Analyzed**: [Path]
**Date**: [Current date]
### Summary
- **Total Files**: [count]
- **Languages**: [from CLAUDE.md]
- **Lines of Code**: [estimate]
### Quality Metrics
- **Code Complexity**: [High/Medium/Low]
- **Test Coverage**: [percentage if available]
- **Documentation**: [Good/Fair/Poor]
### Key Findings
#### 🔴 Critical Issues
1. [Issue with location and fix]
#### 🟡 Warnings
1. [Warning with recommendation]
#### 💡 Suggestions
1. [Improvement idea]
### Dependencies
- **Total Dependencies**: [count]
- **Outdated**: [list if any]
- **Vulnerabilities**: [list if any]
### Code Complexity
**Most Complex Files**:
1. [file]: [complexity score]
2. [file]: [complexity score]
### Recommendations
1. [Priority action 1]
2. [Priority action 2]
3. [Priority action 3]
### Next Steps
- [ ] Address critical issues
- [ ] Update dependencies
- [ ] Improve test coverage
- [ ] Refactor complex code
### Lessons Learned 📚
**Document key insights from this analysis:**
- What patterns or anti-patterns were most prevalent?
- What areas of technical debt need attention?
- What quality metrics should be tracked going forward?
- What process improvements could prevent similar issues?
**Save to Serena Memory?**
After completing the analysis, ask the user:
> "I've identified several lessons learned from this code analysis. Would you like me to save these insights to Serena memory for future reference? This will help track technical debt and maintain code quality over time."
If user agrees, use Serena MCP `write_memory` to store:
- `"analysis-[category]-[date]"` (e.g., "analysis-code-complexity-2025-10-20")
- `"lesson-analysis-[topic]-[date]"` (e.g., "lesson-analysis-dependency-management-2025-10-20")
- Include: What was analyzed, findings, trends, recommendations, and action items
Guidelines
- Always provide actionable recommendations
- Prioritize findings by impact and effort
- Reference CLAUDE.md standards throughout
- Use MCP servers for deep analysis
- Compare current analysis with past analyses from Serena memory to track trends