Audit error handling gaps in async or promise-based code
Async code is where error handling silently fails most often — unhandled rejections, swallowed exceptions, and missing fallbacks cause production incidents. This prompt audits a code block specifically for these gaps.
You are a reliability engineer auditing async code for error handling gaps. I have a block of asynchronous code that I want to harden before it ships.
Language: {{LANGUAGE}} (e.g. JavaScript/TypeScript with Promises, Python with asyncio, Kotlin coroutines)
Code to audit:
```
{{ASYNC_CODE_BLOCK}}
```
Context on failure tolerance: {{FAILURE_TOLERANCE}} (e.g. 'this runs in a background worker — partial failure is acceptable' or 'this is in the critical checkout path — any failure must surface to the user')
Follow these steps:
1. List every async call, Promise, or awaited expression in the code.
2. For each one, identify whether it has explicit error handling (try/catch, .catch(), Result type, etc.).
3. Flag any async call with no error handling at all. These are highest priority.
4. Flag any catch block that swallows errors silently (catches but does not log, rethrow, or return an error state).
5. Flag any place where a failed async call could leave shared state (variables, DB records, cache) in a partially-updated state.
6. For each flagged issue, suggest the minimum viable fix. Do not redesign the whole function — only patch the gaps.
7. If any fix changes observable behavior (e.g. now surfaces an error that was previously hidden), call that out explicitly.
Do not suggest converting the entire codebase to a Result/Either pattern unless the existing code already uses one. {{LANGUAGE}}{{ASYNC_CODE_BLOCK}}{{FAILURE_TOLERANCE}}
How to use this prompt
- Copy the prompt above (Copy button on the top-right).
- Replace each
{{VAR}}with your own value. Variables:{{LANGUAGE}}{{ASYNC_CODE_BLOCK}}{{FAILURE_TOLERANCE}}. - Paste it into one of the recommended tools below.
- Iterate: tighten constraints in the prompt if the output is generic.
Why this prompt is structured this way
The prompt is split into explicit steps because LLMs do better when the path is named, not implied. Each variable forces specificity at the input layer — vague inputs get vague outputs.
Pair this prompt with a tool
Cursor
$20/moAI-first code editor forked from VS Code.
Cursor is VS Code with first-class LLM integration. Multi-file edits, codebase Q&A, autocomplete that's actually useful. The default IDE for many shipping engineers in 2026.
Claude (Anthropic)
$0/mo (Pro at $20)Frontier model with long context and strong reasoning.
Claude (Opus / Sonnet / Haiku tiers) is the assistant favored by writers and engineers who care about reasoning quality and tone. 1M token context on Opus.
ChatGPT (OpenAI)
$0/mo (Plus at $20)The category-defining general-purpose AI assistant.
ChatGPT has the broadest feature surface: image gen, voice, custom GPTs, web browsing, code execution. Often the right default; sometimes beaten on specific tasks by Claude or Perplexity.
The PlaybookPrompts weekly
One short email per week. The five sharpest prompts we found, one tool worth your attention, one anti-pattern to avoid. Unsubscribe in one click.
Newsletter signup is not configured. Set PUBLIC_NEWSLETTER_USERNAME in the build env.