skills/curiouslearner/performance-profiler/SKILL.md
Analyze code performance patterns and identify optimization opportunities.
npx skillsauth add aiskillstore/marketplace performance-profilerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Analyze code performance patterns and identify optimization opportunities.
You are a performance optimization expert. When invoked:
Identify Performance Issues:
Analyze Patterns:
Measure Impact:
Provide Recommendations:
// ❌ O(n²) - Inefficient
function findDuplicates(arr) {
const duplicates = [];
for (let i = 0; i < arr.length; i++) {
for (let j = i + 1; j < arr.length; j++) {
if (arr[i] === arr[j]) duplicates.push(arr[i]);
}
}
return duplicates;
}
// ✓ O(n) - Efficient
function findDuplicates(arr) {
const seen = new Set();
const duplicates = new Set();
for (const item of arr) {
if (seen.has(item)) duplicates.add(item);
seen.add(item);
}
return Array.from(duplicates);
}
// ❌ Re-renders on every parent update
function ExpensiveComponent({ data }) {
const processed = expensiveCalculation(data);
return <div>{processed}</div>;
}
// ✓ Memoized, only re-renders when data changes
const ExpensiveComponent = React.memo(({ data }) => {
const processed = useMemo(() => expensiveCalculation(data), [data]);
return <div>{processed}</div>;
});
// ❌ N+1 queries
async function getPostsWithAuthors() {
const posts = await db.posts.findAll();
for (const post of posts) {
post.author = await db.users.findById(post.authorId); // N queries
}
return posts;
}
// ✓ Single query with join
async function getPostsWithAuthors() {
return await db.posts.findAll({
include: [{ model: db.users, as: 'author' }]
});
}
// ❌ Memory leak - event listener not cleaned up
useEffect(() => {
window.addEventListener('scroll', handleScroll);
// Missing cleanup!
}, []);
// ✓ Proper cleanup
useEffect(() => {
window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
}, []);
@performance-profiler
@performance-profiler src/
@performance-profiler UserList.jsx
@performance-profiler --focus algorithms
@performance-profiler --include-bundle-size
# Performance Analysis Report
## Summary
- Files analyzed: 23
- Issues found: 18
- High priority: 4
- Medium priority: 9
- Low priority: 5
- Estimated improvement: 60% faster, 30% smaller bundle
## Critical Issues (4)
### 1. Inefficient Algorithm - src/utils/search.js:34
**Issue**: O(n²) search algorithm
**Current**: Linear search within loop (complexity: O(n²))
**Impact**: ~850ms for 1000 items
**Recommendation**: Use Map for O(1) lookups
**Expected improvement**: 99% faster (~8ms for 1000 items)
```javascript
// Current (slow)
function findMatches(items, queries) {
return queries.map(q => items.find(i => i.id === q));
}
// Optimized
function findMatches(items, queries) {
const itemMap = new Map(items.map(i => [i.id, i]));
return queries.map(q => itemMap.get(q));
}
Issue: Component re-renders on every state change Impact: ~500ms render time for 100 rows Recommendation: Implement React.memo and useMemo Expected improvement: 80% reduction in render time
Issue: Importing entire lodash library (71KB gzipped)
Current: import _ from 'lodash'
Recommendation: Import only needed functions
Expected improvement: -65KB (91% reduction)
// Instead of
import _ from 'lodash';
// Use
import debounce from 'lodash/debounce';
import throttle from 'lodash/throttle';
Issue: Sequential database queries in loop Impact: ~2000ms for 50 posts Recommendation: Use eager loading/joins Expected improvement: 95% faster (~100ms)
Total Bundle Size: 487KB (gzipped: 142KB)
Largest Dependencies:
Recommendations:
High Priority (Do First):
Medium Priority:
Low Priority (Nice to Have):
## Optimization Techniques
### Frontend Performance
- **Memoization**: Cache expensive calculations
- **Virtualization**: Render only visible items
- **Lazy Loading**: Load code/images on demand
- **Code Splitting**: Break bundle into chunks
- **Debouncing/Throttling**: Limit function calls
- **Web Workers**: Offload CPU-intensive tasks
### Backend Performance
- **Caching**: Redis, in-memory caches
- **Query Optimization**: Indexes, joins, pagination
- **Connection Pooling**: Reuse database connections
- **Async Operations**: Non-blocking I/O
- **Batching**: Combine multiple operations
### General Optimizations
- **Algorithm Choice**: Pick right data structure
- **Early Returns**: Exit loops/functions early
- **Avoid Premature Optimization**: Profile first
- **Lazy Evaluation**: Compute only when needed
## Profiling Tools
- **JavaScript**: Chrome DevTools, React Profiler, Lighthouse
- **Node.js**: clinic.js, 0x, node --prof
- **Python**: cProfile, memory_profiler, py-spy
- **Database**: Query analyzers, EXPLAIN plans
- **Bundle**: webpack-bundle-analyzer, source-map-explorer
## Notes
- Always profile before optimizing
- Measure actual impact after changes
- Consider readability vs performance trade-offs
- Focus on bottlenecks, not micro-optimizations
- Test performance improvements with realistic data
- Document why optimizations were made
development
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.