What can Sanity Content Agent audit automatically?
It can help inspect missing metadata, incomplete fields, references, terminology and potentially overlapping content. Accuracy depends on the deployed schema, audit instructions and available data.
Learn how Sanity Content Agent helps audit metadata, content freshness and terminology, with practical GROQ and TypeScript examples for controlled workflows.
Sanity Content Agent makes content audits more systematic by combining structured GROQ queries with AI-assisted analysis. Teams can identify missing metadata, potentially outdated pages, terminology inconsistencies and possible duplication. The Agent API extends these checks into repeatable workflows and can prepare targeted edits as reviewable drafts. It does not replace website-level technical audits or subject-matter approval.
The main benefit is not a single clever prompt. It comes from a reliable content architecture: well-defined fields and references support reproducible checks. AI becomes useful where deterministic rules alone cannot assess clarity, consistency or overlapping intent.
Sanity describes two complementary approaches in its guide to automating content audits: the interactive Content Agent within Sanity and Agent Actions for programmatic analysis and changes.
With Content Agent, editors describe checks in natural language. The agent can use available document types, fields and references to find relevant content with GROQ and suggest improvements. Suggestions should be reviewed before they are accepted as drafts or Content Releases. Publishing is a separate decision.
For recurring tasks and system integrations, Sanity offers the Agent API: Prompt can analyze content and return text or JSON without changing documents, while Transform can update selected fields and normally writes to drafts for regular document types. Sanity documentation continues to label Prompt and Transform as experimental APIs.
Metadata: missing SEO titles, empty descriptions, missing image alt text and unassigned categories can be detected with field queries. The rules must reflect the fields actually deployed in the content schema.
Freshness: modification timestamps identify records that have not changed for a long period. They do not prove that the content is factually outdated. A dedicated editorial review date or the version of the authoritative product information may be more meaningful.
Consistency: differences in product names, outdated terms, incomplete translations and potentially overlapping articles can be flagged for review. Semantic similarity alone is not evidence of keyword cannibalization.
References: structured relationships help find documents pointing to products that are no longer approved. Whether external URLs resolve correctly on the rendered website still requires separate HTTP checks.
Many quality rules can be checked deterministically. Missing meta descriptions, empty required fields and timestamps beyond a threshold do not need a language model. GROQ produces a clear and inspectable set of candidates.
AI can then assess the selected documents qualitatively: Which statement is unclear? Where does terminology drift? Which articles appear to answer the same question? This avoids indiscriminate model calls and unnecessary edits.
A model should not make deletion, redirection or publication decisions on its own. Those actions require search performance data, accountable owners and knowledge of the deployed website.
The following GROQ query selects posts where seoDescription is missing or empty. The example assumes the document type post and a field named seoDescription. Both must exist in the actual Sanity schema.
The query is read-only and returns an initial batch of up to 25 documents. Larger content collections need pagination and a prioritization method.
*[
_type == "post" &&
(!defined(seoDescription) || seoDescription == "")
][0...25]{
_id,
title,
"slug": slug.current,
_updatedAt
}A freshness review also starts with an explicit query. This example selects records whose technical modification timestamp is more than 180 days old. The threshold is illustrative and should reflect the content type, review cycle and applicable requirements.
Note that _updatedAt can change following editorial or technical edits. For products maintained in separate source systems, business-level freshness needs dedicated fields and verification against the authoritative data.
*[
_type == "post" &&
dateTime(_updatedAt) < dateTime(now()) - 180 * 24 * 60 * 60
][0...25]{
_id,
title,
_updatedAt,
publishedAt
}For qualitative checks, Prompt complements rule-based filtering. This example fetches a bounded list of posts and passes the records into an AI assessment. The response is a structured report, not an automatic publication.
This requires server-side execution, a token with appropriate access and a compatible version of @sanity/client. The Sanity guide referenced in the original article specifies version 7.1.0 or later and apiVersion vX for Agent Actions. Check current release notes and API signatures before implementation.
This is an implementation example, not code verified against a production project. Keep credentials in server-side environment variables. Validate the returned JSON before using it in a report or ticket workflow; add evidence, timestamps and review status as needed.
import {createClient} from '@sanity/client'
const client = createClient({
projectId: process.env.SANITY_PROJECT_ID!,
dataset: 'production',
apiVersion: 'vX', // Agent Actions require vX
token: process.env.SANITY_AUDIT_TOKEN,
useCdn: false,
})
const candidates = await client.fetch(
'*[_type == "post" && (!defined(seoDescription) || seoDescription == "")][0...15]{_id,title,excerpt,_updatedAt}'
)
if (candidates.length > 0) {
const report = await client.agent.action.prompt({
instruction: [
'Review the CMS records in $documents.',
'Flag missing or unclear SEO metadata.',
'Do not invent traffic or performance data.',
'Return JSON: {"findings":[{"id":"...","issue":"...","priority":"high|medium|low"}]}.',
].join(' '),
instructionParams: {
documents: {
type: 'constant',
value: JSON.stringify(candidates),
},
},
format: 'json',
})
console.log(report) // Route to a report or ticket queue
}
After reviewing the findings, use Transform only for selected records. The call needs a document ID, the actually deployed schema ID and a target restricted to the intended field. Here, the batch is limited to five records so each proposed description can be reviewed individually.
For regular document types, Transform ordinarily writes to drafts unless a published write is explicitly forced. liveEdit document types require separate care, and forcePublishedWrite should not be enabled casually in a review workflow.
The schema ID is not the project ID; it must come from the deployed schema registration. The example performs synchronous calls rather than relying on an asynchronous job status. Editorial review and publication happen afterwards in Sanity Studio.
// Use the authenticated server-side client from the previous example.
const candidates = await client.fetch(
'*[_type == "post" && (!defined(seoDescription) || seoDescription == "")][0...5]{_id,title}'
)
for (const doc of candidates) {
const result = await client.agent.action.transform({
schemaId: process.env.SANITY_SCHEMA_ID!,
documentId: doc._id,
instruction: [
'Write one concise English SEO description',
'based only on the existing document.',
'Keep it under 160 characters.',
'Do not invent claims, statistics or customer results.',
].join(' '),
target: {include: ['seoDescription']},
})
console.log('Review draft for:', doc._id, result)
}
// Review each draft in Studio before publishing.
1. Define the rules. Which document types are business-critical? Which fields are required? Which terminology is approved? The content model, categories and references must express those rules.
2. Identify candidates. GROQ checks missing fields, incomplete relationships and agreed freshness thresholds. Process large collections in manageable batches.
3. Evaluate in context. The Agent API examines prioritized content against explicit criteria. For technical claims, authoritative ERP, PIM, PLM or documentation data should be made available where required.
4. Correct with oversight. Generate changes at field level, have the responsible specialists approve them, and only then publish. Record the finding, decision and resulting change.
An English article may be current while its German or Serbian version still contains outdated product information. A useful audit therefore needs to compare not only individual documents, but also translations and shared product identities.
That requires stable translation relationships, consistent terminology and a way to track source changes across target languages. URLs, canonical tags and hreflang must also match the actual frontend.
We explain AI-assisted localization in Sanity AI Translations. For enterprise-wide data ownership, our discussion of Sanity Context and independent data platforms explains why CMS content should remain connected to shared information systems.
A content agent can inspect information stored in the Content Lake and available through its context. A valid seoDescription value does not prove that a frontend emits it correctly. A stored internal link does not guarantee that the public route works without redirects or 404 responses.
Comprehensive quality checks combine CMS-level rules with website crawlers, rendered HTML checks, indexation evidence and analytics. Search Console data or external crawling results require separate integrations; Content Agent does not automatically possess them.
For international discoverability, these checks also belong to Search & AI Visibility. The underlying content model, integrations and workflow execution remain engineering responsibilities.
Sanity Content Agent operates within assigned permissions and presents proposed edits for review. Programmatic Agent Actions require their own access tokens, limited privileges and explicit rules describing which records may change.
Not all audit steps incur the same cost. Deterministic queries differ from model-based analysis and document transformations. Frequent full-library scans and uncontrolled Transform loops may waste AI credits. First filter, then analyze and finally edit in small batches.
Recurring audits can run through scheduled jobs, CI/CD or Sanity Scheduled Functions. Production systems also need monitoring, error handling, execution limits, idempotency and auditable reporting. A small integration adapter makes future API changes easier to contain.
The combination is especially helpful for large, well-structured content collections where consistent rules must be applied across many documents. A sound schema reduces the effort of recurring checks and focused changes.
If the content model is inconsistent, references are ambiguous or authoritative product systems disagree, fix the data architecture first. Additional prompts cannot replace data ownership or dependable relationships between records.
Nor does a CMS agent replace analysis of indexation, conversion outcomes or real product availability. Those signals originate outside the CMS and must be integrated into the audit deliberately.
It can help inspect missing metadata, incomplete fields, references, terminology and potentially overlapping content. Accuracy depends on the deployed schema, audit instructions and available data.
The interactive agent presents edits for review rather than publishing them autonomously. For programmatic Agent Actions, the write mode and document type must be evaluated separately.
Yes. Programmatic checks may be integrated into scheduled jobs or Sanity Scheduled Functions. Frequency and infrastructure depend on project requirements and available limits.
It can inspect structured CMS references. HTTP status codes, rendered HTML, canonicals and hreflang on public pages require additional technical website checks.
No. Missing fields, date thresholds and fixed terminology rules should be checked deterministically wherever practical. AI is most useful for qualitative review.
The Sanity documentation reviewed for the source article still marks Prompt and Transform as experimental. Recheck versions, API interfaces and error behaviour before production use.
Sanity Content Agent can turn occasional manual content checks into a repeatable workflow. The key is to separate verifiable data rules, AI-assisted assessment and accountable approval. That makes findings traceable and corrections controlled.
We engineer the necessary content and integration architecture, from an auditable schema and validation rules to agent workflows and checks against the actual website.
We can evaluate what your existing content platform supports and where to start through Consulting & Diagnostics.
Platform Engineering
We assess content models, data ownership and existing quality processes. From there, we develop a repeatable audit architecture with targeted corrections and connections to your systems.
Managing Director
aleks@valanor.co
+49 (0) 711 16 44 6 83
Lindenspürstrasse 22, 70176 Stuttgart
