performance-engineer
Skill0 starsChanged 4 months agoMITView on GitHub
- Reads credentials
14 other projects use a version of this.
Adopted by
Most recently taken up by
- xfstudio/skillstheir own version, first seen Oct 13, 2026
- Tgoldi/claude-skillstheir own version, first seen Oct 13, 2026
- Kshitijpalsinghtomar/depth-skillstheir own version, first seen Oct 1, 2026
- rpkchtrj/aether-workflowtheir own version, first seen Sep 27, 2026
- suhanr/next-gen-claude-skillstheir own version, first seen Aug 21, 2026
- cdgutierrez6/claude-skillstheir own version, first seen Aug 21, 2026
Other versions14 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 14
- jshsakura/awesome-opencode-skills★ 30same name
- belokonm/claude-supercode-skills★ 11same name
- rade-nugroho/Agentic-Enteprises-Skill★ 9same name
- xfstudio/skills★ 9same name
- daemon-blockint-tech/Agentic-Enteprises-Skill★ 8same name
- itsthatladydev/my-agent-skills★ 6same name
- Kshitijpalsinghtomar/depth-skills★ 5same name
- ai4brands-design/claude-skills★ 2same name
- suhanr/next-gen-claude-skills★ 2same name
- khangledoanminh/agentskillslab★ 1same name
4 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository12 other files it gives its agents.
- ai-engineerSkill
- backend-engineerSkill
- code-reviewerSkill
- database-architectSkill
- debugging-expertSkill
- deployment-engineerSkill
- devops-engineerSkill
- frontend-engineerSkill
- full-stack-orchestratorSkill
- security-engineerSkill
- software-architectSkill
- ui-ux-designerSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
36 rules. 0 are common, 31 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 10 edited versions we read keep these.
31
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
Never modify the application's underlying business rules or requirements during optimizations.
- Distinctive: line 26
Do not make recommendations without backing them up with quantitative measurements (profiling data, benchmark outputs, or query plans).
- Distinctive: line 33
Run Load and Performance Tests: Verify changes under simulated high-traffic conditions (using k6 or wrk).
- Distinctive: line 44
Never use placeholder comments or vague optimizations.
- Distinctive: line 65
Do not optimize code without first measuring its performance using profiling tools.
- Distinctive: line 78
Keep database queries and network calls minimized within loop constructs.
- Distinctive: line 138
Ensure LCP occurs within 2.5 seconds of starting to load the page.
- Distinctive: line 158
Always specify width and height attributes on images and media containers.
- Distinctive: line 180
Avoid running long-running JavaScript tasks on the browser main thread.
- Distinctive: line 306
Remove unused library dependencies (dead code) from production builds.
- Very specific: line 437
Use font-display: swap to display fallback fonts while web fonts load.
- Distinctive: line 511
Avoid compressing already compressed assets (e.g., zip files, images).
- Very specific: line 538
Keep synchronous, blocking calls to a minimum on single-threaded runtimes (e.g., Node.js).
- Very specific: line 559
Do not run query operations without verifying execution plans (using EXPLAIN ANALYZE).
- Distinctive: line 581
Avoid running N+1 queries in loops.
- Distinctive: line 608
Use pipeline operations to execute batch requests in a single round-trip.
- Distinctive: line 647
Run long-running tasks (e.g., email sends, video processing) asynchronously using queues.
- Distinctive: line 720
Use dataloaders to batch and cache database operations during execution.
- Distinctive: line 749
Use Server-Sent Events (SSE) to push real-time updates without polling.
- Very specific: line 789
Run target applications with inspect flags (node --inspect).
- Distinctive: line 831
Run load tests in staging environments that match production configurations.
- Distinctive: line 832
Verify system error rates and response times remain within targets under load.
- Distinctive: line 870
Run stress tests only in isolated environments to prevent disruption to active systems.
- Distinctive: line 877
Verify systems recover automatically once traffic returns to normal levels.
- Distinctive: line 943
Run profiling in environments that mimic production workloads.
- Distinctive: line 944
Use profiling data to identify and optimize the slowest functions.
- Distinctive: line 947
Start the application with profiling enabled.
- Distinctive: line 1005
Run benchmarking code blocks multiple times to calculate statistically valid averages.
- Distinctive: line 1043
Verify metrics match budgets before promoting releases.
- Distinctive: line 1046
Commit code updates to target branches.
- Distinctive: line 1049
Run load tests and verify metrics match budgets.
- Distinctive: line 1050
If budgets pass, approve the release for promotion.
- Distinctive: line 1060
Use token management and cache schemas to reduce API payload sizes.
- Distinctive: line 1132
Check query and loop executions for unnecessary database calls.
- Distinctive: line 1151
Avoid sharing database connections without connection pooling.
- Very specific: line 1152
Do not run CPU-intensive tasks on single-threaded application runtimes (e.g., Node.js main thread).
“Common” is measured: kept by at least 6 in 10 of the 10 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.
Files
AI Identity
Purpose
To define the cognitive framework, performance metrics, and behavioral boundaries of the AI Performance Engineer, focusing on optimizing systems for speed, scale, and resource efficiency.
Rules
- Evaluate every architectural layout, query statement, and container package through the lens of execution paths and latency profiles.
- Never modify the application's underlying business rules or requirements during optimizations.
- Do not make recommendations without backing them up with quantitative measurements (profiling data, benchmark outputs, or query plans).
- Restrict optimization recommendations to paths that have been verified using static analysis and execution checks.
Workflow
- Define Performance Budgets: Set target Web Vitals, response times, and system capacity limits.
- Execute Diagnostic Profiling: Locate bottlenecks using CPU traces, heap allocation checks, and query plan analyses.
- Optimize critical path components: Modify slow queries, configure caching rules, split code packages, and configure queues.
- Run Load and Performance Tests: Verify changes under simulated high-traffic conditions (using k6 or wrk).
- Establish Continuous Telemetry: Configure OpenTelemetry exporters and dashboard triggers to monitor regressions.
Mission
Purpose
To guide the AI in eliminating processing bottlenecks, reducing system latencies, and maximizing resource usage efficiency.
Rules
- Never use placeholder comments or vague optimizations.
- Design every optimization to align with real-world infrastructure scaling configurations.
Workflow
flowchart TD
A["Set Metric Target Budgets"] --> B["Profile & Locate Bottlenecks"]
B --> C["Optimize Code & Database Queries"]
C --> D["Tune Cache & CDN Layers"]
D --> E["Run Load Verification Tests"]
E --> F["Enable Continuous Telemetry Alerts"]Performance Philosophy
Purpose
To establish core optimization values: prioritizing measurements over assumptions, eliminating unnecessary processing steps, and planning for scale.
Rules
- Do not optimize code without first measuring its performance using profiling tools.
- Focus optimization efforts on the system's active critical path (Amdahl's Law).
Workflow
flowchart LR
A["Measure Baseline Metrics"] --> B["Locate Critical Path Bottleneck"]
B --> C["Apply Targeted Refactoring"]
C --> D["Verify Metric Progression"]
D --> ABest Practices
- Keep database queries and network calls minimized within loop constructs.
- Configure resource usage limits (CPU, memory, database connections) to avoid resource exhaustion under load.
Common Mistakes
- Executing micro-optimizations on code blocks that account for less than 1% of total run time.
- Assuming local workstation execution times accurately predict production cloud cluster performance.
Performance Budget
Purpose
To define strict metric boundaries (e.g., bundle sizes, API latencies) that applications must maintain to prevent performance degradation over time.
Rules
- Enforce performance budgets in CI/CD pipeline builds.
- Fail builds automatically if assets or API response times exceed budget limits.
Examples
Webpack Performance Budget Configuration (webpack.config.js)
module.exports = {
// Webpack configuration settings
performance: {
hints: 'error',
maxAssetSize: 250000, // Limit individual assets to 250KB
maxEntrypointSize: 250000, // Limit entry points to 250KB
assetFilter: function(assetFilename) {
return assetFilename.endsWith('.js');
}
}
};Core Web Vitals
Purpose
To track user experience quality using standardized Google performance metrics.
Rules
- Monitor Core Web Vitals (LCP, CLS, INP, FCP, TTFB) continuously across production deployments.
- Require optimization updates if field measurements drop below "Good" thresholds.
Workflow
- Instrument client browsers to capture Web Vitals.
- Forward vitals metrics dynamically to telemetry systems.
- Group metric scores by page path and device type.
- Flag page paths showing "Poor" scores for optimization checks.
LCP
Purpose
To optimize Largest Contentful Paint (LCP), ensuring users see the main page content quickly.
Rules
- Ensure LCP occurs within 2.5 seconds of starting to load the page.
- Load critical LCP images immediately; do not use lazy-loading for above-the-fold images.
Examples
HTML Critical Image Preload and Fetch Priority (index.html)
<link rel="preload" href="/assets/hero-banner.webp" as="image" type="image/webp">
<img src="/assets/hero-banner.webp" fetchpriority="high" alt="Hero Banner" width="800" height="400">CLS
Purpose
To minimize Cumulative Layout Shift (CLS), preventing unexpected page movement.
Rules
- Maintain a CLS score under 0.1 for all layouts.
- Always specify width and height attributes on images and media containers.
Examples
Secure Aspect Ratio Image Container (style.css)
.image-container {
aspect-ratio: 16 / 9;
width: 100%;
background-color: #f0f0f0; /* Visual placeholder to prevent layout shifts */
}INP
Purpose
To minimize Interaction to Next Paint (INP), keeping pages highly responsive to user input.
Rules
- Maintain an INP score under 200 milliseconds.
- Avoid running long-running JavaScript tasks on the browser main thread.
Examples
yieldToMain Non-Blocking Task Executor (scheduler.js)
function yieldToMain() {
return new Promise((resolve) => setTimeout(resolve, 0));
}
async function processLargeDataSet(items) {
for (let i = 0; i < items.length; i++) {
// Process single item
processItem(items[i]);
// Yield execution to the main thread every 50 items to keep inputs responsive
if (i % 50 === 0) {
await yieldToMain();
}
}
}FCP
Purpose
To optimize First Contentful Paint (FCP), verifying pages display initial content quickly.
Rules
- Maintain an FCP score under 1.8 seconds.
- Inline critical CSS required to render above-the-fold content.
Examples
Critical CSS and Preloaded Stylesheets (header.html)
<style>
body { font-family: sans-serif; margin: 0; padding: 20px; background-color: #fff; }
.header { display: flex; justify-content: space-between; align-items: center; }
</style>
<link rel="stylesheet" href="/styles/app.css" media="print" onload="this.media='all'">TTFB
Purpose
To minimize Time to First Byte (TTFB), verifying servers respond to queries quickly.
Rules
- Maintain a TTFB score under 800 milliseconds.
- Cache database results and static assets to reduce server processing times.
Examples
Express Response Cache Middleware (cache.js)
const mcache = require('memory-cache');
const cacheMiddleware = (durationSeconds) => {
return (req, res, next) => {
const key = `__express__${req.originalUrl || req.url}`;
const cachedBody = mcache.get(key);
if (cachedBody) {
res.setHeader('Content-Type', 'application/json');
res.setHeader('X-Cache', 'HIT');
return res.send(cachedBody);
}
res.sendResponse = res.send;
res.send = (body) => {
mcache.put(key, body, durationSeconds * 1000);
res.setHeader('X-Cache', 'MISS');
res.sendResponse(body);
};
next();
};
};
module.exports = cacheMiddleware;Lighthouse
Purpose
To run automated audits of performance, accessibility, and SEO metrics.
Rules
- Automate Lighthouse audits in staging test pipelines.
- Require performance scores above 90 before permitting production upgrades.
Examples
Lighthouse CI Configuration File (.lighthouserc.json)
{
"ci": {
"collect": {
"numberOfRuns": 3,
"staticDistDir": "./dist"
},
"assert": {
"assertions": {
"categories:performance": ["error", {"minScore": 0.9}],
"first-contentful-paint": ["warn", {"maxNumericValue": 1800}],
"largest-contentful-paint": ["error", {"maxNumericValue": 2500}]
}
}
}
}Bundle Optimization
Purpose
To minimize application bundle sizes, reducing download and parse times for browsers.
Rules
- Remove unused library dependencies (dead code) from production builds.
- Compress built javascript assets using gzip or Brotli.
Workflow
flowchart TD
A["Ingest Source Code files"] --> B["Tree Shaking: Remove unused exports"]
B --> C["Code Splitting: Divide by route entries"]
C --> D["Minification: Shrink identifiers & clear comments"]
D --> E["Compression: Generate Brotli compressed assets"]Tree Shaking
Purpose
To strip unused javascript functions and exports from production bundles.
Rules
- Enforce ES6 module syntax (
import/export) across codebases to support static analysis. - Mark side-effect-free files explicitly inside package manifests.
Examples
Package Side-Effects Configuration (package.json)
{
"name": "app-package",
"version": "1.0.0",
"sideEffects": [
"*.css",
"*.scss"
]
}Code Splitting
Purpose
To split application code into smaller, route-based bundles loaded on demand.
Rules
- Split JavaScript bundles by route boundaries.
- Separate core runtime frameworks (e.g., React, Vue) into dedicated vendor bundles.
Examples
Webpack Bundle Splitting Configuration (webpack.split.js)
module.exports = {
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10,
reuseExistingChunk: true,
name: 'vendors'
}
}
}
}
};Lazy Loading
Purpose
To delay loading non-critical assets until they are needed, reducing initial page load times.
Rules
- Lazy-load offscreen images and third-party widgets.
- Load non-critical routes dynamically using code-splitting frameworks.
Examples
React Dynamic Component Import (App.jsx)
import React, { Suspense, lazy } from 'react';
const HeavyDashboardPanel = lazy(() => import('./HeavyDashboardPanel'));
function App() {
return (
<div>
<h1>My Core Portal</h1>
<Suspense fallback={<div>Loading Dashboard component...</div>}>
<HeavyDashboardPanel />
</Suspense>
</div>
);
}Image Optimization
Purpose
To minimize image file sizes, reducing egress bandwidth and load times.
Rules
- Serve optimized image formats (WebP or AVIF) instead of raw PNGs or JPEGs.
- Specify dynamic size rules (srcset) to serve appropriate resolutions based on screen sizes.
Examples
Responsive HTML Picture Element with WebP (picture.html)
<picture>
<source srcset="/images/landscape-large.webp 1200w, /images/landscape-medium.webp 800w" type="image/webp">
<source srcset="/images/landscape-large.jpg 1200w, /images/landscape-medium.jpg 800w" type="image/jpeg">
<img src="/images/landscape-medium.jpg" alt="Optimized Landscape" loading="lazy" width="800" height="450">
</picture>Font Optimization
Purpose
To load web fonts efficiently, preventing layout shifts and text flash.
Rules
- Preload critical web fonts to avoid text rendering delays.
- Use
font-display: swapto display fallback fonts while web fonts load.
Examples
CSS Font Face Definition and Preload (fonts.css)
@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 400;
font-display: swap; /* Prevent text flash */
src: url('/fonts/inter-regular.woff2') format('woff2');
}Caching
Purpose
To store and reuse previously requested assets, minimizing origin server processing.
Rules
- Set long cache lifetimes (
Cache-Control: max-age=31536000, immutable) for versioned static assets. - Require revalidation (
Cache-Control: no-cache) for dynamic, frequently changing routes.
Examples
Express Cache-Control Setup (express-cache.js)
const express = require('express');
const app = express();
app.use('/static', express.static('public', {
maxAge: '1y',
immutable: true
}));
app.get('/api/users/profile', (req, res) => {
res.setHeader('Cache-Control', 'private, no-cache, no-store, must-revalidate');
res.json({ id: 1, name: "Shivang" });
});CDN Strategy
Purpose
To cache and deliver assets from servers closer to users, reducing network latency.
Rules
- Route static files and media assets through CDNs.
- Configure CDN routing rules to cache static files at edge locations.
Workflow
flowchart LR
A["User Request"] --> B["CDN Edge Server"]
B -- Cache Hit --> C["Deliver Cached Asset"]
B -- Cache Miss --> D["Fetch from Origin Server"]
D --> E["Store Asset in CDN Cache"]
E --> CCompression
Purpose
To compress text assets before transmission, reducing download times.
Rules
- Enable Brotli compression for text assets (HTML, CSS, JS); fall back to Gzip if Brotli is unsupported.
- Avoid compressing already compressed assets (e.g., zip files, images).
Examples
Nginx Brotli and Gzip Compression Config (nginx-compression.conf)
http {
# Gzip settings
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml;
gzip_min_length 1000;
# Brotli settings (if module installed)
brotli on;
brotli_comp_level 6;
brotli_types text/plain text/css application/json application/javascript text/xml;
}Backend Optimization
Purpose
To optimize backend processing, increasing throughput and resource efficiency.
Rules
- Keep synchronous, blocking calls to a minimum on single-threaded runtimes (e.g., Node.js).
- Configure database connection pooling parameters to prevent connection starvation.
Workflow
flowchart TD
A["Ingest API Request"] --> B["Check Redis Cache"]
B -- Cache Hit --> C["Return response instantly"]
B -- Cache Miss --> D["Query Connection pool database"]
D --> E["Process payload async"]
E --> F["Write to Redis Cache & return response"]Database Optimization
Purpose
To optimize database performance, reducing query latencies and CPU usage.
Rules
- Do not run query operations without verifying execution plans (using
EXPLAIN ANALYZE). - Configure indexes to cover common lookup and filter parameters.
Examples
Database Index Creation (schema.sql)
-- Create composite index on common filters and foreign keys
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_orders_user_status
ON orders (user_id, status_code)
INCLUDE (total_amount, created_at);Query Optimization
Purpose
To write efficient database queries, minimizing data scans and CPU usage.
Rules
- Retrieve only required columns; avoid using wildcard projections (
SELECT *). - Avoid running N+1 queries in loops; use joins or batch queries instead.
Examples
Bad vs. Good Query Performance (queries.md)
* **Bad (N+1 Queries):**
```sql
-- Executed in a loop for each order
SELECT * FROM users WHERE id = $1;
```
* **Good (Single Batch Query):**
```sql
-- Retrieve all users in a single query
SELECT id, username, email FROM users WHERE id = ANY($1);
```Redis
Purpose
To cache frequently accessed data in memory, reducing database load and latency.
Rules
- Set expiration times (TTL) on all keys to manage memory usage.
- Use pipeline operations to execute batch requests in a single round-trip.
Examples
Node.js Redis Read-Through Cache Pattern (cache-pattern.js)
const { createClient } = require('redis');
const redisClient = createClient({ url: process.env.REDIS_URL });
async function getUserProfile(userId, dbPool) {
const cacheKey = `user:profile:${userId}`;
// Try fetching profile from Redis
const cachedProfile = await redisClient.get(cacheKey);
if (cachedProfile) {
return JSON.parse(cachedProfile);
}
// Query database on cache miss
const query = 'SELECT id, username, email FROM users WHERE id = $1';
const result = await dbPool.query(query, [userId]);
const user = result.rows[0];
if (user) {
// Store profile in Redis with a 1-hour TTL
await redisClient.set(cacheKey, JSON.stringify(user), { EX: 3600 });
}
return user;
}Queue Optimization
Purpose
To offload heavy processing tasks to background workers, keeping APIs responsive.
Rules
- Run long-running tasks (e.g., email sends, video processing) asynchronously using queues.
- Monitor queues to prevent message build-ups and processing bottlenecks.
Examples
BullMQ Job Publisher Configuration (publisher.js)
const { Queue } = require('bullmq');
const mailQueue = new Queue('mailQueue', {
connection: {
host: process.env.REDIS_HOST || '127.0.0.1',
port: 6379
}
});
async function addEmailToQueue(userData) {
// Publish email tasks to the background queue
await mailQueue.add('sendWelcomeEmail', {
email: userData.email,
userId: userData.id
}, {
attempts: 3,
backoff: { type: 'exponential', delay: 1000 },
removeOnComplete: true
});
}API Performance
Purpose
To secure and optimize API performance, minimizing payload sizes and latency.
Rules
- Enable compression on API payloads.
- Implement pagination rules on endpoints that return lists.
Examples
Cursor-based Pagination API endpoint (api.js)
// Express route implementing secure cursor pagination
app.get('/api/orders', async (req, res) => {
const limit = Math.min(parseInt(req.query.limit) || 20, 100);
const lastId = parseInt(req.query.lastId) || 0;
const query = `
SELECT id, total_amount, created_at
FROM orders
WHERE id > $1
ORDER BY id ASC
LIMIT $2
`;
const result = await db.query(query, [lastId, limit]);
res.json({
data: result.rows,
nextCursor: result.rows.length ? result.rows[result.rows.length - 1].id : null
});
});GraphQL Optimization
Purpose
To resolve GraphQL execution bottlenecks (e.g., N+1 queries).
Rules
- Use dataloaders to batch and cache database operations during execution.
- Set complexity limits to block overly resource-intensive queries.
Examples
Node.js DataLoader Batch Resolver (loader.js)
const DataLoader = require('dataloader');
// Batch loader function to query users in a single request
const userBatchLoader = new DataLoader(async (keys) => {
const users = await db.query('SELECT id, username FROM users WHERE id = ANY($1)', [keys]);
// Map users back to keys in the correct order
const userMap = {};
users.rows.forEach(user => { userMap[user.id] = user; });
return keys.map(key => userMap[key] || null);
});Streaming
Purpose
To stream large data payloads sequentially, reducing memory overhead and time to first render.
Rules
- Stream file downloads and database outputs directly to response streams.
- Use Server-Sent Events (SSE) to push real-time updates without polling.
Examples
Node.js Database Query Stream Response (stream.js)
const QueryStream = require('pg-query-stream');
app.get('/api/export/orders', async (req, res) => {
const client = await dbPool.connect();
const query = new QueryStream('SELECT id, total_amount, created_at FROM orders');
const stream = client.query(query);
res.setHeader('Content-Type', 'text/csv');
res.setHeader('Content-Disposition', 'attachment; filename=export.csv');
// Stream data to client to keep server memory usage low
stream.on('data', (row) => {
res.write(`${row.id},${row.total_amount},${row.created_at}\n`);
});
stream.on('end', () => {
res.end();
client.release();
});
});Memory Optimization
Purpose
To identify, diagnose, and resolve application memory leaks and execution footprint bloat.
Rules
- Monitor heap memory profiles regularly to identify leaks.
- Clear references to unused objects to support garbage collection.
Workflow
- Run target applications with inspect flags (
node --inspect). - Take heap snapshot files during memory usage increases.
- Compare heap snapshots to identify persistent, uncollected objects.
- Refactor code to clear references to identified objects.
CPU Optimization
Purpose
To optimize CPU usage, improving throughput and server efficiency.
Rules
- Profile application runtimes using CPU tracing tools (e.g., Node.js Profiler).
- Offload long-running CPU tasks (e.g., parsing, calculations) to worker threads.
Examples
Node.js worker_threads Math Executor (worker-main.js)
const { Worker } = require('worker_threads');
function runHeavyCalculation(data) {
return new Promise((resolve, reject) => {
const worker = new Worker('./worker-task.js', { workerData: data });
worker.on('message', resolve);
worker.on('error', reject);
worker.on('exit', (code) => {
if (code !== 0) reject(new Error(`Worker stopped with exit code ${code}`));
});
});
}Load Testing
Purpose
To test system performance and latency metrics under simulated production loads.
Rules
- Run load tests in staging environments that match production configurations.
- Verify system error rates and response times remain within targets under load.
Examples
k6 API Performance Load Script (k6-performance.js)
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
stages: [
{ duration: '1m', target: 100 }, // Scale up to 100 users
{ duration: '3m', target: 100 }, // Maintain load
{ duration: '1m', target: 0 } // Scale down
],
thresholds: {
http_req_duration: ['p(95)<250'], // 95% of requests must complete under 250ms
http_req_failed: ['rate<0.01'] // Error rates must remain under 1%
}
};
export default function() {
const response = http.get('http://api.production.internal/health/live');
check(response, {
'status matches 200': (r) => r.status === 200
});
sleep(1);
}Stress Testing
Purpose
To identify system breaking points under extreme traffic volumes.
Rules
- Run stress tests only in isolated environments to prevent disruption to active systems.
- Monitor how systems fail and recover when resources are exhausted.
Workflow
- Set up monitoring dashboards to track system performance.
- Incrementally increase load beyond normal peak traffic volumes.
- Track the load levels where response times degrade or services fail.
- Verify systems recover automatically once traffic returns to normal levels.
Scalability Planning
Purpose
To plan system architectures that scale efficiently to handle increasing traffic.
Rules
- Design services to run state-free to support horizontal autoscaling.
- Partition and shard database storage to scale database capacity.
Workflow
flowchart TD
A["Estimate User Growth & Traffic Targets"] --> B["Identify System Bottlenecks"]
B --> C["Design Stateless Service Tiers"]
C --> D["Configure Database Shards & Read Replicas"]
D --> E["Establish Automated Autoscaling Rules"]Autoscaling
Purpose
To scale infrastructure resources dynamically based on application traffic.
Rules
- Define minimum and maximum replica limits to manage resource costs.
- Base autoscaling triggers on metrics like CPU usage or average request counts.
Examples
Kubernetes HPA Autoscaler Manifest (hpa-autoscaler.yaml)
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: api-autoscaler
namespace: production
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: api-service
minReplicas: 3
maxReplicas: 12
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70Profiling
Purpose
To measure and analyze application resource usage (CPU, memory) at the function level.
Rules
- Run profiling in environments that mimic production workloads.
- Use profiling data to identify and optimize the slowest functions.
Workflow
- Start the application with profiling enabled.
- Generate traffic matching production workloads using load test scripts.
- Collect CPU and heap profile data.
- Analyze profiles (e.g., using Flamegraphs) to locate slow functions.
Monitoring
Purpose
To track application health, latency, error rates, and resource usage in real-time.
Rules
- Monitor the Golden Signals of API systems: Latency, Traffic, Errors, and Saturation.
- Configure dashboards to display metrics clearly.
OpenTelemetry
Purpose
To standardize the collection and export of traces, metrics, and logs.
Rules
- Instrument codebases using OpenTelemetry standard libraries.
- Export telemetry data using open formats (e.g., OTLP).
Examples
Node.js OpenTelemetry SDK Setup (telemetry.js)
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-proto');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-proto');
const sdk = new NodeSDK({
traceExporter: new OTLPTraceExporter({
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces'
}),
metricReader: new OTLPMetricExporter({
url: process.env.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT || 'http://localhost:4318/v1/metrics'
}),
instrumentations: [getNodeAutoInstrumentations()]
});
sdk.start();Benchmarking
Purpose
To measure and compare execution times for specific code changes.
Rules
- Isolate environments to ensure test runs are stable and consistent.
- Run benchmarking code blocks multiple times to calculate statistically valid averages.
Examples
JavaScript Performance Benchmarking Script (benchmark.js)
const { PerformanceObserver, performance } = require('perf_hooks');
const obs = new PerformanceObserver((items) => {
const entry = items.getEntries()[0];
console.log(`Execution time for [${entry.name}]: ${entry.duration.toFixed(4)} ms`);
performance.clearMarks();
});
obs.observe({ entryTypes: ['measure'] });
function runIterationTest() {
performance.mark('A');
// Target code block to benchmark
let sum = 0;
for (let i = 0; i < 1000000; i++) {
sum += i;
}
performance.mark('B');
performance.measure('runIterationTest', 'A', 'B');
}
runIterationTest();Performance Testing
Purpose
To verify that code updates meet performance and response time budgets.
Rules
- Automate performance tests in deployment pipelines.
- Verify metrics match budgets before promoting releases.
Workflow
- Commit code updates to target branches.
- Trigger pipeline build stages.
- Deploy updates to the performance testing environment.
- Run load tests and verify metrics match budgets.
- If budgets pass, approve the release for promotion.
AI Performance
Purpose
To optimize LLM and vector database integrations, minimizing latency and API costs.
Rules
- Use token management and cache schemas to reduce API payload sizes.
- Batch vector queries to optimize vector database throughput.
Token Optimization
Purpose
To optimize prompt lengths, reducing API latency and costs.
Rules
- Compress prompts to remove unnecessary text before querying APIs.
- Cache common query embeddings to avoid recalculating vector values.
Examples
Python Prompt Compression Utility (token_optim.py)
import tiktoken
def calculate_token_count(text_content: str, model_name: str) -> int:
encoding = tiktoken.encoding_for_model(model_name)
return len(encoding.encode(text_content))
def compress_template_prompt(system_rules: str, context_details: str, user_query: str) -> str:
# Build a concise prompt by removing helper text if the token count exceeds limits
base_prompt = f"Rules: {system_rules}\nContext: {context_details}\nQuery: {user_query}"
token_count = calculate_token_count(base_prompt, "gpt-4")
if token_count > 2000:
# Strip comments or extra context if over limits
context_details = context_details[:1000] # Trim context
return f"Rules: {system_rules}\nContext: {context_details}\nQuery: {user_query}"
return base_promptCost Optimization
Purpose
To optimize resource usage, balancing performance requirements against server costs.
Rules
- Tag all cloud resources to track and allocate costs to specific environments or teams.
- Terminate unused or orphaned resources (e.g., detached disks, outdated snapshots) on schedule.
Examples
Serverless Auto-Scale Target Configuration (railway.json)
{
"service": {
"numReplicas": 3,
"scaling": {
"metric": "cpu",
"target": 70,
"minReplicas": 1,
"maxReplicas": 5
}
}
}Common Mistakes
Purpose
To document common performance mistakes, helping teams avoid latency and resource bottlenecks.
Rules
- Check query and loop executions for unnecessary database calls.
- Enforce caching for frequently accessed, unchanging data.
Common Mistakes & Remediation
- Mistake: Running database queries inside loops (N+1 queries).
- Remediation: Retrieve data in single, batch queries.
- Mistake: Downloading uncompressed, full-resolution images.
- Remediation: Convert assets to optimized WebP/AVIF formats.
- Mistake: Bypassing caching for database queries that return static list options.
- Remediation: Cache static list outputs in Redis with realistic TTL parameters.
Anti Patterns
Purpose
To identify and remediate design patterns that degrade application performance and scalability.
Rules
- Avoid sharing database connections without connection pooling.
- Do not run CPU-intensive tasks on single-threaded application runtimes (e.g., Node.js main thread).
Workflow
flowchart TD
A["Scan Code for Performance Anti-Patterns"] --> B["Locate database calls inside loops"]
B --> C["Refactor using batch queries or joins"]
C --> D["Locate CPU-heavy operations on main thread"]
D --> E["Offload operations to worker threads"]Engineering Checklist
Purpose
To provide a final validation checklist, verifying performance optimization criteria are met.
Checklist
- Performance Budgets: Webpack bundles and static assets fit within size budgets.
- Core Web Vitals: Pages pass Chrome User Experience baseline limits (LCP < 2.5s, CLS < 0.1, INP < 200ms).
- Code Splitting: Frontend route assets load dynamically using code-splitting features.
- Asset Compression: Brotli/Gzip parameters compress static text assets on proxies.
- Image Formats: Images serve optimized WebP/AVIF formats with explicit width/height dimensions.
- Query Execution: Database queries are indexed; no N+1 query loops exist in code.
- Caching Strategy: Redis cache instances manage frequently requested static data.
- Asynchronous Workers: Long-running CPU operations offload to background queues or workers.
- Telemetry Logging: OpenTelemetry metrics and traces export to central monitoring endpoints.
- Load Verification: Load tests confirm response times meet budgets under simulated traffic.
Self Review Engine
Purpose
To define a self-criticism engine that audits performance configurations before returning code.
Rules
- Analyze all generated templates and code snippets against the review workflow prior to delivery.
- Resolve any performance or scalability bottlenecks identified during review.
Workflow
flowchart TD
Start["Draft Code/Config Completed"] --> Q1{"Is database query inside loop?"}
Q1 -- Yes --> R1["Refactor to query values in single batch"] --> Q2
Q1 -- No --> Q2{"Are assets uncompressed?"}
Q2 -- Yes --> R2["Inject Brotli/Gzip configuration settings"] --> Q3
Q2 -- No --> Q3{"Are HTML image dimensions missing?"}
Q3 -- Yes --> R3["Configure explicit width & height tags"] --> Q4
Q3 -- No --> Q4{"Are CPU-heavy tasks on main thread?"}
Q4 -- Yes --> R4["Refactor to use background queues / worker threads"] --> Q5
Q4 -- No --> Q5{"Is caching omitted on static endpoints?"}
Q5 -- Yes --> R5["Inject Redis cache read-through checks"] --> End
Q5 -- No --> End["Deliver Optimized Production-Grade Code"]References
Purpose
To list core specifications, standards, and guidelines governing performance engineering.
Recommended References
- W3C Web Performance Working Group Specifications: Authoritative metrics standards.
- Google Chrome Web Dev Documentation: Best practices for optimizing Core Web Vitals.
- The Art of Computer Systems Performance Analysis: Authoritative systems tuning text.
- Designing Data-Intensive Applications: Database structures and scaling guidelines.
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
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.

