Agent Wranglers

DOC-18Recommended

Put a stop before every destructive step in a runbook

Mark every runbook step that deletes data, drops a table or destroys infrastructure with a stop line. Say what is lost, how to undo it and who must approve it.

How to do it

A person half awake, or an agent that follows steps literally, runs whatever comes next. Put the stop line just before the command, such as "STOP. This deletes every order in staging. Undo by restoring the 06:00 backup." Write each command in its own fenced block, never in a screenshot, so it can be copied and checked. Keep runbooks as Keep runbooks next to the code they run says, and restores as Write the restore runbook says. Agents also need the permission limits from Review agent settings like code.

Examples

JavaScript example

const DESTRUCTIVE = /\b(DROP|DELETE FROM|TRUNCATE|rm -rf|terraform destroy|kubectl delete)\b/i;

export function unmarkedDestructiveBlocks(markdown) {
  const blocks = [...markdown.matchAll(/([^\n]*)\n+```\w*\n([\s\S]*?)```/g)];
  return blocks.filter(([, lineAbove, code]) => DESTRUCTIVE.test(code) && !lineAbove.startsWith('STOP.'));
}

Python example

import re

DESTRUCTIVE = re.compile(r"\b(DROP|DELETE FROM|TRUNCATE|rm -rf|terraform destroy|kubectl delete)\b", re.I)

def unmarked_destructive_blocks(markdown: str) -> list[str]:
    blocks = re.findall(r"([^\n]*)\n+```\w*\n(.*?)```", markdown, re.S)
    return [code for line_above, code in blocks if DESTRUCTIVE.search(code) and not line_above.startswith("STOP.")]

How to check

A script scans every code block in docs/runbooks/ for destructive commands, such as DROP, DELETE FROM, TRUNCATE, rm -rf, terraform destroy and kubectl delete. Each one has a line starting with STOP. directly above its block.

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/documentation/docs-for-coding-agents/destructive-step-stops">Agent Wranglers documentation playbook</a>. In code you write, add a comment next to it with the same link.