serverless-debugger
FreeNo executable scriptsNot checkedDebug and optimize serverless functions (AWS Lambda, Vercel Functions, Cloudflare Workers). Use when someone asks to "debug Lambda", "trace serverless…
by TerminalSkills★ 221 GitHub starsAbout this skill
Serverless Debugger
Overview
This skill helps you trace, debug, and optimize serverless function invocations. It correlates logs across chained functions, identifies cold start bottlenecks, analyzes timeout patterns, and generates optimized configurations to reduce latency and failure rates.
Instructions
Log Analysis and Request Tracing
When given CloudWatch logs, Vercel logs, or similar:
- Find the request: Search for correlation ID, request ID, or timestamp range
- Build the trace: Follow the request across all functions it touches, ordered by timestamp
- Identify the failure point: Mark where errors, timeouts, or unexpected behavior occurred
- Root cause: Determine why — cold start, timeout, OOM, unhandled exception, downstream failure
- Present as timeline: Show each function invocation with START, key events, and END/ERROR
Cold Start Analysis
When given invocation metrics or asked to analyze cold starts:
- Identify cold start invocations: Look for
Init Durationin CloudWatch or equivalent - Calculate statistics: P50, P95, P99 init durations per function
- Find patterns: Time-of-day distribution, correlation with deployment events
- Diagnose causes:
- Large bundle size (>5MB is concerning, >10MB is critical)
- Too many dependencies loaded at init
- Heavy top-level initialization (DB connections, SDK clients)
- Low memory allocation (Lambda CPU scales with memory; 1,769 MB is one full vCPU)
- Check what the init costs: since August 1, 2025, the init phase of on-demand ZIP functions on managed runtimes is included in Billed Duration, so slow cold starts cost money as well as latency. Provisioned Concurrency and custom runtimes were already billed this way.
- Recommend fixes in priority order:
- Tree-shake and bundle with esbuild/rollup (biggest impact)
- Migrate AWS SDK for JavaScript v2 → v3 (modular imports). v2 reached end of support on September 8, 2025 and gets no more updates.
- Lazy-load heavy dependencies (only import when needed)
- Increase memory allocation (more CPU = faster init)
- Provisioned concurrency for latency-critical functions
- Move to ARM/Graviton2 (10-20% faster init, 20% cheaper)
Timeout Debugging
- Check if timeout is from cold start + execution exceeding limit
- Check for synchronous waits on downstream services
- Check for missing
awaiton promises (function exits before async work completes) - Check for connection pool exhaustion (DB, HTTP clients)
- Recommend appropriate timeout values based on P99 execution time + buffer
Platform limits to check first:
- Lambda: memory 128–10,240 MB in 1 MB steps; CPU is proportional to memory.
- Vercel Functions (fluid compute, on by default): default max duration 300 s. Hobby is capped at 300 s; Pro and Enterprise can go to 800 s. Up to 1,800 s is in beta for supported runtimes. Set it with
export const maxDuration = 800;in a Next.js route, or withfunctionsinvercel.jsonfor other frameworks. - Cloudflare Workers: the limit is CPU time, not wall-clock time. Free allows 10 ms of CPU per request. Paid defaults to 30 s and can be raised to 5 min.
For a Vercel function outside Next.js, raise the limit per path in vercel.json:
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"functions": {
"app/api/checkout/**/*.ts": {
"maxDuration": 60
}
}
}
Configuration Generation
Generate platform-specific configs:
- AWS SAM/CloudFormation: template.yaml with memory, timeout, provisioned concurrency
- Serverless Framework: serverless.yml with
build.esbuildsettings (v4). Projects on v3 with theserverless-esbuildplugin put the same settings undercustom.esbuild. - CDK: TypeScript constructs with optimized settings
- Vercel: vercel.json with function configuration
Examples
Example 1: Tracing a Timeout
Input: "My order-processor Lambda timed out at 14:32 UTC. Here are CloudWatch logs."
Output:
Request Trace — req-abc123
14:32:01.100 [api-gateway] Request received: POST /orders
14:32:01.203 [auth-handler] ✅ 15ms — Token validated
14:32:01.340 [order-processor] START — Warm invocation
14:32:01.355 [order-processor] Validating order payload... OK
14:32:01.412 [order-processor] Calling inventory-check (sync HTTP)
14:32:31.412 [order-processor] ❌ TIMEOUT (30s limit reached)
Cause: inventory-check function had a 28s cold start (256MB memory,
22MB bundle). order-processor's synchronous HTTP call waited for the
full cold start + execution, exceeding its 30s timeout.
Fix: Set inventory-check to 1024MB memory (reduces cold start to ~4s),
add provisioned concurrency of 1, or make the call async with SQS.
Example 2: Cold Start Optimization
Input: "Our payment function has 5s cold starts. Here's the package.json and handler code."
Output:
Cold Start Diagnosis — payment-handler
Current: 512MB memory | 18.4MB bu
Install serverless-debugger in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the serverless-debugger skill do?
Debug and optimize serverless functions (AWS Lambda, Vercel Functions, Cloudflare Workers). Use when someone asks to "debug Lambda", "trace serverless request", "fix cold starts", "analyze CloudWatch logs", "optimize Lambda performance", "reduce init duration", or "troubleshoot function timeout". Correlates logs across invocations and generates fixes.
How do I install the serverless-debugger skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the serverless-debugger skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic