agentleFS
troskatertroskater/flowdeck-claude/skills/performance-profiling/SKILL.md

performance-profiling

Skill0 starsChanged 22 days agoMITView on GitHub

CPU and memory profiling, N+1 query detection, bundle analysis, and render optimization. Activate when diagnosing slow performance or before production deployments.

  • Installs packages

25 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use intelligent-routing, bash-linux and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • SKB3002Skill

    intelligent-routing

    Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.

    Also in 5 projects that use this

  • xenitV1Skill

    bash-linux

    Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.

    Also in 6 projects that use this

  • xenitV1Skill

    red-team-tactics

    Red team tactics principles based on MITRE ATT&CK. Attack phases, detection evasion, reporting.

    Also in 6 projects that use this

  • SKB3002Skill

    nextjs-react-expert

    React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations.

    Also in 3 projects that use this

  • +8 more from xenitV1

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 14 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before a production deployment of performance-sensitive changes

    line 16
  2. Distinctive:

    After adding features to a hot code path

    line 17

“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Performance Profiling Skill

Finds real performance bottlenecks using data. Never optimize without measuring first.

When to Activate

Activate when:

  • Users report slow responses
  • A page or endpoint takes longer than expected
  • Before a production deployment of performance-sensitive changes
  • After adding features to a hot code path

Core Principles

  • Measure before optimizing — a guess about the bottleneck is almost always wrong
  • Profile the real bottleneck — top-line metrics first, then drill down
  • Verify improvement with numbers — "feels faster" is not a performance result

Workflow

  1. Establish baseline — measure current performance with actual numbers
  2. Profile — find where time is spent
  3. Identify bottleneck — the one slowest thing
  4. Fix — targeted change to address bottleneck
  5. Measure improvement — confirm the number improved

Profiling Tools

# Node.js CPU profiling
node --prof app.js
node --prof-process isolate-*.log | head -100

# Clinic.js (visual profiler)
npm install -g clinic
clinic doctor -- node app.js
clinic flame -- node app.js   # flame graph

# Lighthouse (web performance)
npx lighthouse http://localhost:3000 --output=json --output-path=./report.json

# Bundle analyzer
npx webpack-bundle-analyzer dist/stats.json

Core Web Vitals Targets

MetricGoodNeeds WorkPoor
LCP< 2.5s2.5s-4s> 4s
FID< 100ms100ms-300ms> 300ms
CLS< 0.10.1-0.25> 0.25
TTFB< 800ms800ms-1.8s> 1.8s

N+1 Detection

// ❌ N+1 — 1 query for posts, N queries for authors
const posts = await Post.findAll();
for (const post of posts) {
  post.author = await User.findById(post.authorId); // N queries!
}

// ✅ Single query with JOIN
const posts = await Post.findAll({
  include: [{ model: User, as: 'author' }]
});

Detection: add query logging and look for repeated queries with different IDs.

Bundle Analysis

# Generate stats
npm run build -- --stats

# Analyze
npx webpack-bundle-analyzer dist/stats.json

# What to look for:
# - Large libraries that could be replaced with smaller alternatives
# - Libraries imported in full that should be tree-shaken
# - Duplicate dependencies at different versions

React Render Profiling

// React DevTools Profiler — open in browser DevTools → Profiler tab
// Record a user interaction, look for:
// - Components rendering too often
// - Renders taking >16ms (drops frame rate)

// why-did-you-render (development only)
import whyDidYouRender from '@welldone-software/why-did-you-render';
whyDidYouRender(React, { trackAllPureComponents: true });

Memory Leak Patterns

// ❌ Event listener never removed
useEffect(() => {
  document.addEventListener('click', handler);
}, []);

// ✅ Cleanup
useEffect(() => {
  document.addEventListener('click', handler);
  return () => document.removeEventListener('click', handler);
}, []);

// ❌ Interval never cleared
useEffect(() => {
  setInterval(poll, 5000);
}, []);

// ✅ Clear on unmount
useEffect(() => {
  const id = setInterval(poll, 5000);
  return () => clearInterval(id);
}, []);

Performance Report Template

## Performance Report

### Baseline
- Endpoint: GET /api/v1/users
- P50: 340ms | P95: 1200ms | P99: 3400ms
- Measured with: autocannon, 100 concurrent connections

### Bottleneck
- Root cause: N+1 query — 1 query per user to fetch their role
- Evidence: query log shows 47 queries for 47 users

### Fix
- Single JOIN query in UserRepository.findAllWithRoles()
- File: src/db/user-repo.ts

### After
- P50: 42ms | P95: 98ms | P99: 210ms
- Improvement: 87% faster at P50

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.