mcpField
O
optimizing-code

optimizing-code

github.com/dralgorhythmDevelopment12870 installsUpdated 14w ago
Repository

About optimizing-code

A coding skill for improving software performance while preserving behavior. It guides developers through benchmarking and profiling before and after changes, with examples of common optimization areas.

Key features

  1. 01Benchmark before optimization
  2. 02Profile to locate bottlenecks
  3. 03Measure results after changes
  4. 04Algorithm and data-structure guidance
  5. 05Caching, database, and memory techniques

Use cases

  1. 01Finding a slow critical path
  2. 02Checking whether a code change improves performance
  3. 03Reducing costly database queries
  4. 04Handling large files with less memory

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/dralgorhythm/claude-agentic-framework --skill optimizing-code

After installing, type/optimizing-codein Claude Code to confirm it loaded.

Details

From the project README

Optimizing Code

The Optimization Hat

When optimizing, you improve performance without changing behavior. Always measure before and after.

Golden Rules

  1. Measure First: Never optimize without a benchmark
  2. Profile Before Guessing: Find the actual bottleneck
  3. Optimize the Right Thing: Focus on the critical path
  4. Measure After: Verify the optimization worked

Workflows

  • Benchmark: Establish baseline performance metrics
  • Profile: Identify the actual bottleneck
  • Hypothesize: What optimization will help?
  • Implement: Make the change
  • Measure: Verify improvement
  • Document: Record the optimization and results

Common Optimizations

Algorithm Complexity
  • Replace O(n²) with O(n log n) or O(n)
  • Use appropriate data structures (Set for lookups, Map for key-value)
Caching
// Memoization
const cache = new Map<string, Result>();

function expensiveCalculation(input: string): Result {
  if (cache.has(input)) {
    return cache.get(input)!;
  }
  const result = /* expensive work */;
  cache.set(input, result);
  return result;
}
Database Queries
  • Add indexes for frequently queried columns
  • Avoid N+1 queries (use eager loading)
  • Use pagination for large result sets
Memory
  • Avoid creating unnecessary objects in loops
  • Use streaming for large files
  • Release references when done

Profiling Tools

# Node.js
node --prof app.js
node --prof-process isolate-*.log

# Python
python -m cProfile -s cumtime script.py

# Go
go test -bench=. -cpuprofile=cpu.prof
go tool pprof cpu.prof

Anti-Patterns to Avoid

  • Premature optimization (no benchmark)
  • Micro-optimizations (negligible impact)
  • Optimizing cold paths
  • Sacrificing readability for minor gains

Comments

Markdown supported