Clean up orphaned reusable blocks

ContentIntermediate~15 min

Before you start

A connected site with content reads on and the delete-block write ability enabled. Trashed blocks are recoverable, but take a backup before a large cleanup anyway.

Synced blocks pile up quietly. You duplicate one to try a layout, build a couple of test blocks, keep an old promo you meant to delete, and a year later the reusable-blocks list is a junk drawer nobody wants to sort by hand.

This prompt does the sorting for you and leaves the deciding with you. It lists every synced block, reads what is inside each, and hands you a shortlist of likely-dead ones. Nothing is removed until you say so, and anything it trashes can be restored.

The prompt
I want to clean up the synced (reusable) blocks on this site. Work in two
passes and change nothing in the first.
First pass: list every synced block with its title, slug, and last-modified
date, then open each one so you can see what it holds. Hand me back a table of
cleanup candidates, the blocks that look dead, empty, duplicated, or like old
test blocks, with a one-line note on why each made the list.
I will tell you which ones to remove. Only after I confirm, move the approved
blocks to the Trash in small batches, pausing to show me each batch. At the
end, list every block you trashed so I can restore any I want back.

Why this is safe to run

The whole first pass is reads. Listing the blocks and opening each one writes nothing, so you get to see the full shortlist as a table before a single block moves. One honest limit worth knowing: with these abilities the agent can read the blocks themselves but cannot scan every page to prove a block is unused, so it flags the likely-dead ones and you make the final call.

The delete half is recoverable by design. delete-block moves a block to the Trash rather than erasing it, so a block you remove by mistake is one restore away. On top of that, the delete ability stays off until you enable it, every call is checked against the capability of the user you bound the agent to, and every removal lands in the Activity Log with the block it touched.

Already connected? Skip the paste. Ask your agent for the “clean up orphaned reusable blocks” recipe, or just ask it to shortlist your dead synced blocks, and it runs the same two-pass flow on your own site.

How it works

  1. List every synced (reusable) block with its title, slug, and last-modified date.
  2. Read each block so you can see what it holds, including the empty or duplicate ones.
  3. Hand you a table of cleanup candidates and wait for you to confirm which to remove.
  4. Trash only the blocks you approve, in small batches, pausing between them.
  5. Return the list of blocks it trashed so you can restore any you want back.

Questions

Can it tell which blocks are truly unused?
Not on its own with these abilities. It lists and reads every synced block and flags the likely-dead ones, but you confirm which are safe to remove before anything is trashed.
Is a deleted block gone for good?
No. delete-block moves the block to the Trash, where you can restore it. It is never a permanent delete, so a wrong call is one restore away.