Agent skill
backend-latency-profiler-helper
Identifies API latency hotspots and bottlenecks with profiling tools, slow endpoint detection, suspected causes, and fix roadmap. Use for "latency profiling", "performance bottlenecks", "slow APIs", or "backend performance".
Install this agent skill to your Project
npx add-skill https://github.com/patricio0312rev/skills/tree/main/performance/backend-latency-profiler-helper
SKILL.md
Backend Latency Profiler Helper
Find and fix API performance bottlenecks.
Slow Endpoint Detection
// Middleware to track latency
app.use((req, res, next) => {
const start = Date.now();
res.on("finish", () => {
const duration = Date.now() - start;
if (duration > 1000) {
logger.warn(
{
endpoint: req.path,
method: req.method,
duration_ms: duration,
userId: req.user?.id,
},
"Slow request detected"
);
}
});
next();
});
Top Slow Endpoints
-- Query from logs
SELECT
endpoint,
AVG(duration_ms) as avg_ms,
MAX(duration_ms) as max_ms,
COUNT(*) as requests
FROM request_logs
WHERE created_at > NOW() - INTERVAL '1 day'
GROUP BY endpoint
HAVING AVG(duration_ms) > 500
ORDER BY avg_ms DESC
LIMIT 10;
Suspected Causes
interface PerformanceBottleneck {
endpoint: string;
avgLatency: number;
suspectedCauses: string[];
fixPriority: "high" | "medium" | "low";
}
const bottlenecks: PerformanceBottleneck[] = [
{
endpoint: "GET /api/users/:id",
avgLatency: 2500,
suspectedCauses: [
"N+1 query fetching user orders",
"No database index on user_id",
"Expensive JSON serialization",
],
fixPriority: "high",
},
];
Fix Roadmap
# Performance Fix Roadmap
## Week 1: Quick Wins
- [ ] Add database indexes
- [ ] Enable response caching
- [ ] Fix N+1 queries
## Week 2: Medium Effort
- [ ] Optimize slow database queries
- [ ] Implement Redis caching
- [ ] Add connection pooling
## Week 3: Long-term
- [ ] Database query optimization
- [ ] Service decomposition
- [ ] CDN integration
Output Checklist
- Slow endpoints identified
- Causes analyzed
- Fix roadmap created
- Monitoring configured ENDFILE
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
rate-limiting-abuse-protection
Implements rate limiting and abuse prevention with per-route policies, IP/user-based limits, sliding windows, safe error responses, and observability. Use when adding "rate limiting", "API protection", "abuse prevention", or "DDoS protection".
rbac-permissions-builder
Implements role-based access control with permission matrix, route guards, policy functions, and UI permission hints. Provides middleware/guards, helper utilities, test suggestions, and permission checking patterns. Use when building "RBAC", "permissions", "access control", or "authorization".
websocket-realtime-builder
Implements real-time features using WebSockets with Socket.io, rooms, authentication, and reconnection handling. Use when users request "real-time updates", "WebSocket", "Socket.io", "live chat", or "push notifications".
webhook-receiver-hardener
Secures webhook receivers with signature verification, retry handling, deduplication, idempotency keys, and error responses. Provides verification code, dedupe storage strategy, runbook for incidents. Use when implementing "webhooks", "webhook security", "event receivers", or "third-party integrations".
auth-module-builder
Implements secure authentication patterns including login/registration, session management, JWT tokens, password hashing, cookie settings, and CSRF protection. Provides auth routes, middleware, security configurations, and threat model documentation. Use when building "authentication", "login system", "JWT auth", or "session management".
rest-to-graphql-migrator
Migrates REST APIs to GraphQL incrementally with schema stitching, REST datasources, and gradual endpoint migration. Use when users request "migrate to GraphQL", "REST to GraphQL", "GraphQL wrapper", or "API modernization".
Didn't find tool you were looking for?