Analyze codebase for anti-patterns, code smells, and quality issues using ast-grep
Analyzes codebase for anti-patterns, code smells, and quality issues using ast-grep
/plugin marketplace add laurigates/claude-plugins/plugin install code-quality-plugin@lgates-claude-plugins[PATH] [--focus <category>] [--severity <level>]code/echo "${1:-.}"find ${1:-.} -type f \( -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" -o -name "*.vue" -o -name "*.py" \) 2>/dev/null | head -5 | xargs -I {} basename {} | sed 's/.*\.//' | sort -u | tr '\n' ' 'find ${1:-.} -type f \( -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" -o -name "*.vue" -o -name "*.py" \) 2>/dev/null | wc -lfind ${1:-.} -name "*.vue" 2>/dev/null | head -1 | grep -q . && echo "yes" || echo "no"grep -r "from 'react'" ${1:-.} 2>/dev/null | head -1 | grep -q . && echo "yes" || echo "no"find ${1:-.} -name "*.py" 2>/dev/null | head -1 | grep -q . && echo "yes" || echo "no"Perform comprehensive anti-pattern analysis using ast-grep and parallel agent delegation.
Based on the detected languages, analyze for these categories:
JavaScript/TypeScript Anti-patterns
Async/Promise Patterns
Framework-Specific (if detected)
TypeScript Quality (if .ts files present)
any types, non-null assertions, type safety issuesCode Complexity
Security Concerns
Memory & Performance
Python Anti-patterns (if detected)
CRITICAL: Use parallel agent delegation for efficiency.
Launch multiple specialized agents simultaneously:
## Agent 1: Language Detection & Setup (Explore - quick)
Detect project stack, identify file patterns, establish analysis scope
## Agent 2: JavaScript/TypeScript Analysis (code-analysis)
- Use ast-grep for structural pattern matching
- Focus on: empty catch, magic values, var usage, deprecated patterns
## Agent 3: Async/Promise Analysis (code-analysis)
- Unhandled promises, nested callbacks, floating promises
- Promise constructor anti-pattern
## Agent 4: Framework-Specific Analysis (code-analysis)
- Vue: props mutation, reactivity issues
- React: hooks dependencies, inline functions
## Agent 5: Security Analysis (security-audit)
- eval, innerHTML, hardcoded secrets, injection risks
- Use OWASP context
## Agent 6: Complexity Analysis (code-analysis)
- Function length, nesting depth, parameter counts
- Cyclomatic complexity indicators
Use these patterns during analysis:
# Empty catch blocks
ast-grep -p 'try { $$$ } catch ($E) { }' --lang js
# Magic numbers
ast-grep -p 'if ($VAR > 100)' --lang js
# Console statements
ast-grep -p 'console.log($$$)' --lang js
# var usage
ast-grep -p 'var $VAR = $$$' --lang js
# TypeScript any
ast-grep -p ': any' --lang ts
ast-grep -p 'as any' --lang ts
# Vue props mutation
ast-grep -p 'props.$PROP = $VALUE' --lang js
# Security: eval
ast-grep -p 'eval($$$)' --lang js
# Security: innerHTML
ast-grep -p '$ELEM.innerHTML = $$$' --lang js
# Python: mutable defaults
ast-grep -p 'def $FUNC($ARG=[])' --lang py
Consolidate findings into this structure:
## Anti-pattern Analysis Report
### Summary
- Total issues: X
- Critical: X | High: X | Medium: X | Low: X
- Categories with most issues: [list]
### Critical Issues (Fix Immediately)
| File | Line | Issue | Category |
|------|------|-------|----------|
| ... | ... | ... | ... |
### High Priority Issues
| File | Line | Issue | Category |
|------|------|-------|----------|
| ... | ... | ... | ... |
### Medium Priority Issues
[Similar table]
### Low Priority / Style Issues
[Similar table or summary count]
### Recommendations
1. [Prioritized fix recommendations]
2. [...]
### Category Breakdown
- **Security**: X issues (details)
- **Async/Promises**: X issues (details)
- **Code Complexity**: X issues (details)
- [...]
--focus <category>: Focus on specific category (security, async, complexity, framework)--severity <level>: Minimum severity to report (critical, high, medium, low)--fix: Attempt automated fixes where safeAfter consolidating findings:
code-antipatterns-analysis - Pattern library and detailed guidanceast-grep-search - ast-grep usage reference/code:review - Comprehensive code reviewsecurity-audit - Deep security analysiscode-refactoring - Automated refactoring