Skip to content
Back to skills

Code Optimization

ASecurity

Use when asked to optimize code or fix memory leaks, or when analyzing code for performance issues, inefficient loops, blocking calls, and resource waste

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 14, 2026
devopsjavascriptpythongojavanodedockerperformance

Security analysis

A100/100

Scanned November 14, 2026

npx -y skills add nikospavlopoulos/devops-mutant-powers --skill code-optimization --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Code Optimization?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Code Optimization
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nikospavlopoulos-code-optimization/badge)](https://www.skillsdirectory.com/skills/nikospavlopoulos-code-optimization)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: code-optimization
description: Use when asked to optimize code or fix memory leaks, or when analyzing code for performance issues, inefficient loops, blocking calls, and resource waste
---

# Code Optimization

## Works In Both Modes

- **Repo mode** — analyze actual source files
- **Chat mode** — analyze pasted code snippets

## What to Look For

### Memory Leaks

- Connections opened but never closed (DB, HTTP, file handles)
- Event listeners added but never removed
- Unbounded in-memory caches or queues (grows forever)
- Objects held in global scope that should be request-scoped
- Circular references preventing garbage collection

### Inefficient Loops & Algorithms

- N+1 query patterns (DB query inside a loop)
- Nested loops over large datasets (O(n²) or worse)
- Repeated computation of the same value inside a loop (move outside)
- Sorting inside a loop (sort once, outside)
- Linear search where a map/set lookup would be O(1)

### Blocking Operations

- Synchronous file I/O in an async/event-driven service
- Blocking network calls on the main thread
- CPU-intensive work blocking an event loop (Node.js, Python asyncio)
- Long-running DB queries without timeout

### Container & Infrastructure Waste

- Oversized Docker images (unnecessary packages, dev deps in prod image)
- Redundant image layers (multiple `RUN` commands that could be combined)
- CPU/memory limits set far above actual usage
- Idle replicas with no autoscaling configured
- Logs written to disk inside container instead of stdout

### Common Language Patterns

**Python:**
- `list.append()` in a loop where a list comprehension would do
- `+` string concatenation in a loop (use `join`)
- Reading entire file into memory when streaming is possible

**JavaScript/Node:**
- `Promise` chains that could run in parallel (`Promise.all`)
- `console.log` left in hot paths
- Synchronous `fs` methods (`fs.readFileSync`) in async handlers

**Go:**
- Goroutine leaks (goroutines started but never terminated)
- Mutex held too long — narrow the critical section
- Unnecessary allocations in hot paths

## Reporting Format

For each finding:

```
[SEVERITY] Type — Description
  Location: file:line or "pasted code, line X"
  Impact: what this costs (memory, CPU, latency, etc.)
  Fix: specific change to make
  Example:
    Before: <bad code>
    After:  <fixed code>
```

Severity: **HIGH** (causes real degradation), **MEDIUM** (wastes resources), **LOW** (minor improvement).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in devops →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.