Add a table of contents to a long post

ContentIntermediate~10 min

Before you start

A connected site with content reads and content writes enabled so the agent can read the post and, on your approval, update it.

A long guide without a table of contents makes readers scroll and guess. You know it needs one, but building it by hand means copying every heading, creating an anchor for each, and wiring the links, then redoing the whole thing the next time you add a section.

This reads the post’s headings, builds the anchored list, and drops it in at the top once you have seen it.

The prompt
Read the post at [/guides/complete-setup/] and add a table of contents. Do not
change anything yet.
Pull the headings in order and build a table of contents from them, with each
entry linking to its own section. Show me the list first so I can check the
headings and the order. Change nothing until I approve.
Once I approve, insert the table of contents near the top of the post, below
the intro, and add the anchors the links need. Do not rewrite my headings or
body copy, and do not change whether the post is published. When you are done,
tell me what you added and remind me the old version is saved as a revision.

Why this is safe to run

Reading the post and building the list writes nothing, so you see the exact table of contents and can fix the order or the wording before anything saves.

The write inserts the table of contents and the heading anchors and leaves your heading text and body copy alone. It never changes whether the post is published, and WordPress keeps the previous version as a revision, so pulling the table of contents back out later is easy. The update ability stays off until you enable it, every call is checked against the capability of the user you bound the agent to, and the edit lands in the Activity Log with the post it touched.

Already connected? Skip the paste. Ask your agent for the “add a table of contents to a long post” recipe, or just point it at a long post, and it runs the same read-approve-insert flow on your own site.

How it works

  1. Read the post you name and pull its headings in order.
  2. Build an anchored table of contents from those headings and show it to you.
  3. Wait for approval before touching the post.
  4. Insert the table of contents near the top, linking each entry to its section.
  5. Return what it changed and note the old version is saved as a revision.

Questions

Do the links jump to the right sections?
Yes. The agent anchors each heading and points each table-of-contents entry at its own section, so the links scroll to the matching part of the post.
Will it rewrite my headings?
No. It reads your headings as they are and builds the list from them. It adds the table of contents and the anchors, and leaves your heading text and body copy alone.