Claude Skills
CollectionsCompareWorkflowsNominate
Sign inSign up
© 2026 Curated Agent Skills·Learn more about Agent Skills
Back to repository

node-performance

verified

Node.js performance optimization patterns

View on GitHub

Marketplace

alphaagent-team

the-answerai/alphaagent-team

Plugin

aai-stack-node

stack

Repository

the-answerai/alphaagent-team

plugins/aai-stack-node/skills/node-performance/SKILL.md

Last Verified

February 1, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/the-answerai/alphaagent-team/blob/main/plugins/aai-stack-node/skills/node-performance/SKILL.md -a claude-code --skill node-performance

Installation paths:

Claude
.claude/skills/node-performance/
Powered by add-skill CLI

Instructions

# Node.js Performance Skill

Patterns for optimizing Node.js application performance.

## Memory Management

### Heap Snapshots

```typescript
import v8 from 'v8'
import fs from 'fs'

// Take heap snapshot
function takeHeapSnapshot(filename: string): void {
  const snapshotStream = v8.writeHeapSnapshot(filename)
  console.log(`Heap snapshot written to ${snapshotStream}`)
}

// Expose via endpoint
app.get('/debug/heap', (req, res) => {
  const filename = `/tmp/heap-${Date.now()}.heapsnapshot`
  takeHeapSnapshot(filename)
  res.download(filename)
})

// Memory usage
function getMemoryUsage(): object {
  const usage = process.memoryUsage()
  return {
    heapUsed: Math.round(usage.heapUsed / 1024 / 1024) + 'MB',
    heapTotal: Math.round(usage.heapTotal / 1024 / 1024) + 'MB',
    external: Math.round(usage.external / 1024 / 1024) + 'MB',
    rss: Math.round(usage.rss / 1024 / 1024) + 'MB',
  }
}
```

### Avoiding Memory Leaks

```typescript
// BAD: Growing array
const cache: any[] = []
function addToCache(item: any) {
  cache.push(item)  // Never cleared
}

// GOOD: LRU cache with limit
import { LRUCache } from 'lru-cache'

const cache = new LRUCache<string, any>({
  max: 500,              // Max items
  maxSize: 50 * 1024 * 1024,  // 50MB
  sizeCalculation: (value) => JSON.stringify(value).length,
  ttl: 1000 * 60 * 5,    // 5 minutes
})

// BAD: Event listener leak
class Service {
  constructor(emitter: EventEmitter) {
    emitter.on('data', this.handleData.bind(this))
    // Never removed
  }
}

// GOOD: Cleanup listeners
class Service {
  private handler: (data: any) => void

  constructor(private emitter: EventEmitter) {
    this.handler = this.handleData.bind(this)
    emitter.on('data', this.handler)
  }

  destroy() {
    this.emitter.off('data', this.handler)
  }
}
```

## CPU Optimization

### Worker Threads

```typescript
import { Worker, isMainThread, parentPort, workerData } from 'worker_threads'
import os from 'os'

if (isMainThread) {
  // Main thread
  

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
7716 chars