AI Automations/Content pipeline
Guardrails for an agent that publishes to your CMS
Five constraints that keep a coding agent from inventing clients, hallucinating links or publishing without review.
// read first
On this page
Giving an agent write access to your CMS is a reasonable thing to do, right up until it publishes a case study for a client that does not exist. These are the constraints that make it safe, all of them enforced in the script rather than requested in a prompt.
1. Drafts by default, never publish implicitly
The publish flag must be explicit and must be absent from every example command an agent might copy. A draft costs nothing to discard; a published page has already been crawled.
const publish = process.argv.includes("--publish");
const id = publish ? docId : `drafts.${docId}`;2. A model may choose, never generate, an identifier
Every reference — collection, category, author, related post — is resolved against a live list. If the value is not in the list, the script fails with the valid options printed. It does not guess the nearest match.
const match = collections.find((c) => c.slug === frontmatter.collection);
if (!match) {
throw new Error(
`Unknown collection "${frontmatter.collection}". Valid: ${collections
.map((c) => c.slug)
.join(", ")}`,
);
}3. Type collisions are an error, not an overwrite
Deterministic ids mean a slug maps to exactly one document. If that id is already held by a different type, the script stops. Silently converting a post into a doc destroys content and every inbound link to it.
4. Never invent facts
Client names, URLs and metrics are the three things a model will confabulate most confidently, because they are the fields whose absence feels most like an incomplete answer. The rule in AGENTS.md is explicit: if it is missing, ask.
- Client name and URL — must come from the human, verbatim.
- Metrics — must come from an analytics export or the human, never estimated.
- Dates — derive from the system clock, not from memory of when work happened.
5. Print the URLs on success
The script's last act is printing the Studio URL and the eventual live URL. It makes review a click rather than a search, which is the difference between a workflow people use and one they abandon.
✓ Draft created: doc-provision-ubuntu-node-server
Studio https://brainnotfound.com/studio/structure/doc;doc-provision-ubuntu-node-server
Live https://brainnotfound.com/docs/server-setups/provision-ubuntu-node-server (after publish)// related
From the rest of the site.
Building an AI Content Pipeline That Doesn't Publish Slop
Where language models genuinely help a publishing workflow, where they quietly destroy it, and how to wire the difference.
