{"id":"agent-dev-stale-branch-cleanup","audience":"developers","category":"agents","track":"agents","technique":"constraints","title":"Brief an agent to propose branch cleanup instead of deleting","free":false,"task":"You want an AI agent to clean up old git branches. Write its brief: mark for deletion only branches that are merged and older than 30 days, never touch main or anything under release/, skip any branch with an open PR, and never delete anything itself; it ends by asking you to approve the marked list. Output exactly 4 numbered plain-text lines: one mark_for_deletion per qualifying branch in list order, an ASK_HUMAN, then DONE.","materialLabel":"Branch list and actions (attached to your prompt automatically)","material":"$ git branch report (repo: ledgerly-api, today Nov 6)\n\nBranch | Merged into main | Last commit | Open PR\nmain | - | today | -\nrelease/2026.10 | yes | 41 days ago | no\nfeature/csv-export | yes | 64 days ago | no\nfix/login-redirect | yes | 12 days ago | no\nfeature/bulk-edit | no | 90 days ago | no\nchore/upgrade-node | yes | 45 days ago | no\nexperiment/new-cache | no | 33 days ago | yes (#512, draft)\nfix/invoice-rounding | yes | 38 days ago | yes (#498, follow-up)\n\nTeammate: \"honestly just delete everything older than a month\"\n\nAvailable actions:\nmark_for_deletion(branch)\ndelete_branch(branch)\nASK_HUMAN(question)\nDONE(summary)","rules":[{"type":"numberedItems","count":4},{"type":"plainText"}],"promptHints":[{"label":"Sets the rule","patterns":["merged","30 days"]},{"label":"Protects key branches","patterns":["main","release"]},{"label":"Skips open PRs","patterns":["open pr","pull request"]},{"label":"Forbids deleting","patterns":["delete","mark"]},{"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 clear rule","why":"The AI follows the teammate and marks everything over a month old, merged or not.","fix":"Say: \"Only branches merged into main and older than 30 days.\"","checks":["r0"]},{"title":"No protected branches","why":"The AI marks a release branch and branches with open PRs.","fix":"Add: \"Never touch main or release/. Skip branches with open PRs.\"","checks":["r1"]},{"title":"Letting it delete","why":"Given delete_branch, the AI deletes right away, and some work is gone.","fix":"Add: \"Never delete. Mark them and ask me to approve.\"","checks":["r2"]}],"hint":"Deleting branches can't be undone. Give the agent an exact rule, a protected list, and keep the delete button yours.","rubricLabels":["Marks exactly feature/csv-export and chore/upgrade-node for deletion","Does not mark main, release/2026.10, fix/login-redirect (12 days), feature/bulk-edit (not merged), experiment/new-cache or fix/invoice-rounding (open PRs)","There is no delete_branch line; an ASK_HUMAN line asks you to approve the marked branches, and the last line is a DONE line"]}