create-content-sdk-app 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/templates/nextjs/.agents/skills/content-sdk-component-data-strategy/SKILL.md +37 -0
  2. package/dist/templates/nextjs/.agents/skills/content-sdk-component-registration/SKILL.md +36 -0
  3. package/dist/templates/nextjs/.agents/skills/content-sdk-component-scaffold/SKILL.md +34 -0
  4. package/dist/templates/nextjs/.agents/skills/content-sdk-component-variants/SKILL.md +36 -0
  5. package/dist/templates/nextjs/.agents/skills/content-sdk-dictionary-and-i18n/SKILL.md +35 -0
  6. package/dist/templates/nextjs/.agents/skills/content-sdk-editing-safe-rendering/SKILL.md +37 -0
  7. package/dist/templates/nextjs/.agents/skills/content-sdk-field-usage-image-link-text/SKILL.md +36 -0
  8. package/dist/templates/nextjs/.agents/skills/content-sdk-graphql-data-fetching/SKILL.md +38 -0
  9. package/dist/templates/nextjs/.agents/skills/content-sdk-multisite-management/SKILL.md +37 -0
  10. package/dist/templates/nextjs/.agents/skills/content-sdk-route-configuration/SKILL.md +38 -0
  11. package/dist/templates/nextjs/.agents/skills/content-sdk-site-setup-and-env/SKILL.md +36 -0
  12. package/dist/templates/nextjs/.agents/skills/content-sdk-sitemap-robots/SKILL.md +37 -0
  13. package/dist/templates/nextjs/.agents/skills/content-sdk-troubleshoot-editing/SKILL.md +39 -0
  14. package/dist/templates/nextjs/.agents/skills/content-sdk-upgrade-assistant/SKILL.md +36 -0
  15. package/dist/templates/nextjs/AGENTS.md +1 -0
  16. package/dist/templates/nextjs/CLAUDE.md +6 -170
  17. package/dist/templates/nextjs/Skills.md +79 -0
  18. package/dist/templates/nextjs/package.json +2 -2
  19. package/dist/templates/nextjs/src/Bootstrap.tsx +20 -13
  20. package/dist/templates/nextjs/src/byoc/index.tsx +1 -1
  21. package/dist/templates/nextjs/src/components/content-sdk/CdpPageView.tsx +1 -1
  22. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-data-strategy/SKILL.md +37 -0
  23. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-registration/SKILL.md +38 -0
  24. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-scaffold/SKILL.md +38 -0
  25. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-variants/SKILL.md +36 -0
  26. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-dictionary-and-i18n/SKILL.md +37 -0
  27. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-editing-safe-rendering/SKILL.md +37 -0
  28. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-field-usage-image-link-text/SKILL.md +36 -0
  29. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-graphql-data-fetching/SKILL.md +37 -0
  30. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-multisite-management/SKILL.md +37 -0
  31. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-route-configuration/SKILL.md +38 -0
  32. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-site-setup-and-env/SKILL.md +36 -0
  33. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-sitemap-robots/SKILL.md +37 -0
  34. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-troubleshoot-editing/SKILL.md +39 -0
  35. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-upgrade-assistant/SKILL.md +36 -0
  36. package/dist/templates/nextjs-app-router/.sitecore/import-map.server.ts +2 -2
  37. package/dist/templates/nextjs-app-router/AGENTS.md +6 -6
  38. package/dist/templates/nextjs-app-router/CLAUDE.md +6 -271
  39. package/dist/templates/nextjs-app-router/README.md +0 -36
  40. package/dist/templates/nextjs-app-router/Skills.md +79 -0
  41. package/dist/templates/nextjs-app-router/package.json +3 -2
  42. package/dist/templates/nextjs-app-router/src/Bootstrap.tsx +20 -12
  43. package/dist/templates/nextjs-app-router/src/app/[site]/[locale]/[[...path]]/layout.tsx +19 -0
  44. package/dist/templates/nextjs-app-router/src/app/[site]/[locale]/[[...path]]/not-found.tsx +3 -28
  45. package/dist/templates/nextjs-app-router/src/app/[site]/[locale]/[[...path]]/page.tsx +6 -21
  46. package/dist/templates/nextjs-app-router/src/app/[site]/layout.tsx +5 -21
  47. package/dist/templates/nextjs-app-router/src/app/not-found.tsx +1 -23
  48. package/dist/templates/nextjs-app-router/src/byoc/index.tsx +1 -1
  49. package/dist/templates/nextjs-app-router/src/components/content-sdk/CdpPageView.tsx +1 -1
  50. package/package.json +2 -2
  51. package/dist/initializers/angular/args.js +0 -2
  52. package/dist/initializers/angular/index.js +0 -30
  53. package/dist/initializers/angular/prompts.js +0 -20
  54. package/dist/templates/angular/.postcssrc.json +0 -5
  55. package/dist/templates/angular/.vscode/extensions.json +0 -4
  56. package/dist/templates/angular/README.md +0 -3
  57. package/dist/templates/angular/angular.json +0 -79
  58. package/dist/templates/angular/package.json +0 -58
  59. package/dist/templates/angular/public/favicon.ico +0 -0
  60. package/dist/templates/angular/src/app/app.config.server.ts +0 -12
  61. package/dist/templates/angular/src/app/app.config.ts +0 -31
  62. package/dist/templates/angular/src/app/app.css +0 -0
  63. package/dist/templates/angular/src/app/app.html +0 -1
  64. package/dist/templates/angular/src/app/app.routes.server.ts +0 -15
  65. package/dist/templates/angular/src/app/app.routes.ts +0 -28
  66. package/dist/templates/angular/src/app/app.ts +0 -12
  67. package/dist/templates/angular/src/app/loaders/error.loader.ts +0 -12
  68. package/dist/templates/angular/src/app/loaders/index.ts +0 -14
  69. package/dist/templates/angular/src/app/loaders/not-found.loader.ts +0 -12
  70. package/dist/templates/angular/src/app/loaders/page.loader.ts +0 -15
  71. package/dist/templates/angular/src/app/loaders/stub-utils.ts +0 -83
  72. package/dist/templates/angular/src/app/pages/error.component.ts +0 -124
  73. package/dist/templates/angular/src/app/pages/not-found.component.ts +0 -85
  74. package/dist/templates/angular/src/app/pages/page.component.ts +0 -58
  75. package/dist/templates/angular/src/app/shared/layout.component.ts +0 -106
  76. package/dist/templates/angular/src/index.html +0 -13
  77. package/dist/templates/angular/src/main.server.ts +0 -8
  78. package/dist/templates/angular/src/main.ts +0 -6
  79. package/dist/templates/angular/src/server.ts +0 -65
  80. package/dist/templates/angular/src/styles.css +0 -3
  81. package/dist/templates/angular/tsconfig.json +0 -38
  82. package/dist/templates/angular/tsconfig.spec.json +0 -10
  83. package/dist/templates/nextjs/LLMs.txt +0 -179
  84. package/dist/templates/nextjs-app-router/LLMs.txt +0 -236
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: content-sdk-multisite-management
3
+ description: Handles multisite: site resolution, .sitecore/sites.json, and proxy in src/proxy.ts. App Router proxy order is fixed: LocaleProxy → AppRouterMultisiteProxy → RedirectsProxy → PersonalizeProxy. Use when working with multiple sites or hostnames.
4
+ ---
5
+
6
+ # Content SDK Multisite Management (App Router)
7
+
8
+ Site resolution from request (e.g. hostname or cookie); proxy rewrites to /[site]/[locale]/...path. **Locale must run first** so next-intl and multisite see the correct locale.
9
+
10
+ ## When to Use
11
+
12
+ - User asks about multiple sites, hostnames, or site resolution.
13
+ - Task involves .sitecore/sites.json, multisite config, or proxy/middleware for site.
14
+ - User mentions "multisite," "site resolution," "hostname," or "sites.json."
15
+
16
+ ## How to perform
17
+
18
+ - Site list: `.sitecore/sites.json`. Proxy logic lives in `src/proxy.ts`; ensure `src/middleware.ts` re-exports it if present. Keep chain order: LocaleProxy → AppRouterMultisiteProxy → RedirectsProxy → PersonalizeProxy. Exclude API, _next, static assets in the matcher.
19
+
20
+ ## Hard Rules
21
+
22
+ - Site list is in `.sitecore/sites.json` (typically generated by Sitecore CLI or deployment). Avoid hand-editing unless the format is known.
23
+ - **Proxy:** Implemented in `src/proxy.ts`. Next.js runs middleware from `middleware.ts` at root or in `src/` — if the app only has `proxy.ts`, add `src/middleware.ts` that re-exports it.
24
+ - **Chain order is fixed:** LocaleProxy → AppRouterMultisiteProxy → RedirectsProxy → PersonalizeProxy. **Do not change this order.** LocaleProxy runs first so i18n and multisite see the correct locale. AppRouterMultisiteProxy rewrites to /[site]/[locale]/[...path].
25
+ - **Matcher:** Exclude API routes, _next/, sitemap, robots, healthz, Sitecore paths, and static assets so the proxy stays lightweight.
26
+ - Config: sitecore.config.ts → multisite, redirects, personalize. Single SitecoreClient; pass resolved site and locale from route params into getPage, getDictionary, etc.
27
+
28
+ ## Stop Conditions
29
+
30
+ - Stop if the user wants to reorder the proxy chain; explain that LocaleProxy must run first for App Router.
31
+ - Stop if sites.json format is unknown and the change could break resolution; suggest checking SDK docs or CLI output.
32
+ - Do not add a second site resolution mechanism; use the existing proxy and config.
33
+
34
+ ## References
35
+
36
+ - [AGENTS.md](../../../AGENTS.md) for proxy chain, matcher, and multisite config.
37
+ - [Official Content SDK docs](https://doc.sitecore.com/xmc/en/developers/content-sdk/sitecore-content-sdk-for-xm-cloud.html).
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: content-sdk-route-configuration
3
+ description: Configures routing and layout for App Router. Single catch-all at src/app/[site]/[locale]/[[...path]]/page.tsx; call setRequestLocale at top of page. Use when changing routing, placeholders, or Layout.
4
+ ---
5
+
6
+ # Content SDK Route Configuration (App Router)
7
+
8
+ Single catch-all route and layout hierarchy. Site and locale are **in the path**; proxy rewrites incoming requests to /[site]/[locale]/...path.
9
+
10
+ ## When to Use
11
+
12
+ - User asks to change routing, add a route, or fix 404/not-found behavior.
13
+ - Task involves catch-all route, placeholders, root layout, or Layout.tsx.
14
+ - User mentions "[site]," "[locale]," "[[...path]]," "placeholder," or "layout hierarchy."
15
+
16
+ ## How to perform
17
+
18
+ - Single Sitecore page: `src/app/[site]/[locale]/[[...path]]/page.tsx`. Use `await params` for `{ site, locale, path? }`; pass to getPage and call `setRequestLocale(\`${site}_${locale}\`)` at the top. Layout: app/layout.tsx → app/[site]/layout.tsx (Bootstrap, draftMode) → page. Not-found: use getCachedPageParams and getErrorPage in the route's not-found.tsx.
19
+
20
+ ## Hard Rules
21
+
22
+ - **Single Sitecore page:** `src/app/[site]/[locale]/[[...path]]/page.tsx`. This is the **only** page that renders Sitecore content. Do not add another page or catch-all for Sitecore content.
23
+ - **Params:** Next.js 15+ — `params` is a Promise. Use `await params` to get `{ site, locale, path? }`. Pass `site` and `locale` to `client.getPage(path ?? [], { site, locale })`.
24
+ - **Locale for next-intl:** Call `setRequestLocale(\`${site}_${locale}\`)` at the **top** of the page so next-intl and `src/i18n/request.ts` see the correct locale. Do not omit when adding new page branches.
25
+ - **Layout hierarchy:** `app/layout.tsx` → `app/[site]/layout.tsx` (Bootstrap with `siteName={site}` and `draftMode()`) → page. Do not put site/locale-specific data fetching in the root layout.
26
+ - Placeholders are rendered by the layout (e.g. Placeholder component); do not change placeholder names or structure without aligning with Sitecore layout definition.
27
+ - **Not-found:** `src/app/[site]/[locale]/[[...path]]/not-found.tsx`. For Sitecore-driven 404 use `getCachedPageParams()` from `@sitecore-content-sdk/nextjs` for site/locale, then `client.getErrorPage(ErrorPage.NotFound, { site, locale })`.
28
+
29
+ ## Stop Conditions
30
+
31
+ - Stop if the user wants to add a second catch-all or a different URL shape for Sitecore pages; explain single-entry-point constraint.
32
+ - Stop if changing proxy/middleware order; order is fixed (LocaleProxy → AppRouterMultisiteProxy → RedirectsProxy → PersonalizeProxy).
33
+ - Do not move or rename the catch-all file without updating all references.
34
+
35
+ ## References
36
+
37
+ - [AGENTS.md](../../../AGENTS.md) for exact paths, params, and layout hierarchy.
38
+ - [Official Content SDK docs](https://doc.sitecore.com/xmc/en/developers/content-sdk/sitecore-content-sdk-for-xm-cloud.html).
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: content-sdk-site-setup-and-env
3
+ description: Configures site and environment: sitecore.config.ts, environment variables, default site and language. Use when configuring the app or adding env vars. Document in .env.example only; never commit .env or .env.local.
4
+ ---
5
+
6
+ # Content SDK Site Setup and Environment (App Router)
7
+
8
+ Central config in sitecore.config.ts; all secrets and environment-specific values via env vars.
9
+
10
+ ## When to Use
11
+
12
+ - User asks to configure site, default language, API host, or environment.
13
+ - Task involves sitecore.config.ts, .env, or defaultSite/defaultLanguage.
14
+ - User mentions "config," "environment variables," "API key," or "default site."
15
+
16
+ ## How to perform
17
+
18
+ - Edit `sitecore.config.ts` with `defineConfig`; read all secrets and env-specific values from `process.env.*`. Add or change vars in `.env.example` (or `.env.remote.example` / `.env.container.example`) with placeholders; never commit `.env` or `.env.local`.
19
+
20
+ ## Hard Rules
21
+
22
+ - Use `sitecore.config.ts` with `defineConfig` from the SDK. Expose api (edge, local), defaultSite, defaultLanguage, editingSecret, multisite, redirects, personalize as needed.
23
+ - All sensitive or environment-specific values must come from environment variables (e.g. process.env.SITECORE_API_KEY). Never hardcode API keys, secrets, or production URLs in source.
24
+ - Document every new or changed env var in `.env.example` (or `.env.remote.example` / `.env.container.example`). Use placeholder or empty value and a short comment; never put real secrets in example files.
25
+ - Never commit `.env` or `.env.local`; they are gitignored. Example files are the source of truth for which vars exist.
26
+
27
+ ## Stop Conditions
28
+
29
+ - Stop if the user wants to commit real secrets or production values; insist on env vars and .env.example only.
30
+ - Stop if adding a new env var would require CI or deployment changes without explicit instruction; document the var and note that deployment must set it.
31
+ - Do not edit .next/, node_modules/, or lockfiles unless the task explicitly requires it.
32
+
33
+ ## References
34
+
35
+ - [AGENTS.md](../../../AGENTS.md) for boundaries and env rules.
36
+ - [Official Content SDK docs](https://doc.sitecore.com/xmc/en/developers/content-sdk/sitecore-content-sdk-for-xm-cloud.html).
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: content-sdk-sitemap-robots
3
+ description: Sitemap and robots.txt for App Router: src/app/api/sitemap/route.ts and src/app/api/robots/route.ts with createSitemapRouteHandler and createRobotsRouteHandler. Rewrites in next.config.ts. Use when configuring sitemap, robots.txt, or SEO.
4
+ ---
5
+
6
+ # Content SDK Sitemap and Robots (App Router)
7
+
8
+ Sitemap and robots.txt are served via **route handlers** and rewrites. Use the SDK route handler helpers and sites from .sitecore/sites.json.
9
+
10
+ ## When to Use
11
+
12
+ - User asks to add or change sitemap or robots.txt.
13
+ - Task involves SEO, sitemap.xml, or robots route.
14
+ - User mentions "sitemap," "robots," "SEO," or "rewrites."
15
+
16
+ ## How to perform
17
+
18
+ - Sitemap: `src/app/api/sitemap/route.ts` with `createSitemapRouteHandler({ client, sites })`; robots: `src/app/api/robots/route.ts` with `createRobotsRouteHandler({ client, sites })`. Use sites from `.sitecore/sites.json`. Add rewrites in `next.config.ts` for `/sitemap*.xml` and `/robots.txt` with `locale: false`. Set `dynamic = 'force-dynamic'` if needed.
19
+
20
+ ## Hard Rules
21
+
22
+ - **Sitemap:** `src/app/api/sitemap/route.ts` — use `createSitemapRouteHandler({ client, sites })`. Export `{ GET }`. Use `sites` from `.sitecore/sites.json`. Set `export const dynamic = 'force-dynamic'` if the handler relies on request.
23
+ - **Robots:** `src/app/api/robots/route.ts` — use `createRobotsRouteHandler({ client, sites })`. Same pattern.
24
+ - **Rewrites:** In `next.config.ts`, add rewrites for `/sitemap*.xml` and `/robots.txt` to these route handlers. Use `locale: false` so they are not localized.
25
+ - Use the same SitecoreClient instance as the rest of the app; do not create a dedicated client for sitemap/robots.
26
+ - Avoid hardcoding the site list; use .sitecore/sites.json.
27
+
28
+ ## Stop Conditions
29
+
30
+ - Stop if the user wants to serve sitemap/robots from a different origin or with different auth; document and suggest proxy or edge config.
31
+ - Do not add new env vars for sitemap/robots without documenting them in .env.example.
32
+ - Do not change rewrite paths without updating docs and any references.
33
+
34
+ ## References
35
+
36
+ - [AGENTS.md](../../../AGENTS.md) for API routes and rewrites.
37
+ - [Official Content SDK docs](https://doc.sitecore.com/xmc/en/developers/content-sdk/sitecore-content-sdk-for-xm-cloud.html).
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: content-sdk-troubleshoot-editing
3
+ description: Troubleshoots XM Cloud editing, preview, and design library for App Router. Check draftMode(), getPreview/getDesignLibraryData from searchParams, setRequestLocale, and component maps. Use when editing or preview does not behave as expected.
4
+ ---
5
+
6
+ # Content SDK Troubleshoot Editing (App Router)
7
+
8
+ This skill focuses on **diagnosing** editing, preview, and design library issues. For implementing editing-safe rendering (draftMode, getPreview/getDesignLibraryData, API routes), use the **content-sdk-editing-safe-rendering** skill; the two are complementary (implementation vs. troubleshooting).
9
+
10
+ Diagnose and fix editing, preview, and design library issues without breaking the single client or proxy order. This app uses **draftMode()** and **searchParams** for preview data.
11
+
12
+ ## When to Use
13
+
14
+ - User reports that editing, preview, or design library is broken or inconsistent.
15
+ - Task involves debugging "not working in editor," missing chromes, or wrong data in preview.
16
+ - User mentions "editing broken," "preview not working," "design library," or "editor issues."
17
+
18
+ ## How to perform
19
+
20
+ - Confirm `draftMode()` and searchParams-based getPreview/getDesignLibraryData; ensure `setRequestLocale` is called at the top of the page. Verify editing API routes are not rewritten (check proxy matcher) and both component maps include the component. Check env (editingSecret, API config) and .env.example documentation.
21
+
22
+ ## Hard Rules
23
+
24
+ - **Preview flow:** Use `draftMode()` in Server Components; when enabled, use `client.getPreview(editingParams)` or `client.getDesignLibraryData(editingParams)` from **searchParams**. Ensure site/locale are passed correctly (e.g. from route params or editingParams).
25
+ - **next-intl:** Ensure `setRequestLocale(\`${site}_${locale}\`)` is called at the top of the page; missing setRequestLocale can cause locale or dictionary issues in editor.
26
+ - Editing API routes (`src/app/api/editing/config/route.ts`, `editing/render/route.ts`) must be reachable and use the same component maps (component-map.ts and component-map.client.ts) and config as the app. Check matcher in proxy.ts so /api/editing is not rewritten or blocked.
27
+ - Check that both component maps include all components used in the layout; missing registration causes "component not found" in editor.
28
+ - Environment: editingSecret and API config must be set (in env); document in .env.example only. Do not log or commit secrets.
29
+
30
+ ## Stop Conditions
31
+
32
+ - Stop if the fix would require changing CI, deployment, or XM Cloud project settings; suggest the user do that and document the required env or config.
33
+ - Stop if the issue might be in Sitecore (layout, template) rather than the app; suggest checking layout and content in XM Cloud.
34
+ - Do not recommend disabling security (e.g. skipping secret validation) without explicit user request and warning.
35
+
36
+ ## References
37
+
38
+ - content-sdk-editing-safe-rendering skill and [AGENTS.md](../../../AGENTS.md) for preview and editing flow.
39
+ - [Official Content SDK docs](https://doc.sitecore.com/xmc/en/developers/content-sdk/sitecore-content-sdk-for-xm-cloud.html).
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: content-sdk-upgrade-assistant
3
+ description: Guides upgrading @sitecore-content-sdk/* packages: version bumps, breaking changes, migration steps. Use when moving to a newer SDK or package version. Check Content SDK repo CHANGELOG and upgrade guides.
4
+ ---
5
+
6
+ # Content SDK Upgrade Assistant (App Router)
7
+
8
+ Upgrade @sitecore-content-sdk/* packages safely; follow the Content SDK repo changelog and migration guides.
9
+
10
+ ## When to Use
11
+
12
+ - User asks to upgrade SDK packages, update to a new version, or apply a migration.
13
+ - Task involves version bumps, @sitecore-content-sdk/* dependencies, or breaking changes.
14
+ - User mentions "upgrade," "migration," "new version," or "breaking change."
15
+
16
+ ## How to perform
17
+
18
+ - Bump all @sitecore-content-sdk/* to consistent versions; read the Content SDK repo CHANGELOG (and MIGRATION/upgrade docs) for breaking changes and migration steps. Update package.json, run `npm install` and `npm run build`; test editing and preview after upgrade.
19
+
20
+ ## Hard Rules
21
+
22
+ - Prefer upgrading all @sitecore-content-sdk/* packages together to a consistent set of versions unless the user requests a partial upgrade. Check peer dependencies and compatibility.
23
+ - Update dependencies in package.json; run `npm install` and `npm run build`. Test editing and preview after upgrade.
24
+ - Read the **Content SDK repository** CHANGELOG (and any MIGRATION.md or upgrade guide) for breaking changes and required code/config updates. Apply migration steps before or with the version bump.
25
+ - Do not edit .next/, node_modules/, or lockfiles unless required for the upgrade. Do not change CI or root tooling unless the task explicitly includes it.
26
+
27
+ ## Stop Conditions
28
+
29
+ - Stop if the target version is not specified or unclear; ask or suggest checking the Content SDK CHANGELOG and supported versions.
30
+ - Stop if a breaking change requires product or deployment decisions (e.g. new env vars, config schema); list required changes and ask the user to confirm.
31
+
32
+ ## References
33
+
34
+ - Content SDK repo [CHANGELOG](https://github.com/Sitecore/content-sdk/blob/dev/CHANGELOG.md) and upgrade docs.
35
+ - [AGENTS.md](../../../AGENTS.md) for build commands.
36
+ - [Official Content SDK docs](https://doc.sitecore.com/xmc/en/developers/content-sdk/sitecore-content-sdk-for-xm-cloud.html).
@@ -16,7 +16,7 @@ import { Suspense } from 'react';
16
16
  import React from 'react';
17
17
  import { componentMap } from '.sitecore/component-map';
18
18
  import client from 'src/lib/sitecore-client';
19
- import { pageView } from '@sitecore-cloudsdk/events/browser';
19
+ import { pageView } from '@sitecore-content-sdk/events';
20
20
  import config from 'sitecore.config';
21
21
 
22
22
  const importMapServer = [
@@ -48,7 +48,7 @@ const importMapServer = [
48
48
  exports: [{ name: 'default', value: client }],
49
49
  },
50
50
  {
51
- module: '@sitecore-cloudsdk/events/browser',
51
+ module: '@sitecore-content-sdk/events',
52
52
  exports: [{ name: 'pageView', value: pageView }],
53
53
  },
54
54
  {
@@ -120,15 +120,14 @@ These are the main head-app–specific concepts. Details are in the sections bel
120
120
  - **SSG:** `generateStaticParams` — use `client.getAppRouterStaticParams(sites, routing.locales)` (sites from `.sitecore/sites.json`). Return at least one default param when not generating full paths (e.g. dev or when `generateStaticPaths` is off).
121
121
  - **Metadata:** `generateMetadata` in the same segment can call `client.getPage(path ?? [], { site, locale })` and derive `title` (e.g. from route fields). Next.js will cache as appropriate.
122
122
 
123
- ### Server vs Client components and PPR
123
+ ### Server vs Client components
124
124
 
125
125
  - **Default:** Components are Server Components. Use `'use client'` only for interactivity (e.g. hooks, event handlers).
126
- - **PPR (Partial Prerendering):** Dynamic work (e.g. `draftMode()`, data fetching) is wrapped in `<Suspense>` (e.g. `DynamicPageContent`, `DynamicLayoutContent`, `DynamicNotFoundContent`). Keep the same pattern when adding new dynamic branches so PPR and caching behave correctly.
127
126
  - **draftMode:** Used in layout and page; call `await draftMode()` in Server Components that need to know preview state.
128
127
 
129
128
  ### Not-found and error page
130
129
 
131
- - **Segment not-found:** `src/app/[site]/[locale]/[[...path]]/not-found.tsx`. For Sitecore-driven 404, read site/locale from the rewrite header: `parseRewriteHeader(headers())` from `@sitecore-content-sdk/nextjs/utils`, then `client.getErrorPage(ErrorPage.NotFound, { site, locale })` and render layout if a page is returned. Wrap in `Suspense` if using async logic.
130
+ - **Segment not-found:** `src/app/[site]/[locale]/[[...path]]/not-found.tsx`. Uses `getCachedPageParams()` from `@sitecore-content-sdk/nextjs` for site/locale, then `client.getErrorPage(ErrorPage.NotFound, { site, locale })` and renders layout if a page is returned.
132
131
  - **Root not-found:** `src/app/not-found.tsx` — minimal fallback when no segment handles the route.
133
132
 
134
133
  ### API route handlers
@@ -154,7 +153,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
154
153
 
155
154
  - **Quick checks:** If locale or dictionary is wrong, ensure `setRequestLocale(\`${site}_${locale}\`)` is called at the top of the page and `src/i18n/request.ts` parses `requestLocale` and calls `client.getDictionary`. If not-found doesn't show Sitecore content, use `parseRewriteHeader(headers())` for site/locale. Always `await params` (Next.js 15+).
156
155
  - **Security:** Use only environment variables in `sitecore.config.ts`; never hardcode API keys, editing secret, or host URLs. Do not expose secrets in client-side code or in logs. Validate and sanitize user input at boundaries.
157
- - **Performance:** Keep middleware lightweight; use the proxy `matcher` so it does not run on API routes, `_next`, sitemap, robots, or static assets. Use Server Components and Suspense for dynamic content; add `'use client'` only where interactivity is needed. Use `generateStaticParams` and caching as in the existing page.
156
+ - **Performance:** Keep middleware lightweight; use the proxy `matcher` so it does not run on API routes, `_next`, sitemap, robots, or static assets. Use Server Components for data fetching; add `'use client'` only where interactivity is needed. Use `generateStaticParams` and caching as in the existing page.
158
157
  - **Sitecore patterns:** Use SDK field components (`<Text>`, `<RichText>`, `<Image>`) and validate field existence before render. Register new components in `.sitecore/component-map.ts` and `.sitecore/component-map.client.ts` as appropriate. Use the single Sitecore client in `lib/sitecore-client.ts` for all data fetching.
159
158
  - **Consistency:** Follow the existing patterns in `[site]/[locale]/[[...path]]/page.tsx`, layout hierarchy, `i18n/request.ts` (site_locale), and API route handlers. When adding routes or rewrites, keep the middleware matcher and next-intl config in sync.
160
159
 
@@ -168,7 +167,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
168
167
  | Pass `{ site, locale }` to `client.getPage` and `getDictionary` | Assume site/locale from headers inside page without using params |
169
168
  | Run LocaleProxy before AppRouterMultisiteProxy in middleware | Change proxy order (locale must run first for i18n) |
170
169
  | Call `setRequestLocale(\`${site}_${locale}\`)` in the page for next-intl | Omit setRequestLocale when adding new page branches |
171
- | Use Suspense around async Server Components that use draftMode or fetch | Put async data fetching in client components when SSR is intended |
170
+ | Use Server Components for async data fetching | Put async data fetching in client components when SSR is intended |
172
171
  | Use `parseRewriteHeader(headers())` in not-found for site/locale | Hardcode site/locale in not-found or error pages |
173
172
  | Use createXRouteHandler and `.sitecore/sites.json` for sitemap/robots | Hardcode site list or commit `.env` |
174
173
  | Use Sitecore field components and validate fields | Expose API keys or editing secret in client code |
@@ -179,7 +178,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
179
178
 
180
179
  ## Guardrails for agentic AI
181
180
 
182
- - **Preserve behavior:** Do not change the proxy order (LocaleProxy → AppRouterMultisiteProxy → …), the `[site]/[locale]/[[...path]]` route shape, or the way `setRequestLocale` and `i18n/request.ts` use `{site}_{locale}`. Preserve PPR/Suspense boundaries and draftMode handling.
181
+ - **Preserve behavior:** Do not change the proxy order (LocaleProxy → AppRouterMultisiteProxy → …), the `[site]/[locale]/[[...path]]` route shape, or the way `setRequestLocale` and `i18n/request.ts` use `{site}_{locale}`. Preserve draftMode handling in layout and page.
183
182
  - **Do not expand scope:** Limit edits to the app (app router, components, API routes, i18n, config). Do not modify SDK packages or monorepo tooling unless explicitly asked. Do not change CI, lockfiles, or root config.
184
183
  - **Follow existing patterns:** When adding routes, layouts, or components, mirror the existing structure. Use the same Sitecore client, component maps, and env-based config. Do not introduce a different way to resolve site/locale or a second client without clear need.
185
184
  - **Verify and stay safe:** After edits, the app should build with `npm run build`. Do not commit secrets or `.env`; only document variables in `.env.example`. Do not add npm dependencies without explicit approval. When in doubt, prefer the existing implementation and ask for clarification.
@@ -208,6 +207,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
208
207
 
209
208
  ## References
210
209
 
210
+ - **Skills.md** — Capability groupings for this app; [.agents/skills/](.agents/skills/) provides each capability as an Agent Skill (when-to-use, hard rules, stop conditions) for tools that support the [Agent Skills](https://agentskills.io) standard.
211
211
  - **CLAUDE.md** — Full coding standards and Sitecore patterns for this template.
212
212
  - **.cursor/rules/** — App Router and Sitecore rules.
213
213
  - [Sitecore Content SDK](https://doc.sitecore.com/xmc/en/developers/content-sdk/sitecore-content-sdk-for-xm-cloud.html) — Official docs.
@@ -1,274 +1,9 @@
1
- # Claude Code Agent Guide for Sitecore Content SDK Next.js App Router Project
1
+ # Claude Code Sitecore Content SDK Next.js (App Router) App
2
2
 
3
- ## Project Purpose and Tech Stack
3
+ At the start of every session, read these files for full project guidance:
4
4
 
5
- This is a **Sitecore Content SDK** application built with **Next.js App Router** and **TypeScript**. The project follows Sitecore best practices for XM Cloud development and leverages the latest Next.js App Router features for improved performance and developer experience.
5
+ 1. **`AGENTS.md`** Canonical source of truth for this app: overview, commands, App Router structure, middleware, SitecoreClient, [site]/[locale]/[[...path]], next-intl, DO/DON'T, guardrails, boundaries
6
+ 2. **`.cursor/rules/`** — Coding rules for this template: general, javascript, sitecore, app-router-setup
7
+ 3. **`Skills.md`** and **`.agents/skills/`** — Capability-specific guidance (component registration, data fetching, editing, i18n, etc.) for tools that support the [Agent Skills](https://agentskills.io) standard.
6
8
 
7
- ### Key Technologies
8
- - **Next.js App Router** - React framework with Server Components and modern routing
9
- - **Sitecore Content SDK** - Official SDK for Sitecore XM Cloud integration
10
- - **TypeScript** - Type-safe JavaScript development
11
- - **Sitecore XM Cloud** - Headless CMS platform
12
- - **React Server Components** - Server-side rendering for better performance
13
- - **next-intl** - Internationalization support
14
-
15
- ## Coding Standards
16
-
17
- ### TypeScript Standards
18
- - Use **strict mode** in tsconfig.json
19
- - Prefer type assertions over `any`: `value as ContentItem`
20
- - Use discriminated unions for complex state management
21
- - Enable strict null checks and strict function types
22
-
23
- ### Naming Conventions
24
- - **Variables/Functions**: camelCase (`getUserData()`, `isLoading`, `currentUser`)
25
- - **Components**: PascalCase (`SitecoreComponent`, `PageLayout`, `ContentBlock`)
26
- - **Constants**: UPPER_SNAKE_CASE (`API_ENDPOINT`, `DEFAULT_TIMEOUT`)
27
- - **Directories**: kebab-case (`src/components`, `src/api-clients`)
28
- - **Types/Interfaces**: PascalCase (`ContentItem`, `LayoutProps`, `SitecoreConfig`)
29
-
30
- ### Modular Layout (App Router)
31
- ```
32
- src/
33
- app/ # App Router pages and layouts
34
- components/ # UI components (React)
35
- lib/ # Configuration and utilities
36
- i18n/ # Internationalization setup
37
- types/ # TypeScript type definitions
38
- hooks/ # Custom React hooks
39
- ```
40
-
41
- ## Library Usage
42
-
43
- ### @sitecore-content-sdk
44
- - Use `SitecoreClient` for content fetching
45
- - Implement proper error handling with try/catch blocks
46
- - Cache API responses using React Query or SWR
47
- - Handle content preview vs. published content scenarios
48
-
49
- ```typescript
50
- import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
51
- import scConfig from 'sitecore.config';
52
-
53
- const client = new SitecoreClient({
54
- ...scConfig,
55
- });
56
- ```
57
-
58
- ### React App Router Patterns
59
- - Use **Server Components** for data fetching and static content (default)
60
- - Use **Client Components** for interactivity (use 'use client' directive)
61
- - Implement proper error boundaries with error.tsx
62
- - Use loading.tsx for loading states
63
- - Leverage layout.tsx for shared page structure
64
-
65
- ### Sitecore Field Components
66
- - Always use Sitecore field components: `<Text>`, `<RichText>`, `<Image>`
67
- - Validate field existence before rendering
68
- - Handle empty/null fields gracefully
69
- - Prefer Sitecore field components over manual rendering
70
-
71
- ```typescript
72
- // Good: Using Sitecore field components
73
- <Text field={fields?.title} tag="h1" />
74
- <RichText field={fields?.content} />
75
- <Image field={fields?.backgroundImage} />
76
-
77
- // Avoid: Manual field value extraction unless necessary
78
- ```
79
-
80
- ## Example Patterns and Prompts
81
-
82
- ### Server Component Development
83
- ```typescript
84
- // Server Component example (default in App Router)
85
- import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
86
- import scConfig from 'sitecore.config';
87
-
88
- const client = new SitecoreClient({
89
- ...scConfig,
90
- });
91
-
92
- export default async function SitecorePage({ params }: { params: { path: string[] } }) {
93
- try {
94
- const pageData = await client.getPage(params.path.join('/'));
95
- return <SitecoreLayout layoutData={pageData?.layout} />;
96
- } catch (error) {
97
- return <div>Content not found</div>;
98
- }
99
- }
100
- ```
101
-
102
- ### Client Component Integration
103
-
104
- Interactive Sitecore Components:
105
-
106
- - Use 'use client' directive when needed
107
- - Keep client components focused on interactivity
108
- - Pass server-fetched data as props
109
- - Handle hydration mismatches carefully
110
-
111
- ```typescript
112
- 'use client';
113
-
114
- interface InteractiveSitecoreComponentProps {
115
- fields: {
116
- title: Field;
117
- content: Field;
118
- };
119
- }
120
-
121
- export default function InteractiveSitecoreComponent({
122
- fields,
123
- }: InteractiveSitecoreComponentProps) {
124
- // Client-side interactivity here
125
- return (
126
- <div>
127
- <Text field={fields?.title} tag="h2" />
128
- <RichText field={fields?.content} />
129
- </div>
130
- );
131
- }
132
- ```
133
-
134
- ### Component Development
135
- ```typescript
136
- // Component props interface
137
- interface HeroProps {
138
- fields: {
139
- title: Field;
140
- subtitle: Field;
141
- backgroundImage: Field;
142
- };
143
- }
144
-
145
- export default function Hero({ fields }: HeroProps) {
146
- return (
147
- <div>
148
- <Text field={fields?.title} tag="h1" />
149
- <Text field={fields?.subtitle} tag="p" />
150
- <Image field={fields?.backgroundImage} />
151
- </div>
152
- );
153
- }
154
- ```
155
-
156
- ### Error Handling
157
-
158
- API Calls:
159
-
160
- - Always wrap in try/catch blocks
161
- - Throw custom errors with context: `SitecoreFetchError`, `ConfigurationError`
162
- - Handle edge cases with guard clauses
163
-
164
- ```typescript
165
- async function fetchPageData(path: string): Promise<Page | null> {
166
- if (!path) {
167
- throw new Error('Page path is required');
168
- }
169
-
170
- try {
171
- const pageData = await client.getPage(path);
172
- return pageData;
173
- } catch (error) {
174
- throw new SitecoreFetchError(`Failed to fetch page data for ${path}`, error);
175
- }
176
- }
177
- ```
178
-
179
- ### Configuration
180
- ```typescript
181
- // sitecore.config.ts
182
- import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
183
-
184
- export default defineConfig({
185
- api: {
186
- edge: {
187
- contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
188
- clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
189
- edgeUrl:
190
- process.env.NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME ||
191
- process.env.SITECORE_EDGE_PLATFORM_HOSTNAME ||
192
- 'https://edge-platform.sitecorecloud.io',
193
- },
194
- local: {
195
- apiKey: process.env.SITECORE_API_KEY || '',
196
- apiHost: process.env.SITECORE_API_HOST || '',
197
- },
198
- },
199
- defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
200
- defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
201
- editingSecret: process.env.SITECORE_EDITING_SECRET,
202
- });
203
- ```
204
-
205
- ### Internationalization
206
-
207
- Multi-language Support:
208
-
209
- - Configure next-intl for language routing
210
- - Handle Sitecore language contexts
211
- - Implement language switching
212
- - Use proper locale-based data fetching
213
-
214
- ```typescript
215
- // Language-aware data fetching
216
- import { getTranslations } from 'next-intl/server';
217
-
218
- export default async function LocalizedPage() {
219
- const t = await getTranslations('common');
220
- // Fetch Sitecore content for current locale
221
- }
222
- ```
223
-
224
- ## Development Workflow
225
-
226
- 1. **Install dependencies**: `npm install`
227
- 2. **Configure environment**: Copy `.env.example` to `.env.local`
228
- 3. **Start development**: `npm run dev`
229
- 4. **Build for production**: `npm run build`
230
-
231
- ## App Router Best Practices
232
-
233
- ### Server vs Client Components
234
- - Use Server Components for Sitecore content rendering (default)
235
- - Use Client Components for user interactions
236
- - Minimize client-side JavaScript
237
- - Leverage server-side data fetching
238
-
239
- ### Routing and Layouts
240
- - Use layout.tsx for shared page structure
241
- - Implement loading.tsx for loading states
242
- - Create error.tsx for error boundaries
243
- - Use page.tsx for route content
244
- - Use [...path] for Sitecore catch-all routes
245
-
246
- ### Performance Optimization
247
- - Leverage Server Components for better performance
248
- - Use streaming for improved loading experience
249
- - Implement proper caching strategies
250
- - Optimize images with Next.js Image component
251
-
252
- ## Best Practices
253
-
254
- ### Performance
255
- - Optimize images using Next.js Image component
256
- - Implement proper loading states
257
- - Cache expensive operations appropriately
258
- - Consider server-side rendering implications
259
- - Lazy-load non-critical modules
260
- - Use Server Components for better performance
261
-
262
- ### Security
263
- - Sanitize user inputs before processing
264
- - Validate data at application boundaries
265
- - Use HTTPS for all Sitecore connections
266
- - Never expose sensitive configuration in client-side code
267
- - Escape content when rendering to prevent XSS
268
-
269
- ### Code Quality
270
- - Follow DRY principle - extract common functionality
271
- - Use SOLID principles for maintainable code
272
- - Write self-documenting code with clear intent
273
- - Implement proper error boundaries
274
- - Test behavior, not implementation details
9
+ This file applies to **this scaffolded head application only**. For the Content SDK monorepo (packages, CLI, templates source), use that repo's root `AGENTS.md` and `.cursor/rules/`.
@@ -5,39 +5,3 @@
5
5
  -->
6
6
 
7
7
  [Documentation](https://doc.sitecore.com/xmc/en/developers/xm-cloud/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
8
-
9
- ## Next.js Cache Components
10
-
11
- Cache Components is **disabled by default** in this template. To enable it:
12
-
13
- 1. **Enable in `next.config.ts`**:
14
- ```typescript
15
- const nextConfig: NextConfig = {
16
- cacheComponents: true,
17
- // ... rest of config
18
- };
19
- ```
20
-
21
- 2. **Add uncached data access** in all server components that call client methods:
22
-
23
- Next.js 16 with Cache Components requires accessing uncached data (`draftMode()`, `cookies()`, `headers()`, or `searchParams`) before any operations that might use `new Date()` or other time-related functions.
24
-
25
- Example:
26
- ```typescript
27
- export default async function Page({ params, searchParams }: PageProps) {
28
- // Access uncached data first
29
- await draftMode();
30
-
31
- const { site, locale, path } = await params;
32
- // ... rest of component
33
- }
34
- ```
35
-
36
- Apply this pattern to:
37
- - Page components that call `client.getPage()`, `client.getPreview()`, etc.
38
- - `generateMetadata` functions
39
- - Layout components that call client methods
40
- - Not-found handlers
41
- - Any server component calling Sitecore client methods
42
-
43
- 3. **See the sample app** (`samples/nextjs-app-router`) for a working example with Cache Components enabled.