⚡ PromptLoot

Home › AI Agents

AI Agent Run Postmortem Prompt (Find the Real Fix)

When an AI agent does something wrong, reconstruct what happened from logs and decide the right fix: a prompt edit, a rules-file change, a test, or a hard permission limit.

Added

You are an incident reviewer for AI agents. An agent run went wrong. Help me write a blameless postmortem and pick fixes that stop it happening again.

## What went wrong
[ONE OR TWO SENTENCES: e.g. the support agent issued a $400 refund without approval / the coding agent deleted a migration and said "done"]

## Evidence
- Agent and model: [e.g. Claude Code, GPT-x, custom agent on LangGraph]
- System prompt / CLAUDE.md / skills in use: [PASTE OR LINK]
- Tools and permissions it had: [e.g. shell, git push, Stripe refunds up to any amount]
- Transcript or logs: [PASTE THE RUN, including tool calls and outputs]
- What the user asked for: [PASTE]

## Step 1: Timeline
A numbered timeline of the run: each step, what the agent decided, which tool it called, and the result. Mark the first step where it went off track.

## Step 2: Root cause
Pick the main cause and say why, quoting the log:
- Missing or unclear instruction
- Conflicting instructions
- Instruction ignored (rule existed but the agent didn't follow it)
- Bad tool output or missing context
- Permission too broad (the agent could do something it never should)
- No verification step (it claimed success without checking)

## Step 3: Fixes, strongest first
For each fix, give the exact change and where it goes:
1. Hard limit outside the model: tool permission, spending cap, approval step, sandbox. Use this for anything with money, data deletion, or outside messages.
2. Check: a test, lint rule, or verify-before-done step the agent must pass.
3. Rules file or system prompt edit: a before/after snippet, one or two lines.
4. Regression test case: input, expected behavior, pass criteria, so this exact failure is caught next time.

## Step 4: Postmortem doc
Write it with headings: Summary, Impact, Timeline, Root cause, Fixes (owner + status), Test case added. Keep it under one page.

Rules: no blame, quote the log for every claim, and say "unknown" instead of guessing when the evidence doesn't show something.

How to use it

  1. Click Copy template.
  2. Paste into ChatGPT, Claude, Grok, Cursor, or your agent framework.
  3. Replace the [BRACKETED] parts with your details.

Pairs well with: Audit Untrusted AGENTS.md, CLAUDE.md & SKILL.md Files

Sponsor this page · Reach builders who use AI daily. Get details

FAQ

What should I log for an AI agent run?

At minimum: the model and version, the system prompt and rules files in use, every tool call with inputs and outputs, permissions, the user request, and cost. Without those you can't reconstruct why it acted.

Should I fix agent mistakes in the prompt?

Only for low-risk behavior. Anything involving money, deleting data, or messaging people should be limited outside the model with permissions or approval steps, because prompts can be ignored.

How do I stop the same failure coming back?

Turn each incident into a regression test case and rerun your test set whenever you change the prompt, model, or tools.

Get 3 new templates every week

Free. Unsubscribe anytime.

Related templates

System Prompt Regression Test Set (Evals for Prompts & Skills)

Edit your system prompt, CLAUDE.md, or agent skill without fear: build a small eval set, rerun it after every change, and catch regressions before users do.

General AI Agent System Prompt

A solid base system prompt for any tool-using AI agent.

Headless Agent Run Prompt: Guardrails for CI, Cron & claude -p

Task prompt and checklist for unattended Claude Code, Codex, or Gemini CLI runs in CI or cron: turn and spend caps, restated guardrails, a JSON report.

Browse all AI Agents templates

New on PromptLoot

Check Current Docs First: Stop Agents Using Outdated APIs

Rules that make Claude Code, Cursor, and Codex check your installed versions and current docs before calling any API, cite the version, and flag deprecations.

Minimal Diff Rules: Stop AI Agents Rewriting Unrelated Code

Rules for Claude Code, Cursor, and Codex: change only what you asked, no drive-by renames, refactors, or reformatting, and list every changed file.
PromptLoot Pro Pack · 200+ advanced templates, agent workflows, and Cursor rules bundles. Coming soon