code-optimize

Analyze and optimize code for performance, memory, and efficiency

16 stars

Best use case

code-optimize is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Analyze and optimize code for performance, memory, and efficiency

Teams using code-optimize should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/code-optimize/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/code-optimize/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/code-optimize/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How code-optimize Compares

Feature / Agentcode-optimizeStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Analyze and optimize code for performance, memory, and efficiency

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Code Optimization

Optimize the following code for performance and efficiency.

## Code to Optimize

$ARGUMENTS

## Optimization Strategy for Solo Developers

### 1. **Profiling First**
- Identify actual bottlenecks
- Don't optimize prematurely
- Measure before and after
- Focus on high-impact areas

### 2. **Performance Optimization Areas**

**React/Next.js**
- Memoization (React.memo, useMemo, useCallback)
- Code splitting and lazy loading
- Image optimization (next/image)
- Font optimization (next/font)
- Remove unnecessary re-renders
- Virtual scrolling for long lists

**Database Queries**
- Add indexes for frequently queried fields
- Batch queries (reduce N+1 problems)
- Use select to limit fields
- Implement pagination
- Cache frequent queries
- Use database views for complex joins

**API Calls**
- Implement caching (SWR, React Query)
- Debounce/throttle requests
- Parallel requests where possible
- Request deduplication
- Optimistic updates

**Bundle Size**
- Tree-shaking unused code
- Dynamic imports for large libraries
- Replace heavy dependencies
- Code splitting by route
- Lazy load below-the-fold content

**Memory**
- Fix memory leaks (cleanup useEffect)
- Avoid unnecessary object creation
- Use const for non-changing values
- Clear intervals/timeouts
- Remove event listeners

### 3. **Optimization Checklist**

**JavaScript/TypeScript**
- Use const/let instead of var
- Avoid nested loops where possible
- Use Map/Set for lookups
- Minimize DOM manipulations
- Debounce/throttle expensive operations

**React**
- Memo components that render often
- Move static values outside components
- Use keys properly in lists
- Avoid inline functions in render
- Lazy load routes and components

**Next.js**
- Use Server Components where possible
- Implement ISR for dynamic content
- Optimize images with next/image
- Prefetch critical routes
- Use Suspense for streaming

**Database**
- Add indexes on foreign keys
- Use prepared statements
- Batch inserts/updates
- Implement connection pooling
- Cache expensive queries

**Network**
- Compress responses (gzip/brotli)
- Use CDN for static assets
- Implement HTTP/2
- Set proper cache headers
- Minimize payload size

### 4. **Measurement Tools**

**Frontend**
- Chrome DevTools Performance tab
- Lighthouse CI
- React DevTools Profiler
- Bundle Analyzer (next/bundle-analyzer)

**Backend**
- Node.js profiler
- Database query analyzer
- APM tools (DataDog, New Relic)
- Load testing (k6, Artillery)

### 5. **Common Optimizations**

**Replace inefficient array methods**
```typescript
// Before: Multiple iterations
const result = arr
  .filter(x => x > 0)
  .map(x => x * 2)
  .reduce((sum, x) => sum + x, 0)

// After: Single iteration
const result = arr.reduce((sum, x) => {
  return x > 0 ? sum + (x * 2) : sum
}, 0)
```

**Memoize expensive calculations**
```typescript
const expensiveValue = useMemo(() => {
  return complexCalculation(props.data)
}, [props.data])
```

**Virtual scrolling for long lists**
```typescript
import { useVirtual } from 'react-virtual'
// Only render visible items
```

## Output Format

1. **Analysis** - Identify performance bottlenecks
2. **Optimized Code** - Improved version
3. **Explanation** - What changed and why
4. **Benchmarks** - Expected performance improvement
5. **Trade-offs** - Any complexity added
6. **Next Steps** - Further optimization opportunities

Focus on practical, measurable optimizations that provide real user value. Don't sacrifice readability for micro-optimizations.

Related Skills

prompt-optimizer

16
from diegosouzapw/awesome-omni-skill

This skill should be used when users request help optimizing, improving, or refining their prompts or instructions for AI models. Use this skill when users provide vague, unclear, or poorly structured prompts and need assistance transforming them into clear, effective, and well-structured instructions that AI models can better understand and execute. This skill applies comprehensive prompt engineering best practices to enhance prompt quality, clarity, and effectiveness.

performance-optimizer

16
from diegosouzapw/awesome-omni-skill

Performance analysis, profiling techniques, bottleneck identification, and optimization strategies for code and systems. Use when the user needs to improve performance, reduce resource usage, or identify and fix performance bottlenecks.

optimize

16
from diegosouzapw/awesome-omni-skill

Optimize your SaaS app across four dimensions - Speed (page load, API response), Code (unused files, dead code), Database (orphaned data, schema hygiene), and Dependencies (package bloat, bundle size). Use when app feels slow, codebase feels bloated, or after significant development work accumulates. Each path follows AUDIT → CLEAN → PREVENT workflow.

optimize-prompt

16
from diegosouzapw/awesome-omni-skill

Prompt optimization consultant for AI system prompts and custom instructions. Supports Claude API, OpenAI API, Gemini API, CLAUDE.md, ChatGPT, and n8n. Use when user wants to improve, review, or create prompts, system instructions, or custom instructions for any AI platform.

hinge-profile-optimizer

16
from diegosouzapw/awesome-omni-skill

Comprehensive, research-backed Hinge dating profile optimization. Use when someone wants to improve their Hinge profile, audit an existing profile, write better prompts/captions, select and order photos strategically, or understand why they're not getting quality matches. This is the thorough process (60-90 mins) - discovery interview, game theory analysis, photo strategy, copy creation, settings optimization, and implementation support. Based on 45+ peer-reviewed sources on dating app behavior.

database-optimizer

16
from diegosouzapw/awesome-omni-skill

Expert database optimizer specializing in modern performance tuning, query optimization, and scalable architectures. Masters advanced indexing, N+1 resolution, multi-tier caching, partitioning strategies, and cloud database optimization. Handles complex query analysis, migration strategies, and performance monitoring. Use PROACTIVELY for database optimization, performance issues, or scalability challenges.

claude-code-optimizer

16
from diegosouzapw/awesome-omni-skill

Audit and optimize Claude Code installations to current best practices. Use when users ask to check, audit, optimize, or improve their Claude Code setup, configuration, hooks, permissions, or workflow. Triggers on requests mentioning Claude Code settings, CLAUDE.md files, hooks configuration, permissions setup, or performance optimization.

asset-catalog-optimizer

16
from diegosouzapw/awesome-omni-skill

Analyze and optimize Xcode asset catalogs - find unused assets, missing resolutions, compress images

agent-orchestration-multi-agent-optimize

16
from diegosouzapw/awesome-omni-skill

Optimize multi-agent systems with coordinated profiling, workload distribution, and cost-aware orchestration. Use when improving agent performance, throughput, or reliability.

simd-optimize

16
from diegosouzapw/awesome-omni-skill

SIMD vectorization for Rust — detects ISA features, identifies vectorizable patterns, generates platform-specific intrinsics (ARM NEON/SVE, x86 SSE/AVX/AVX-512), validates correctness and performance. Uses tiered research with baked-in references and /deep-research fallback.

context-optimizer

16
from diegosouzapw/awesome-omni-skill

Analyzes Copilot Chat debug logs, agent definitions, skills, and instruction files to audit context window utilization. Provides log parsing, turn-cost profiling, redundancy detection, hand-off gap analysis, and optimization recommendations. Use when optimizing agent context efficiency, identifying where to add subagent hand-offs, or reducing token waste across agent systems.

agentv-prompt-optimizer

16
from diegosouzapw/awesome-omni-skill

Iteratively optimize prompt files against AgentV evaluation datasets by analyzing failures and refining instructions.