.claude/skills/the-optimizer/SKILL.md
Identifies and fixes performance bottlenecks in the application.
npx skillsauth add dupipcom/morpheus the-optimizerInstall 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.
Task: Analyze and optimize application performance, focusing on database queries, bundle size, and runtime efficiency.
Role: You're a performance engineer optimizing the application for speed and efficiency.
# Find potentially slow queries (missing select)
grep -r "findMany\|findFirst\|findUnique" --include="*.ts" src/app/api/ | grep -v "select:"
# Find N+1 query patterns
grep -r "for.*await.*prisma\|forEach.*await.*prisma" --include="*.ts" src/
# Analyze bundle size
npm run build
# Check .next/analyze if configured
# Find large imports
grep -r "import.*from" --include="*.tsx" src/components/ | grep -v "^//"
Check slow endpoints in production logs or add timing:
const start = Date.now()
// ... operation
console.log(`Operation took ${Date.now() - start}ms`)
// BAD: Fetches all fields
const users = await prisma.user.findMany()
// GOOD: Select only needed fields
const users = await prisma.user.findMany({
select: {
id: true,
profiles: {
select: { data: true }
}
}
})
// Always paginate large datasets
const items = await prisma.item.findMany({
take: limit,
skip: (page - 1) * limit,
orderBy: { createdAt: 'desc' }
})
// BAD: N+1 queries
for (const id of ids) {
const item = await prisma.item.findUnique({ where: { id } })
}
// GOOD: Single batch query
const items = await prisma.item.findMany({
where: { id: { in: ids } }
})
// Fetch independent data in parallel
const [users, items, stats] = await Promise.all([
prisma.user.findMany(),
prisma.item.findMany(),
prisma.stat.aggregate()
])
// Add indexes for frequently queried fields
model Item {
userId String @db.ObjectId
status String
createdAt DateTime
@@index([userId, status])
@@index([createdAt])
}
// Lazy load heavy components
const HeavyComponent = dynamic(() => import('./HeavyComponent'), {
loading: () => <Skeleton />,
ssr: false
})
// Use next/image
import Image from 'next/image'
<Image
src={url}
width={200}
height={200}
loading="lazy"
placeholder="blur"
/>
// Memoize expensive calculations
const memoizedValue = useMemo(() => expensiveCalculation(data), [data])
// Memoize callbacks
const handleClick = useCallback(() => { ... }, [dependency])
| Metric | Target | |--------|--------| | API response time | < 500ms | | Page load (initial) | < 3s | | Page navigation | < 1s | | Database query | < 100ms | | Bundle size (main) | < 200KB |
selectReport optimization findings:
development
Runs tests, analyzes failures, and fixes test issues to ensure code quality.
data-ai
Creates and runs data migrations for schema changes, ensuring data integrity.
development
Identifies and fixes ESLint errors and TypeScript type issues across the codebase.
tools
Manages internationalization - adds translations, fixes missing keys, and ensures locale consistency.