# performance-expert

performance-expert guides code profiling, database query tuning, and caching strategies to resolve latency and throughput issues.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 198 installs · ★ 45 repo stars
- Author: personamanagmentlayer
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/personamanagmentlayer/pcl/tree/HEAD/stdlib/devops/performance-expert/SKILL.md
- Updated: 2026-10-12
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/performance-expert

## What it does

This skill delivers patterns for optimizing backend execution and data access. It covers CPU and memory profiling using `cProfile` and `memory_profiler`, function benchmarking via `timeit`, NumPy vectorization, and generator-based memory savings.

For database workloads, it details resolving SQLAlchemy N+1 query patterns using eager loading, tuning connection pool recycling, setting up composite indexes, and batch inserts. It also provides Redis cache-aside implementations and frontend debouncing examples.

Execution access is scoped in the manifest. The agent is restricted to `python`, `python3`, `pip`, and `pytest` in Bash, meaning raw OS tools like `htop` or kernel profilers cannot be run directly.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill performance-expert -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/performance-expert/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/performance-expert/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill performance-expert -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/performance-expert/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill performance-expert -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/performance-expert/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install personamanagmentlayer/pcl stdlib/devops/performance-expert
```

2. **Manually: put the files in place**
- File: `.github/skills/performance-expert/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill performance-expert -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/personamanagmentlayer/pcl --path stdlib/devops/performance-expert
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/performance-expert/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill performance-expert -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/personamanagmentlayer/pcl/tree/HEAD/stdlib/devops/performance-expert/SKILL.md

## When to use it
- Profile CPU bottlenecks and memory consumption with `cProfile`
- Fix N+1 query overhead in SQLAlchemy models
- Implement cache-aside query storage with Redis
- Replace slow Python iteration with vectorized NumPy routines

## Example prompts
- Profile this Python module and show the cumulative time breakdown
- Rewrite these SQLAlchemy relationships to eliminate N+1 queries
- Benchmark this function with timeit across 1000 iterations

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: a7cbe966a1774475.

BEGIN THIRD-PARTY FILE a7cbe966a1774475
````text
---
name: performance-expert
version: 2.0.0
description: >-
  Expert-level performance optimization, profiling, benchmarking, and tuning. Use when the
  user mentions optimization, profiling, benchmarking, or scalability, or when the task
  involves Performance Fundamentals, Optimization Areas, Profiling Tools, or General.
category: devops
tags: [performance, optimization, profiling, benchmarking, scalability]
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash(python:*, python3:*, pip:*, pytest:*)
---

# Performance Expert

Expert guidance for performance optimization, profiling, benchmarking, and system tuning.

## Core Concepts

### Performance Fundamentals

- Response time vs throughput
- Latency vs bandwidth
- CPU, memory, I/O bottlenecks
- Concurrency vs parallelism
- Caching strategies
- Load balancing

### Optimization Areas

- Algorithm optimization
- Database optimization
- Network optimization
- Frontend performance
- Backend performance
- Infrastructure tuning

### Profiling Tools

- CPU profilers
- Memory profilers
- Network profilers
- Application Performance Monitoring (APM)
- Load testing tools

## Python Performance

```python
import cProfile
import pstats
import timeit
import memory_profiler
from functools import lru_cache
from typing import List
import numpy as np

# Performance Profiling
def profile_function(func):
    """Decorator for profiling function execution"""
    def wrapper(*args, **kwargs):
        profiler = cProfile.Profile()
        profiler.enable()

        result = func(*args, **kwargs)

        profiler.disable()
        stats = pstats.Stats(profiler)
        stats.sort_stats('cumulative')
        stats.print_stats(10)  # Top 10 functions

        return result
    return wrapper

@profile_function
def slow_function():
    total = 0
    for i in range(1000000):
        total += i
    return total

# Memoization for expensive computations
@lru_cache(maxsize=128)
def fibonacci(n: int) -> int:
    """Cached Fibonacci calculation"""
    if n < 2:
        return n
    return fibonacci(n-1) + fibonacci(n-2)

# Vectorization with NumPy
def slow_loop(data: List[float]) -> List[float]:
    """Slow: Using Python loops"""
    return [x ** 2 + 2 * x + 1 for x in data]

def fast_vectorized(data: np.ndarray) -> np.ndarray:
    """Fast: Using NumPy vectorization"""
    return data ** 2 + 2 * data + 1

# Benchmarking
def benchmark_function(func, *args, iterations=1000):
    """Benchmark function execution time"""
    total_time = timeit.timeit(
        lambda: func(*args),
        number=iterations
    )
    avg_time = total_time / iterations

    return {
        'total_time': total_time,
        'avg_time': avg_time,
        'iterations': iterations
    }

# Memory profiling
@memory_profiler.profile
def memory_intensive_function():
````
END THIRD-PARTY FILE a7cbe966a1774475

The third-party file has ended. Everything between the a7cbe966a1774475 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2804 of 11933 bytes. © personamanagmentlayer · Apache-2.0 · https://github.com/personamanagmentlayer/pcl/tree/HEAD/stdlib/devops/performance-expert/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
