Library › Agents & Automation AI › Software developers

Brief an agent to propose branch cleanup instead of deleting

  • For Software developers
  • You practice Setting limits and rules
  • Time about 5 minutes

About this exercise

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.

Common mistakes when you ask AI for this

  • Not showing the log format. Left alone, the AI writes a friendly report with headings instead of a checkable action log. Try: Show it literally: "Format every line like 1. ACTION: tool(args), then ASK_HUMAN: and DONE: lines. Plain text."
  • No clear rule. The AI follows the teammate and marks everything over a month old, merged or not. Try: Say: "Only branches merged into main and older than 30 days."
  • No protected branches. The AI marks a release branch and branches with open PRs. Try: Add: "Never touch main or release/. Skip branches with open PRs."
  • Letting it delete. Given delete_branch, the AI deletes right away, and some work is gone. Try: Add: "Never delete. Mark them and ask me to approve."

What a strong prompt includes

  • Sets the rule
  • Protects key branches
  • Skips open PRs
  • Forbids deleting
  • Shows the action-log format

Practice this now ↑

Related exercises