/sitecore-content-sdk:content-sdk-searchfrom Sitecore Content SDK - Core
Implements SitecoreAI integrated search in a Content SDK head app: client-side search hooks vs server SearchService, facets, sorting, and consent-gated events. Use when adding search UI to a Sitecore head app.
Ships in Sitecore Content SDK - Core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
SitecoreAI Search experiences ("integrated search") is queried from the head app with ONE public credential, the Edge context id, sent as x-sitecore-contextid to POST https://edge-platform.sitecorecloud.io/v1/search and /v1/search/suggest. No API key, no OAuth, no customer key. The index itself (a search source) is configured in the SitecoreAI UI: that half lives in the sitecoreai-search-sources skill.
Status markers: [confirmed] = measured on 2026-10-02 (live read-only probe or a local Next 16 build); [source] = read from the installed SDK; [probe-gated: Pn] = not proven yet, named probe closes it.
| You want | Use | Not |
|---|---|---|
| Site/product search with marketer-tuned boost, pin, facets | this skill + sitecoreai-search-sources | Edge GraphQL search(where:) (filters an item's own fields only) |
| Exact structural queries (children of X, by template) inside a data fetch | Edge GraphQL / ComponentQuery (sitecoreai-graphql-schemas) | integrated search (index lags until a manual reindex) |
Recommendations, widgets, rfk_id, customer key, discover.sitecorecloud.io | standalone Sitecore Search (CEC) | this skill |
| CM item lookup during authoring automation | Authoring GraphQL search(query:) | either search product |
searchIndexId), or list sources with the search-config script of sitecoreai-search-sources (needs a credential with the search-config scope). No source, no search: an unknown id answers 404 no search index found for config <id> [confirmed].npm ls @sitecore-content-sdk/search. Search rides on nextjs (nextjs → react → search). 0.4 (nextjs 2.3) adds locale + facet; 0.5 (nextjs 2.4) adds suggest() + MLT. Table: references/version-matrix.md.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID is set (api.edge.clientContextId). Without it useSearchService() returns null and every hook stays status: 'idle' forever with zero requests and no error [confirmed: P8, 0 requests in 5 s]. A missing searchIndexId instead gives status: 'error'.node scripts/probe-search.mjs --context-env NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID --env-file .env.local --index <id>. It runs a fake-context control first (must be 404 No sitecore context), then a fake-index control (must be 404 no search index found), then your query.| Situation | Use |
|---|---|
| Interactive search box, pagination | useSearch / useInfiniteSearch from @sitecore-content-sdk/nextjs/search, in a 'use client' component, inside a component-local <Suspense> |
| Typeahead | useSuggest (no built-in debounce: debounce the input yourself) |
| SEO-visible results, a "related content" block, a route handler | new SearchService({ contextId }) on the server |
| Related items | MLT: seedItemId or seedItemUrl (site indexes only) instead of keyphrase; mutually exclusive [source]. GUID form [probe-gated: P4] |
Import paths [source]. Hooks come only from the /search subpath; the docs' root-path import does not exist. SearchService is not re-exported by nextjs or react: import it from @sitecore-content-sdk/search and add that package as a direct dependency pinned to the version npm ls shows (it is only transitive, so strict package managers will not resolve it).
Client-only rule [confirmed]. The hook dist files carry no 'use client'. A Server Component calling useSearch compiles fine and then fails at prerender with TypeError: (0 , c.useState) is not a function (a dynamic route would fail at request time instead). Put the directive on the file that calls the hook.
fetchOptions is spread into the global fetch, so Next caching applies: with { next: { revalidate: 60 } } the page prerenders at build (one upstream POST) and repeat requests inside the TTL cause zero upstream calls; under dynamic = 'force-dynamic' the same option still dedupes through the data cache (1 upstream call for 3 requests); { cache: 'no-store' } calls every time.sessionId is '' (no analytics init): search works but is not tied to a CDP session.Error('HTTP 404 Not Found') with e.response.status and e.response.data ({ errors: [{ message, code }] }). Catch it and render an empty state; do not let a missing index 500 the page.search<MyDoc>(…). The default SearchDocument value type is not a ReactNode, so {r.results[0].title} fails type-check.sort and facet object [confirmed: P8]. They are useCallback dependencies compared by reference. An inline facet={{ all: true }} produced 6,568 requests in 5 s, 6,600 renders, status stuck at loading (each render aborts the previous request). The useMemo version sent exactly 1. check-search-wiring.mjs fails the inline form.limit max 500 (RangeError); limit: 0 passes validation [source]. An empty keyphrase returns the whole index.page is 1-based; useInfiniteSearch.hasNextPage = results.length < total.locale for you. Pass the route locale explicitly on a multi-language site; the accepted format (en vs en-US) [probe-gated: P4].name is the facet's display name from the source config, not the raw field name (SDK JSDoc). Operators eq|gt|lt|ge|le; string/boolean fields eq only; an array value means OR. Server behaviour [probe-gated: P4]. Discover names with search-config.mjs.SearchExperienceThe only official consumer is the SYNC starter (xmcloud-starter-js/examples/kit-nextjs-product-listing/src/components/search-experience/). Copy it, then fix these on the way in (diffs in references/starter-port.md):
?q=. useRouter.tsx builds `?q=${value}`; &, #, + corrupt the URL. Use encodeURIComponent(value).nullResults. useEvent.tsx hard-codes nullResults: false, so the dashboard's Null searches KPI can never fire. Pass total === 0.event() directly. Route it through trackEvent() from content-sdk-tracking-consent (analytics category). Consent denied: no event, and sessionId is '', but search itself keeps working.<Suspense> local. useSearchParams needs a boundary for next build; the starter wraps all of Providers, which makes the whole tree client-rendered. Wrap only the search component.SearchDocument from your source's real fields (the starter hard-codes SYNC product fields). Capture a response with probe-search.mjs --out first.useSearchField falls back silently on an empty value, console.warns on invalid JSON, and casts valid JSON without validation (missing searchIndex → undefined). In editing, render an author-visible notice instead.componentInstanceId from the event (A/B/n attribution); its md:${baseClass} grid class is built at runtime and is invisible to Tailwind's scanner, so safelist the three md:grid-cols-* classes.CM side: the datasource template has ONE field search of type Plugin (Source = the Search Configuration Manager app) holding JSON { "searchIndex": "<source id>", "fieldsMapping": { title, description, type, link, images, tags } }. Rendering SearchExperience, variants Default (useSearch, pages) and LoadMore (useInfiniteSearch), rendering parameter columns 1-3, dictionary keys SearchExperience_*. Item inventory: references/starter-port.md. The exact JSON the app writes [probe-gated: P7].
!isEditing && !isPreview; render skeletons otherwise.probe-search.mjs against the live context. A test pass must list "search returns results" as unverifiable until the source is indexed and the page published.sitecoreai-search-sources).Results are index documents wrapped into fake { value } fields; they are not Sitecore fields and not editable. Record a per-field waiver for the result fields in .authorability-ignore.json with that reason. The search config field is authorable (Plugin field, Search Configuration tab).
The starter's event is event({ type: 'search', siteId, channel: 'web', name, language, core: { componentId, interactionType: 'viewed' | 'clicked', keyword, nullResults } }), needing analyticsPlugin + eventsPlugin (content-sdk-analytics-events). type: 'search' is a documented SitecoreAI event, distinct from standalone Search's SC_SEARCH_WIDGET_*. Whether these events reach Performance > Search, and whether a debounced viewed per keystroke inflates the counts [probe-gated: P7]. keyword is user input: treat it as potentially personal data.
scripts/probe-search.mjs --context-env <VAR> [--env-file <f>] [--index <id>] [--keyphrase <q>] [--facet-all] [--suggest <q>] [--locale <l>] [--expect-results] [--out <file>] — read-only; controls first; never prints the context id. Exit 1 when a control or the query fails.scripts/check-search-wiring.mjs --app <dir> [--json] — static gate. FAIL: hook file without 'use client', hooks imported from the package root, inline sort/facet literal or one built in the render body without useMemo, unencoded ?q=, nullResults: false literal, type: 'search' event with no consent guard. WARN: SearchService without a direct @sitecore-content-sdk/search dependency, no client context id in env files, hook call without locale, search event without componentInstanceId, <Suspense> wrapping Providers, runtime-built Tailwind classes.--self-test runs fixtures plus a mutation sweep that disables each guard in turn and fails if no case notices.No sitecore context (problem+json), not 401; the same for no header at all. Do not read it as "endpoint missing".{"errors":[{"message":"no search index found for config <id>","code":404}]}.sort/facet → request storm.useState is not a function.SearchService needs a direct @sitecore-content-sdk/search dependency.limit: 0 is accepted.?q=, nullResults: false, ungated event(), Suspense around Providers, no componentInstanceId, runtime Tailwind class.search(...), Edge search(where:), standalone Search and integrated search.sitecoreai-search-sources (sources, reindex, push, config read) · content-sdk-tracking-consent (trackEvent) · content-sdk-analytics-events · content-sdk-app-router-editing-safe-rendering · content-sdk-variants-vs-siblings (Default / LoadMore) · content-sdk-component-naming-traps (support files under src/components/ auto-register) · content-sdk-upgrade-assistant.
references/api-surface.md (opens in a new tab)references/fixtures/error-404-index-not-found.json (opens in a new tab)references/fixtures/error-404-no-context.json (opens in a new tab)references/starter-port.md (opens in a new tab)references/version-matrix.md (opens in a new tab)scripts/check-search-wiring.mjs (opens in a new tab)scripts/probe-search.mjs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
sitecore-search, content-sdk, search-hooks, facets, edge-search
npx claudepluginhub chris1415/sitecore-skills-pocs --plugin sitecore-content-sdk23 skills in this plugin
/content-sdk-analytics-eventsSends Content SDK analytics events: analytics and events plugins, pageView, event, form, identity, field limits, client vs server, bot and editing suppression. Use when adding or debugging tracking calls. Not consent or personalization./content-sdk-atomic-design-assessmentAssesses a Content SDK head app for Atomic Design: scan src/components, rate each low-code candidate / partial / keep-code, derive the atom set, plan a side-by-side migration. Use when asked which components could become atoms. Not writing atoms./content-sdk-Other plugins' skills for the same job