Sanity Document Publishing
Publish app content into Sanity as valid documents and assets, respecting draft workflows.
What it adds
A publishing path that creates and updates Sanity documents and their assets from app records, honouring the target schema and draft pairing.
What your agent is told to do
5
What your agent is told to do
5-
1
Derive each document's identifier deterministically from the app record it represents, so a retried or repeated publish updates the same document rather than scattering near-identical copies through the dataset.
-
2
Read the target schema and validate the payload against it before sending, rejecting the write locally with a readable error rather than discovering the mismatch as a rejected mutation in a background job.
-
3
Upload every image and file asset first, wait for the asset to be usable, and only then write the document that references it.
-
4
Handle the draft and published pair explicitly: decide whether the app writes drafts for a human to publish or publishes directly, prefer writing drafts, and never let a routine sync publish something an editor deliberately left in draft.
-
5
Do not pass user-authored rich text or references straight through into the document body. Constrain it to the block types, marks, and reference targets the schema allows, because an unconstrained body is a way for one user's input to reach every reader of the published site.
Edge cases it handles
8
Edge cases it handles
8- Identifiers must be stable and derived from the source record. Letting the destination assign one, or generating a fresh one per run, produces silent duplicates that are only noticed once the site shows the same item twice.
- A payload that does not match the schema will be rejected wholesale. Validate before sending so the failure is attributable to a named field rather than an opaque mutation error.
- Assets are processed asynchronously. A document written immediately after an upload can reference an asset that is not yet ready, producing a broken image on a page that was reported as published successfully.
- Draft and published documents exist as a pair. Writing to the wrong half either publishes unreviewed content or leaves the app's changes invisible on the live site with nothing to indicate why.
- Portable text and reference fields must be constrained to what the schema permits. Arbitrary block types or references pointing at unexpected documents will either fail validation or render as something nobody designed.
- Multiple mutations belonging to one logical publish should be sent as a single transaction where the destination allows it, so a failure part way through does not leave a document referencing assets that were never linked.
- Rate limits and outages need bounded retries with backoff, and a publish that could not be delivered must be visible in the app as pending rather than reported as done.
- The stored token can be revoked at any time. Distinguish an authentication failure from a transient error, stop retrying, and prompt an operator to reconnect.
Definition of done
9
Definition of done
9- Document identifiers are deterministic, so repeat publishes update rather than duplicate.
- Payloads are validated against the target schema before any write is attempted.
- Assets are uploaded and confirmed usable before the documents that reference them are written.
- Draft and published documents are handled as a pair, with the app defaulting to writing drafts.
- User-supplied rich text and references cannot introduce structures the schema does not allow.
- A failed publish leaves no half-written document and is shown in the app as pending, not complete.
- A revoked token stops retries and surfaces a reconnect prompt.
- The feature matches the existing design system.
- No existing functionality is broken.
Related features
Contentful Entry Sync
Contentful Entry Sync
Create and update Contentful entries against the connected space, environment, and locale.
What it does
A sync that writes app records into Contentful entries using the connected space's content model and locale configuration.
How it works
- 1 Have the operator select the space, the environment, and the default locale during connection, and store all three, because writing production content into a sandbox environment is an easy and expensive mistake.
- 2 Fetch the content model at connection time and again before each sync run, map app fields to entry fields by their stable identifiers, and validate the value type against the model before attempting the write.
- 3 Write every localized field under an explicit locale rather than relying on whatever the space treats as default, and state clearly which locales the app owns and which it leaves to editors.
Copy the prompt
No account needed
Add this feature to my app:
https://addthisfeature.com/x/contentful-entry-sync
Typesense Index Sync
Typesense Index Sync
Keep a search index in step with your records so results stay current and correctly scoped.
What it does
A one-way sync from the app's records into a Typesense collection, with server-enforced tenant filtering and a rebuild path.
How it works
- 1 Identify every model users search today and declare the indexed shape explicitly: the fields people type into, the fields they filter and sort on, and nothing more. Treat a missing or newly added field as absent rather than letting the document fail validation.
- 2 Reuse the app's existing background-job system to push creates, updates, and deletes. Do not index inside the request cycle; a slow or unreachable search service must never make a save fail or hang.
- 3 Build the tenant, workspace, and permission filter on the server at query time and attach it to every search. Do not accept a filter, collection name, or scope value from a client-supplied parameter, because anything the browser can set the browser can change.
Copy the prompt
No account needed
Add this feature to my app:
https://addthisfeature.com/x/typesense-index-sync
Algolia Index Sync
Algolia Index Sync
Keep the search index matching the database, including who is allowed to see what.
What it does
A sync pipeline that mirrors records into a search index with tenant-scoped filters and scheduled reconciliation.
How it works
- 1 Identify every record type that should be searchable and define one index document per record, keyed by an identifier that never changes for the life of that record.
- 2 Push changes through the app's existing background-job system on create, update, and delete, and make every write idempotent so a replayed job produces the same document rather than a duplicate.
- 3 Put tenant, workspace, and visibility values on each document as filter attributes, and have the server issue short-lived scoped search credentials that pin those filters. The browser must never choose its own filter.
Copy the prompt
No account needed
Add this feature to my app:
https://addthisfeature.com/x/algolia-index-sync
How it works
-
1
Copy the link
Grab the Markdown instruction URL for this feature.
-
2
Give it to your AI
Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.
-
3
It inspects, then implements
Your agent reads your existing app first, then adds the feature to fit it.
Works with your stack
These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.
Need it tighter than that? Customize the feature and tell it exactly what you're running.