Investigation Mode — Orchestrated Debugging
When a user reports something stuck, hung, broken, or not responding, you are the diagnostic coordinator. Do not guess. Follow the triage order, report what you find at every step, and stop when you have a high-confidence root cause.
Reporting Contract
Every investigation step MUST follow this pattern:
- Tell the user what you are checking — "I'm checking the runtime logs for errors…"
- Share the evidence you found — paste the relevant log line, status, error, or screenshot
- Explain the next step — "The logs show a timeout on the DB call. I'll check the connection pool next."
Never silently move between steps. The user is already frustrated — silence makes it worse.
Triage Order
Work through these in order. Stop as soon as you find the root cause.
1. Runtime Logs (check first — most issues leave traces here)
- Dev server: Check terminal output for errors, warnings, unhandled rejections
- Vercel logs:
vercel logs --follow (production) or vercel logs <deployment-url>
- Browser console: Open DevTools → Console tab for client-side errors
- If no logs exist: This is the problem. Add logging before continuing (see "Add Logging" below)
Tell the user: "Checking runtime logs…" → share what you found → explain next step.
2. Workflow / Background Job Status
If the app uses workflows, queues, or cron jobs:
- Run
vercel workflow runs list to check recent run statuses
- Look for runs stuck in
running state — likely a missing await or unresolved promise
- Check individual run details:
vercel workflow runs get <run-id>
- Look for failed steps, retry exhaustion, or timeout errors
Tell the user: "Checking workflow run status…" → share the run state → explain next step.
3. Browser Verification
Use agent-browser to visually verify what the user sees:
- Take a screenshot of the current page state
- Check the browser console for JavaScript errors
- Check the Network tab for failed requests (4xx/5xx, CORS errors, hanging requests)
- Look for hydration mismatches or React error boundaries
Tell the user: "Taking a browser screenshot to see the current state…" → share the screenshot → explain what you see.
4. Deploy / Environment Status
vercel inspect <deployment-url> — check build output, function regions, environment
vercel ls — verify the latest deployment succeeded
- Check for environment variable mismatches between local and production
- Verify the correct branch/commit is deployed
Tell the user: "Checking deployment status…" → share the deployment state → explain findings.
Stop Condition
Stop investigating when:
- You find a high-confidence root cause (specific error, missing env var, failed step, etc.)
- Two consecutive triage steps produce no signal — report what you checked and that you found no evidence, then ask the user for more context
Do not keep cycling through steps hoping something appears. If logs are empty and workflows look fine, say so and ask the user what they expected to happen.
Common Hang Causes
When logs point to code issues, check for these frequent culprits:
- Missing
await: Async functions called without await cause silent failures
- Infinite loops:
while(true) without break conditions, recursive calls without base cases
- Unresolved promises:
new Promise() that never calls resolve() or reject()
- Missing env vars:
process.env.X returning undefined causing silent auth/DB failures
- Connection pool exhaustion: Database connections not being released
- Middleware chains: A middleware that never calls
next() or returns a response
- Timeout misconfigs: Function timeout too short for the operation (check
vercel.json maxDuration)
Add Logging (If Missing)
If the investigation reveals insufficient observability, add structured logging immediately — you cannot debug what you cannot see.
// API routes — wrap handlers with try/catch + logging
export async function POST(request: Request) {
console.log('[api/route] incoming request', { method: 'POST', url: request.url });
try {
const result = await doWork();
console.log('[api/route] success', { resultId: result.id });
return Response.json(result);
} catch (error) {
console.error('[api/route] failed', { error: String(error), stack: (error as Error).stack });
return Response.json({ error: 'Internal error' }, { status: 500 });
}
}
// Workflow steps — log entry/exit of every step
const result = await step.run('process-data', async () => {
console.log('[workflow:process-data] step started');
const data = await fetchData();
console.log('[workflow:process-data] step completed', { count: data.length });
return data;
});
Key principle: Every async boundary, every external call, every step entry/exit should have a log line. When something hangs, the last log line tells you exactly where it stopped.
Cross-reference: For comprehensive logging setup (OpenTelemetry, log drains, Sentry, Vercel Analytics), see the observability skill. For workflow-specific debugging, see the workflow skill.
1---2name: investigation-mode3description: "Orchestrated debugging coordinator. Triggers on frustration signals (stuck, hung, broken, waiting) and systematically triages: runtime logs → workflow status → browser verify → deploy/env. Reports findings at every step."4summary: "Debug stuck/hung apps: check logs → workflow runs → browser → deployment"5metadata:6 priority: 87 docs:8 - "https://openai.com/index/introducing-codex/"9 pathPatterns:10 - "**/middleware.{ts,js,mjs}"11 - "**/lib/logger.{ts,js}"12 - "**/utils/logger.{ts,js}"13 - "**/instrumentation.{ts,js}"14 - "**/*.log"15 - "**/error.{tsx,ts,js,jsx}"16 - "**/global-error.{tsx,ts,js,jsx}"17 - "**/not-found.{tsx,ts,js,jsx}"18 bashPatterns:19 - '\bvercel\s+logs?\b'20 - '\bvercel\s+inspect\b'21 - '\btail\s+-f\b.*\.log'22 - '\bworkflow\s+runs?\b'23 - '\bvercel\s+ls\b'24 - '\bcurl\s+-[vI]'25 importPatterns: []26 promptSignals:27 phrases:28 - "nothing happened"29 - "still waiting"30 - "it's stuck"31 - "it's hung"32 - "nothing is happening"33 - "not responding"34 - "just sitting there"35 - "just sits there"36 - "seems frozen"37 - "is it frozen"38 - "frozen"39 - "why is it hanging"40 - "check the logs"41 - "check logs"42 - "where are the logs"43 - "how do I debug"44 - "how to debug"45 - "white screen"46 - "blank page"47 - "spinning forever"48 - "timed out"49 - "keeps timing out"50 - "no response"51 - "no output"52 - "not loading"53 - "debug this"54 - "investigate why"55 - "what went wrong"56 - "why did it fail"57 - "why is it failing"58 - "something is broken"59 - "something broke"60 - "seems broken"61 - "check what happened"62 - "check the status"63 - "where is the error"64 - "where did it fail"65 - "find the error"66 - "show me the error"67 - "why is it slow"68 - "taking forever"69 - "still loading"70 - "not finishing"71 - "seems dead"72 - "been waiting"73 - "waiting forever"74 - "stuck on"75 - "hung up"76 - "not progressing"77 - "stalled out"78 - "is it running"79 - "did it crash"80 - "keeps failing"81 - "why no response"82 - "where did it go"83 - "lost connection"84 - "never finishes"85 - "pending forever"86 - "queue stuck"87 - "job stuck"88 - "build stuck"89 - "request hanging"90 - "api not responding"91 allOf:92 - [stuck, workflow]93 - [stuck, deploy]94 - [stuck, loading]95 - [stuck, build]96 - [stuck, queue]97 - [stuck, job]98 - [hung, request]99 - [hung, api]100 - [frozen, page]101 - [frozen, app]102 - [check, why]103 - [check, broken]104 - [check, error]105 - [check, status]106 - [check, logs]107 - [debug, workflow]108 - [debug, deploy]109 - [debug, api]110 - [debug, issue]111 - [investigate, error]112 - [logs, error]113 - [logs, check]114 - [slow, response]115 - [slow, loading]116 - [timeout, api]117 - [timeout, request]118 - [waiting, response]119 - [waiting, forever]120 - [waiting, deploy]121 - [not working, why]122 - [not, responding]123 - [hanging, for]124 - [been, hanging]125 - [been, stuck]126 - [been, waiting]127 - [why, slow]128 - [why, failing]129 - [why, stuck]130 - [why, hanging]131 - [job, failing]132 - [queue, processing]133 anyOf:134 - "stuck"135 - "hung"136 - "frozen"137 - "broken"138 - "failing"139 - "timeout"140 - "slow"141 - "debug"142 - "investigate"143 - "check"144 - "logs"145 - "error"146 - "hanging"147 - "waiting"148 - "stalled"149 - "pending"150 - "processing"151 - "loading"152 - "unresponsive"153 noneOf:154 - "css stuck"155 - "sticky position"156 - "position: sticky"157 - "z-index"158 - "sticky nav"159 - "sticky header"160 - "sticky footer"161 - "overflow: hidden"162 - "add a button"163 - "create a button"164 - "style the button"165 minScore: 4166retrieval:167 aliases:168 - debug helper169 - troubleshooter170 - stuck helper171 - problem solver172 intents:173 - debug issue174 - fix stuck app175 - investigate error176 - triage problem177 entities:178 - runtime logs179 - workflow status180 - browser verify181 - triage182chainTo:183 -184 pattern: 'createWorkflow|use workflow|use step|@workflow/'185 targetSkill: workflow186 message: 'Workflow code detected during investigation — loading Workflow DevKit guidance for debugging durable execution, step replay, and hook state.'187 -188 pattern: 'VERCEL_URL|DEPLOYMENT_ID|vercel\.app|VERCEL_ENV'189 targetSkill: deployments-cicd190 message: 'Deployment context detected — loading Deployments guidance for inspecting builds, preview URLs, and production promotion.'191 skipIfFileContains: 'vercel\s+inspect|vercel\s+logs'192 -193 pattern: '@vercel/analytics|@vercel/speed-insights|otel|OpenTelemetry|instrumentation\.(ts|js)'194 targetSkill: observability195 message: 'Observability instrumentation detected — loading Observability guidance for log queries, tracing, and monitoring setup.'196197---198199# Investigation Mode — Orchestrated Debugging200201When a user reports something stuck, hung, broken, or not responding, you are the **diagnostic coordinator**. Do not guess. Follow the triage order, report what you find at every step, and stop when you have a high-confidence root cause.202203## Reporting Contract204205Every investigation step MUST follow this pattern:2062071. **Tell the user what you are checking** — "I'm checking the runtime logs for errors…"2082. **Share the evidence you found** — paste the relevant log line, status, error, or screenshot2093. **Explain the next step** — "The logs show a timeout on the DB call. I'll check the connection pool next."210211Never silently move between steps. The user is already frustrated — silence makes it worse.212213## Triage Order214215Work through these in order. Stop as soon as you find the root cause.216217### 1. Runtime Logs (check first — most issues leave traces here)218219- **Dev server**: Check terminal output for errors, warnings, unhandled rejections220- **Vercel logs**: `vercel logs --follow` (production) or `vercel logs <deployment-url>`221- **Browser console**: Open DevTools → Console tab for client-side errors222- **If no logs exist**: This is the problem. Add logging before continuing (see "Add Logging" below)223224Tell the user: "Checking runtime logs…" → share what you found → explain next step.225226### 2. Workflow / Background Job Status227228If the app uses workflows, queues, or cron jobs:229230- Run `vercel workflow runs list` to check recent run statuses231- Look for runs stuck in `running` state — likely a missing `await` or unresolved promise232- Check individual run details: `vercel workflow runs get <run-id>`233- Look for failed steps, retry exhaustion, or timeout errors234235Tell the user: "Checking workflow run status…" → share the run state → explain next step.236237### 3. Browser Verification238239Use agent-browser to visually verify what the user sees:240241- Take a screenshot of the current page state242- Check the browser console for JavaScript errors243- Check the Network tab for failed requests (4xx/5xx, CORS errors, hanging requests)244- Look for hydration mismatches or React error boundaries245246Tell the user: "Taking a browser screenshot to see the current state…" → share the screenshot → explain what you see.247248### 4. Deploy / Environment Status249250- `vercel inspect <deployment-url>` — check build output, function regions, environment251- `vercel ls` — verify the latest deployment succeeded252- Check for environment variable mismatches between local and production253- Verify the correct branch/commit is deployed254255Tell the user: "Checking deployment status…" → share the deployment state → explain findings.256257## Stop Condition258259**Stop investigating when:**260- You find a high-confidence root cause (specific error, missing env var, failed step, etc.)261- Two consecutive triage steps produce no signal — report what you checked and that you found no evidence, then ask the user for more context262263**Do not** keep cycling through steps hoping something appears. If logs are empty and workflows look fine, say so and ask the user what they expected to happen.264265## Common Hang Causes266267When logs point to code issues, check for these frequent culprits:268269- **Missing `await`**: Async functions called without await cause silent failures270- **Infinite loops**: `while(true)` without break conditions, recursive calls without base cases271- **Unresolved promises**: `new Promise()` that never calls `resolve()` or `reject()`272- **Missing env vars**: `process.env.X` returning `undefined` causing silent auth/DB failures273- **Connection pool exhaustion**: Database connections not being released274- **Middleware chains**: A middleware that never calls `next()` or returns a response275- **Timeout misconfigs**: Function timeout too short for the operation (check `vercel.json` maxDuration)276277## Add Logging (If Missing)278279If the investigation reveals insufficient observability, **add structured logging immediately** — you cannot debug what you cannot see.280281```typescript282// API routes — wrap handlers with try/catch + logging283export async function POST(request: Request) {284 console.log('[api/route] incoming request', { method: 'POST', url: request.url });285 try {286 const result = await doWork();287 console.log('[api/route] success', { resultId: result.id });288 return Response.json(result);289 } catch (error) {290 console.error('[api/route] failed', { error: String(error), stack: (error as Error).stack });291 return Response.json({ error: 'Internal error' }, { status: 500 });292 }293}294```295296```typescript297// Workflow steps — log entry/exit of every step298const result = await step.run('process-data', async () => {299 console.log('[workflow:process-data] step started');300 const data = await fetchData();301 console.log('[workflow:process-data] step completed', { count: data.length });302 return data;303});304```305306**Key principle**: Every async boundary, every external call, every step entry/exit should have a log line. When something hangs, the last log line tells you exactly where it stopped.307308> **Cross-reference**: For comprehensive logging setup (OpenTelemetry, log drains, Sentry, Vercel Analytics), see the **observability** skill. For workflow-specific debugging, see the **workflow** skill.