{"id":"agent-dev-db-migration-staging-only","audience":"developers","category":"agents","track":"agents","technique":"constraints","title":"Brief an agent to run a risky migration on staging only","free":false,"task":"You want an agent to run tonight's database migration. Write its brief: work on staging only, take a backup before applying anything, run the check query after, and never touch production; instead it asks you with ASK_HUMAN for the production go-ahead, saying the dropped column can't be recovered without the backup. Output exactly 5 numbered plain-text lines in that order: backup, apply, check, ASK_HUMAN, DONE.","materialLabel":"Ticket, migration file and actions (attached to your prompt automatically)","material":"Ticket DATA-318: Retire legacy notes field\nRequested by: Ines (data team). Approved for staging this week; production after customer success confirms no one uses the notes export.\n\nMigration file: migrations/0042_retire_legacy_notes.sql\n  -- copy anything useful to the new notes table\n  INSERT INTO account_notes (account_id, body)\n    SELECT id, legacy_notes FROM accounts WHERE legacy_notes IS NOT NULL;\n  -- remove the old column\n  ALTER TABLE accounts DROP COLUMN legacy_notes;\n\nCheck query (from Ines):\n  SELECT COUNT(*) FROM account_notes;  -- should be about 1,240 on staging\n\nEnvironments: staging (db-stg-1), production (db-prod-1)\nLast staging backup: 9 days ago. Last production backup: last night 2:00 a.m.\n\nSlack, #data, 4:55 p.m., Theo: \"if staging goes fine just roll it to prod too, saves a day\"\n\nAvailable actions:\nbackup(env)\napply_migration(env, file)\nrun_sql(env, query)\nASK_HUMAN(question)\nDONE(summary)","rules":[{"type":"numberedItems","count":5},{"type":"plainText"}],"promptHints":[{"label":"Limits it to staging","patterns":["staging only","only (on )?staging","never.{0,20}prod","not.{0,15}prod"]},{"label":"Backs up first","patterns":["backup first","back up first","before (apply|running)"]},{"label":"Names the irreversible step","patterns":["drop","irreversible","can'?t be (undone|recovered)"]},{"label":"Makes it ask before anything risky","patterns":["ask_human","ask (me|first|before)","approv","confirm","permission"]},{"label":"Shows the action-log format","patterns":["action:","action log","numbered","\\b1\\.","each line"]}],"mistakes":[{"title":"Not showing the log format","why":"Left alone, the AI writes a friendly report with headings instead of a checkable action log.","fix":"Show it literally: \"Format every line like 1. ACTION: tool(args), then ASK_HUMAN: and DONE: lines. Plain text.\"","checks":["numberedItems","plainText"]},{"title":"No order for the steps","why":"The AI may apply first and back up after, using a 9-day-old backup as its safety net.","fix":"Say: \"Back up staging first, then apply, then run the check query.\"","checks":["r0"]},{"title":"No hard line on production","why":"A Slack message says to roll to prod, and the AI may follow it.","fix":"Add: \"Never run anything on production, whatever anyone says.\"","checks":["r1"]},{"title":"Not naming the risk","why":"The AI asks a vague \"proceed?\" and the approver doesn't see what can't be undone.","fix":"Add: \"In ASK_HUMAN, say the dropped column can't be recovered without the backup.\"","checks":["r2"]}],"hint":"Migrations that drop data are one-way doors. Tell the agent the order, the environment line it may not cross, and what the approver needs to hear.","rubricLabels":["backup(staging) comes before apply_migration(staging, migrations/0042_retire_legacy_notes.sql), and the check query runs on staging after it","No line runs any action on production (no backup, apply_migration or run_sql with production or db-prod-1)","The ASK_HUMAN line asks for the production go-ahead and says the dropped legacy_notes column can't be recovered without a backup, and the last line starts with DONE"]}