A Claude Code slash command for performance profiling and optimization suggestions.
# Clone to your preferred location
git clone git@github.com:claude-commands/command-profile.git <clone-path>/command-profile
# Symlink (use full path to cloned repo)
ln -s <clone-path>/command-profile/profile.md ~/.claude/commands/profile.md/profile # Find performance issues in project
/profile src/api/users.ts # Profile specific file
/profile handleRequest # Profile specific function
/profile --memory # Focus on memory usage
/profile --cpu # Focus on CPU hotspots
- Detects language and profiling tools
- Identifies slow functions and hotspots
- Analyzes complexity and patterns
- Generates optimization suggestions
- Creates benchmarks for comparison
# Performance Profile
## Hotspots Identified
1. getUserWithPosts (Line 45)
- Issue: N+1 query pattern
- Fix: Use JOIN or batch loading
- Impact: 10x improvement
## Memory Concerns
| Function | Allocations |
| -------- | ----------- |
| loadAllUsers | 45/call |
## Recommendations
1. Fix N+1 queries
2. Add caching layer| Language | Profiler |
|---|---|
| Node.js | node --prof, clinic.js |
| Go | pprof, trace |
| Python | cProfile, py-spy |
| Rust | perf, flamegraph |
| Pattern | Issue |
|---|---|
| Nested loops | O(n²) complexity |
| N+1 queries | Database round trips |
| Sync I/O | Blocking operations |
| No caching | Repeated computation |
- Source code to analyze
- Claude Code with Opus 4.5 model access
cd <clone-path>/command-profile && git pull