create-content-sdk-app 2.0.0 → 2.0.2-canary.0

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 (115) hide show
  1. package/LICENSE.MD +202 -202
  2. package/dist/templates/nextjs/.agents/skills/content-sdk-component-data-strategy/SKILL.md +37 -0
  3. package/dist/templates/nextjs/.agents/skills/content-sdk-component-registration/SKILL.md +36 -0
  4. package/dist/templates/nextjs/.agents/skills/content-sdk-component-scaffold/SKILL.md +34 -0
  5. package/dist/templates/nextjs/.agents/skills/content-sdk-component-variants/SKILL.md +36 -0
  6. package/dist/templates/nextjs/.agents/skills/content-sdk-dictionary-and-i18n/SKILL.md +35 -0
  7. package/dist/templates/nextjs/.agents/skills/content-sdk-editing-safe-rendering/SKILL.md +37 -0
  8. package/dist/templates/nextjs/.agents/skills/content-sdk-field-usage-image-link-text/SKILL.md +36 -0
  9. package/dist/templates/nextjs/.agents/skills/content-sdk-graphql-data-fetching/SKILL.md +38 -0
  10. package/dist/templates/nextjs/.agents/skills/content-sdk-multisite-management/SKILL.md +37 -0
  11. package/dist/templates/nextjs/.agents/skills/content-sdk-route-configuration/SKILL.md +38 -0
  12. package/dist/templates/nextjs/.agents/skills/content-sdk-site-setup-and-env/SKILL.md +36 -0
  13. package/dist/templates/nextjs/.agents/skills/content-sdk-sitemap-robots/SKILL.md +37 -0
  14. package/dist/templates/nextjs/.agents/skills/content-sdk-troubleshoot-editing/SKILL.md +39 -0
  15. package/dist/templates/nextjs/.agents/skills/content-sdk-upgrade-assistant/SKILL.md +36 -0
  16. package/dist/templates/nextjs/.cursor/rules/general.mdc +81 -81
  17. package/dist/templates/nextjs/.cursor/rules/javascript.mdc +112 -112
  18. package/dist/templates/nextjs/.cursor/rules/project-setup.mdc +100 -100
  19. package/dist/templates/nextjs/.cursor/rules/sitecore.mdc +150 -150
  20. package/dist/templates/nextjs/.env.container.example +27 -27
  21. package/dist/templates/nextjs/.env.remote.example +51 -51
  22. package/dist/templates/nextjs/.gitattributes +11 -11
  23. package/dist/templates/nextjs/.prettierrc +8 -8
  24. package/dist/templates/nextjs/.vscode/extensions.json +8 -8
  25. package/dist/templates/nextjs/.vscode/launch.json +15 -15
  26. package/dist/templates/nextjs/.windsurfrules +186 -186
  27. package/dist/templates/nextjs/AGENTS.md +1 -0
  28. package/dist/templates/nextjs/CLAUDE.md +6 -170
  29. package/dist/templates/nextjs/LICENSE.txt +202 -202
  30. package/dist/templates/nextjs/Skills.md +79 -0
  31. package/dist/templates/nextjs/eslint.config.mjs +81 -81
  32. package/dist/templates/nextjs/gitignore +28 -28
  33. package/dist/templates/nextjs/package.json +68 -68
  34. package/dist/templates/nextjs/sitecore.config.ts.example +40 -40
  35. package/dist/templates/nextjs/src/Bootstrap.tsx +20 -13
  36. package/dist/templates/nextjs/src/byoc/index.tsx +1 -1
  37. package/dist/templates/nextjs/src/components/content-sdk/CdpPageView.tsx +1 -1
  38. package/dist/templates/nextjs/tsconfig.json +40 -40
  39. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-data-strategy/SKILL.md +37 -0
  40. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-registration/SKILL.md +38 -0
  41. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-scaffold/SKILL.md +38 -0
  42. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-variants/SKILL.md +36 -0
  43. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-dictionary-and-i18n/SKILL.md +37 -0
  44. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-editing-safe-rendering/SKILL.md +37 -0
  45. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-field-usage-image-link-text/SKILL.md +36 -0
  46. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-graphql-data-fetching/SKILL.md +37 -0
  47. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-multisite-management/SKILL.md +37 -0
  48. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-route-configuration/SKILL.md +38 -0
  49. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-site-setup-and-env/SKILL.md +36 -0
  50. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-sitemap-robots/SKILL.md +37 -0
  51. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-troubleshoot-editing/SKILL.md +39 -0
  52. package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-upgrade-assistant/SKILL.md +36 -0
  53. package/dist/templates/nextjs-app-router/.cursor/rules/app-router-setup.mdc +116 -116
  54. package/dist/templates/nextjs-app-router/.cursor/rules/general.mdc +80 -80
  55. package/dist/templates/nextjs-app-router/.cursor/rules/javascript.mdc +112 -112
  56. package/dist/templates/nextjs-app-router/.cursor/rules/sitecore.mdc +174 -174
  57. package/dist/templates/nextjs-app-router/.env.container.example +27 -27
  58. package/dist/templates/nextjs-app-router/.env.remote.example +51 -51
  59. package/dist/templates/nextjs-app-router/.gitattributes +11 -11
  60. package/dist/templates/nextjs-app-router/.sitecore/import-map.server.ts +2 -2
  61. package/dist/templates/nextjs-app-router/.windsurfrules +290 -290
  62. package/dist/templates/nextjs-app-router/AGENTS.md +6 -6
  63. package/dist/templates/nextjs-app-router/CLAUDE.md +6 -271
  64. package/dist/templates/nextjs-app-router/README.md +0 -36
  65. package/dist/templates/nextjs-app-router/Skills.md +79 -0
  66. package/dist/templates/nextjs-app-router/eslint.config.mjs +29 -29
  67. package/dist/templates/nextjs-app-router/gitignore +31 -31
  68. package/dist/templates/nextjs-app-router/package.json +55 -54
  69. package/dist/templates/nextjs-app-router/postcss.config.mjs +5 -5
  70. package/dist/templates/nextjs-app-router/sitecore.config.ts.example +40 -40
  71. package/dist/templates/nextjs-app-router/src/Bootstrap.tsx +20 -12
  72. package/dist/templates/nextjs-app-router/src/app/[site]/[locale]/[[...path]]/layout.tsx +19 -0
  73. package/dist/templates/nextjs-app-router/src/app/[site]/[locale]/[[...path]]/not-found.tsx +3 -28
  74. package/dist/templates/nextjs-app-router/src/app/[site]/[locale]/[[...path]]/page.tsx +6 -21
  75. package/dist/templates/nextjs-app-router/src/app/[site]/layout.tsx +5 -21
  76. package/dist/templates/nextjs-app-router/src/app/globals.css +1 -1
  77. package/dist/templates/nextjs-app-router/src/app/not-found.tsx +1 -23
  78. package/dist/templates/nextjs-app-router/src/byoc/index.tsx +1 -1
  79. package/dist/templates/nextjs-app-router/src/components/content-sdk/CdpPageView.tsx +1 -1
  80. package/dist/templates/nextjs-app-router/tsconfig.json +48 -48
  81. package/package.json +2 -2
  82. package/dist/initializers/angular/args.js +0 -2
  83. package/dist/initializers/angular/index.js +0 -30
  84. package/dist/initializers/angular/prompts.js +0 -20
  85. package/dist/templates/angular/.postcssrc.json +0 -5
  86. package/dist/templates/angular/.vscode/extensions.json +0 -4
  87. package/dist/templates/angular/README.md +0 -3
  88. package/dist/templates/angular/angular.json +0 -79
  89. package/dist/templates/angular/package.json +0 -58
  90. package/dist/templates/angular/public/favicon.ico +0 -0
  91. package/dist/templates/angular/src/app/app.config.server.ts +0 -12
  92. package/dist/templates/angular/src/app/app.config.ts +0 -31
  93. package/dist/templates/angular/src/app/app.css +0 -0
  94. package/dist/templates/angular/src/app/app.html +0 -1
  95. package/dist/templates/angular/src/app/app.routes.server.ts +0 -15
  96. package/dist/templates/angular/src/app/app.routes.ts +0 -28
  97. package/dist/templates/angular/src/app/app.ts +0 -12
  98. package/dist/templates/angular/src/app/loaders/error.loader.ts +0 -12
  99. package/dist/templates/angular/src/app/loaders/index.ts +0 -14
  100. package/dist/templates/angular/src/app/loaders/not-found.loader.ts +0 -12
  101. package/dist/templates/angular/src/app/loaders/page.loader.ts +0 -15
  102. package/dist/templates/angular/src/app/loaders/stub-utils.ts +0 -83
  103. package/dist/templates/angular/src/app/pages/error.component.ts +0 -124
  104. package/dist/templates/angular/src/app/pages/not-found.component.ts +0 -85
  105. package/dist/templates/angular/src/app/pages/page.component.ts +0 -58
  106. package/dist/templates/angular/src/app/shared/layout.component.ts +0 -106
  107. package/dist/templates/angular/src/index.html +0 -13
  108. package/dist/templates/angular/src/main.server.ts +0 -8
  109. package/dist/templates/angular/src/main.ts +0 -6
  110. package/dist/templates/angular/src/server.ts +0 -65
  111. package/dist/templates/angular/src/styles.css +0 -3
  112. package/dist/templates/angular/tsconfig.json +0 -38
  113. package/dist/templates/angular/tsconfig.spec.json +0 -10
  114. package/dist/templates/nextjs/LLMs.txt +0 -179
  115. package/dist/templates/nextjs-app-router/LLMs.txt +0 -236
@@ -1,290 +1,290 @@
1
- # Sitecore Content SDK Next.js App Router Project - Windsurf AI Rules
2
-
3
- ## Project Purpose and Tech Stack
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.
6
-
7
- ### Key Technologies
8
-
9
- - **Next.js App Router** - React framework with Server Components and modern routing
10
- - **Sitecore Content SDK** - Official SDK for Sitecore XM Cloud integration
11
- - **TypeScript** - Type-safe JavaScript development
12
- - **Sitecore XM Cloud** - Headless CMS platform
13
- - **React Server Components** - Server-side rendering for better performance
14
- - **next-intl** - Internationalization support
15
-
16
- ## Coding Standards
17
-
18
- ### TypeScript Standards
19
-
20
- - Use **strict mode** in tsconfig.json
21
- - Prefer type assertions over `any`: `value as ContentItem`
22
- - Use discriminated unions for complex state management
23
- - Enable strict null checks and strict function types
24
-
25
- ### Naming Conventions
26
-
27
- - **Variables/Functions**: camelCase (`getUserData()`, `isLoading`, `currentUser`)
28
- - **Components**: PascalCase (`SitecoreComponent`, `PageLayout`, `ContentBlock`)
29
- - **Constants**: UPPER_SNAKE_CASE (`API_ENDPOINT`, `DEFAULT_TIMEOUT`)
30
- - **Directories**: kebab-case (`src/components`, `src/api-clients`)
31
- - **Types/Interfaces**: PascalCase (`ContentItem`, `LayoutProps`, `SitecoreConfig`)
32
-
33
- ### Modular Layout (App Router)
34
-
35
- ```
36
- src/
37
- app/ # App Router pages and layouts
38
- components/ # UI components (React)
39
- lib/ # Configuration and utilities
40
- i18n/ # Internationalization setup
41
- types/ # TypeScript type definitions
42
- hooks/ # Custom React hooks
43
- ```
44
-
45
- ## Library Usage
46
-
47
- ### @sitecore-content-sdk
48
-
49
- - Use `SitecoreClient` for content fetching
50
- - Implement proper error handling with try/catch blocks
51
- - Cache API responses using React Query or SWR
52
- - Handle content preview vs. published content scenarios
53
-
54
- ```typescript
55
- import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
56
- import scConfig from 'sitecore.config';
57
-
58
- const client = new SitecoreClient({
59
- ...scConfig,
60
- });
61
- ```
62
-
63
- ### React App Router Patterns
64
-
65
- - Use **Server Components** for data fetching and static content (default)
66
- - Use **Client Components** for interactivity (use 'use client' directive)
67
- - Implement proper error boundaries with error.tsx
68
- - Use loading.tsx for loading states
69
- - Leverage layout.tsx for shared page structure
70
-
71
- ### Sitecore Field Components
72
-
73
- - Always use Sitecore field components: `<Text>`, `<RichText>`, `<Image>`
74
- - Validate field existence before rendering
75
- - Handle empty/null fields gracefully
76
- - Prefer Sitecore field components over manual rendering
77
-
78
- ```typescript
79
- // Good: Using Sitecore field components
80
- <Text field={fields?.title} tag="h1" />
81
- <RichText field={fields?.content} />
82
- <Image field={fields?.backgroundImage} />
83
-
84
- // Avoid: Manual field value extraction unless necessary
85
- ```
86
-
87
- ## Example Patterns and Prompts
88
-
89
- ### Server Component Development
90
-
91
- ```typescript
92
- // Server Component example (default in App Router)
93
- import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
94
- import scConfig from 'sitecore.config';
95
-
96
- const client = new SitecoreClient({
97
- ...scConfig,
98
- });
99
-
100
- export default async function SitecorePage({ params }: { params: { path: string[] } }) {
101
- try {
102
- const pageData = await client.getPage(params.path.join('/'));
103
- return <SitecoreLayout layoutData={pageData?.layout} />;
104
- } catch (error) {
105
- return <div>Content not found</div>;
106
- }
107
- }
108
- ```
109
-
110
- ### Client Component Integration
111
-
112
- Interactive Sitecore Components:
113
-
114
- - Use 'use client' directive when needed
115
- - Keep client components focused on interactivity
116
- - Pass server-fetched data as props
117
- - Handle hydration mismatches carefully
118
-
119
- ```typescript
120
- 'use client';
121
-
122
- interface InteractiveSitecoreComponentProps {
123
- fields: {
124
- title: Field;
125
- content: Field;
126
- };
127
- }
128
-
129
- export default function InteractiveSitecoreComponent({
130
- fields,
131
- }: InteractiveSitecoreComponentProps) {
132
- // Client-side interactivity here
133
- return (
134
- <div>
135
- <Text field={fields?.title} tag="h2" />
136
- <RichText field={fields?.content} />
137
- </div>
138
- );
139
- }
140
- ```
141
-
142
- ### Component Development
143
-
144
- ```typescript
145
- // Component props interface
146
- interface HeroProps {
147
- fields: {
148
- title: Field;
149
- subtitle: Field;
150
- backgroundImage: Field;
151
- };
152
- }
153
-
154
- export default function Hero({ fields }: HeroProps) {
155
- return (
156
- <div>
157
- <Text field={fields?.title} tag="h1" />
158
- <Text field={fields?.subtitle} tag="p" />
159
- <Image field={fields?.backgroundImage} />
160
- </div>
161
- );
162
- }
163
- ```
164
-
165
- ### Error Handling
166
-
167
- API Calls:
168
-
169
- - Always wrap in try/catch blocks
170
- - Throw custom errors with context: `SitecoreFetchError`, `ConfigurationError`
171
- - Handle edge cases with guard clauses
172
-
173
- ```typescript
174
- async function fetchPageData(path: string): Promise<Page | null> {
175
- if (!path) {
176
- throw new Error('Page path is required');
177
- }
178
-
179
- try {
180
- const pageData = await client.getPage(path);
181
- return pageData;
182
- } catch (error) {
183
- throw new SitecoreFetchError(`Failed to fetch page data for ${path}`, error);
184
- }
185
- }
186
- ```
187
-
188
- ### Configuration
189
-
190
- ```typescript
191
- // sitecore.config.ts
192
- import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
193
-
194
- export default defineConfig({
195
- api: {
196
- edge: {
197
- contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
198
- clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
199
- edgeUrl:
200
- process.env.NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME ||
201
- process.env.SITECORE_EDGE_PLATFORM_HOSTNAME ||
202
- 'https://edge-platform.sitecorecloud.io',
203
- },
204
- local: {
205
- apiKey: process.env.SITECORE_API_KEY || '',
206
- apiHost: process.env.SITECORE_API_HOST || '',
207
- },
208
- },
209
- defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
210
- defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
211
- editingSecret: process.env.SITECORE_EDITING_SECRET,
212
- });
213
- ```
214
-
215
- ### Internationalization
216
-
217
- Multi-language Support:
218
-
219
- - Configure next-intl for language routing
220
- - Handle Sitecore language contexts
221
- - Implement language switching
222
- - Use proper locale-based data fetching
223
-
224
- ```typescript
225
- // Language-aware data fetching
226
- import { getTranslations } from 'next-intl/server';
227
-
228
- export default async function LocalizedPage() {
229
- const t = await getTranslations('common');
230
- // Fetch Sitecore content for current locale
231
- }
232
- ```
233
-
234
- ## Development Workflow
235
-
236
- 1. **Install dependencies**: `npm install`
237
- 2. **Configure environment**: Copy `.env.example` to `.env.local`
238
- 3. **Start development**: `npm run dev`
239
- 4. **Build for production**: `npm run build`
240
-
241
- ## App Router Best Practices
242
-
243
- ### Server vs Client Components
244
-
245
- - Use Server Components for Sitecore content rendering (default)
246
- - Use Client Components for user interactions
247
- - Minimize client-side JavaScript
248
- - Leverage server-side data fetching
249
-
250
- ### Routing and Layouts
251
-
252
- - Use layout.tsx for shared page structure
253
- - Implement loading.tsx for loading states
254
- - Create error.tsx for error boundaries
255
- - Use page.tsx for route content
256
- - Use [...path] for Sitecore catch-all routes
257
-
258
- ### Performance Optimization
259
-
260
- - Leverage Server Components for better performance
261
- - Use streaming for improved loading experience
262
- - Implement proper caching strategies
263
- - Optimize images with Next.js Image component
264
-
265
- ## Best Practices
266
-
267
- ### Performance
268
-
269
- - Optimize images using Next.js Image component
270
- - Implement proper loading states
271
- - Cache expensive operations appropriately
272
- - Consider server-side rendering implications
273
- - Lazy-load non-critical modules
274
- - Use Server Components for better performance
275
-
276
- ### Security
277
-
278
- - Sanitize user inputs before processing
279
- - Validate data at application boundaries
280
- - Use HTTPS for all Sitecore connections
281
- - Never expose sensitive configuration in client-side code
282
- - Escape content when rendering to prevent XSS
283
-
284
- ### Code Quality
285
-
286
- - Follow DRY principle - extract common functionality
287
- - Use SOLID principles for maintainable code
288
- - Write self-documenting code with clear intent
289
- - Implement proper error boundaries
290
- - Test behavior, not implementation details
1
+ # Sitecore Content SDK Next.js App Router Project - Windsurf AI Rules
2
+
3
+ ## Project Purpose and Tech Stack
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.
6
+
7
+ ### Key Technologies
8
+
9
+ - **Next.js App Router** - React framework with Server Components and modern routing
10
+ - **Sitecore Content SDK** - Official SDK for Sitecore XM Cloud integration
11
+ - **TypeScript** - Type-safe JavaScript development
12
+ - **Sitecore XM Cloud** - Headless CMS platform
13
+ - **React Server Components** - Server-side rendering for better performance
14
+ - **next-intl** - Internationalization support
15
+
16
+ ## Coding Standards
17
+
18
+ ### TypeScript Standards
19
+
20
+ - Use **strict mode** in tsconfig.json
21
+ - Prefer type assertions over `any`: `value as ContentItem`
22
+ - Use discriminated unions for complex state management
23
+ - Enable strict null checks and strict function types
24
+
25
+ ### Naming Conventions
26
+
27
+ - **Variables/Functions**: camelCase (`getUserData()`, `isLoading`, `currentUser`)
28
+ - **Components**: PascalCase (`SitecoreComponent`, `PageLayout`, `ContentBlock`)
29
+ - **Constants**: UPPER_SNAKE_CASE (`API_ENDPOINT`, `DEFAULT_TIMEOUT`)
30
+ - **Directories**: kebab-case (`src/components`, `src/api-clients`)
31
+ - **Types/Interfaces**: PascalCase (`ContentItem`, `LayoutProps`, `SitecoreConfig`)
32
+
33
+ ### Modular Layout (App Router)
34
+
35
+ ```
36
+ src/
37
+ app/ # App Router pages and layouts
38
+ components/ # UI components (React)
39
+ lib/ # Configuration and utilities
40
+ i18n/ # Internationalization setup
41
+ types/ # TypeScript type definitions
42
+ hooks/ # Custom React hooks
43
+ ```
44
+
45
+ ## Library Usage
46
+
47
+ ### @sitecore-content-sdk
48
+
49
+ - Use `SitecoreClient` for content fetching
50
+ - Implement proper error handling with try/catch blocks
51
+ - Cache API responses using React Query or SWR
52
+ - Handle content preview vs. published content scenarios
53
+
54
+ ```typescript
55
+ import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
56
+ import scConfig from 'sitecore.config';
57
+
58
+ const client = new SitecoreClient({
59
+ ...scConfig,
60
+ });
61
+ ```
62
+
63
+ ### React App Router Patterns
64
+
65
+ - Use **Server Components** for data fetching and static content (default)
66
+ - Use **Client Components** for interactivity (use 'use client' directive)
67
+ - Implement proper error boundaries with error.tsx
68
+ - Use loading.tsx for loading states
69
+ - Leverage layout.tsx for shared page structure
70
+
71
+ ### Sitecore Field Components
72
+
73
+ - Always use Sitecore field components: `<Text>`, `<RichText>`, `<Image>`
74
+ - Validate field existence before rendering
75
+ - Handle empty/null fields gracefully
76
+ - Prefer Sitecore field components over manual rendering
77
+
78
+ ```typescript
79
+ // Good: Using Sitecore field components
80
+ <Text field={fields?.title} tag="h1" />
81
+ <RichText field={fields?.content} />
82
+ <Image field={fields?.backgroundImage} />
83
+
84
+ // Avoid: Manual field value extraction unless necessary
85
+ ```
86
+
87
+ ## Example Patterns and Prompts
88
+
89
+ ### Server Component Development
90
+
91
+ ```typescript
92
+ // Server Component example (default in App Router)
93
+ import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
94
+ import scConfig from 'sitecore.config';
95
+
96
+ const client = new SitecoreClient({
97
+ ...scConfig,
98
+ });
99
+
100
+ export default async function SitecorePage({ params }: { params: { path: string[] } }) {
101
+ try {
102
+ const pageData = await client.getPage(params.path.join('/'));
103
+ return <SitecoreLayout layoutData={pageData?.layout} />;
104
+ } catch (error) {
105
+ return <div>Content not found</div>;
106
+ }
107
+ }
108
+ ```
109
+
110
+ ### Client Component Integration
111
+
112
+ Interactive Sitecore Components:
113
+
114
+ - Use 'use client' directive when needed
115
+ - Keep client components focused on interactivity
116
+ - Pass server-fetched data as props
117
+ - Handle hydration mismatches carefully
118
+
119
+ ```typescript
120
+ 'use client';
121
+
122
+ interface InteractiveSitecoreComponentProps {
123
+ fields: {
124
+ title: Field;
125
+ content: Field;
126
+ };
127
+ }
128
+
129
+ export default function InteractiveSitecoreComponent({
130
+ fields,
131
+ }: InteractiveSitecoreComponentProps) {
132
+ // Client-side interactivity here
133
+ return (
134
+ <div>
135
+ <Text field={fields?.title} tag="h2" />
136
+ <RichText field={fields?.content} />
137
+ </div>
138
+ );
139
+ }
140
+ ```
141
+
142
+ ### Component Development
143
+
144
+ ```typescript
145
+ // Component props interface
146
+ interface HeroProps {
147
+ fields: {
148
+ title: Field;
149
+ subtitle: Field;
150
+ backgroundImage: Field;
151
+ };
152
+ }
153
+
154
+ export default function Hero({ fields }: HeroProps) {
155
+ return (
156
+ <div>
157
+ <Text field={fields?.title} tag="h1" />
158
+ <Text field={fields?.subtitle} tag="p" />
159
+ <Image field={fields?.backgroundImage} />
160
+ </div>
161
+ );
162
+ }
163
+ ```
164
+
165
+ ### Error Handling
166
+
167
+ API Calls:
168
+
169
+ - Always wrap in try/catch blocks
170
+ - Throw custom errors with context: `SitecoreFetchError`, `ConfigurationError`
171
+ - Handle edge cases with guard clauses
172
+
173
+ ```typescript
174
+ async function fetchPageData(path: string): Promise<Page | null> {
175
+ if (!path) {
176
+ throw new Error('Page path is required');
177
+ }
178
+
179
+ try {
180
+ const pageData = await client.getPage(path);
181
+ return pageData;
182
+ } catch (error) {
183
+ throw new SitecoreFetchError(`Failed to fetch page data for ${path}`, error);
184
+ }
185
+ }
186
+ ```
187
+
188
+ ### Configuration
189
+
190
+ ```typescript
191
+ // sitecore.config.ts
192
+ import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
193
+
194
+ export default defineConfig({
195
+ api: {
196
+ edge: {
197
+ contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
198
+ clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
199
+ edgeUrl:
200
+ process.env.NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME ||
201
+ process.env.SITECORE_EDGE_PLATFORM_HOSTNAME ||
202
+ 'https://edge-platform.sitecorecloud.io',
203
+ },
204
+ local: {
205
+ apiKey: process.env.SITECORE_API_KEY || '',
206
+ apiHost: process.env.SITECORE_API_HOST || '',
207
+ },
208
+ },
209
+ defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
210
+ defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
211
+ editingSecret: process.env.SITECORE_EDITING_SECRET,
212
+ });
213
+ ```
214
+
215
+ ### Internationalization
216
+
217
+ Multi-language Support:
218
+
219
+ - Configure next-intl for language routing
220
+ - Handle Sitecore language contexts
221
+ - Implement language switching
222
+ - Use proper locale-based data fetching
223
+
224
+ ```typescript
225
+ // Language-aware data fetching
226
+ import { getTranslations } from 'next-intl/server';
227
+
228
+ export default async function LocalizedPage() {
229
+ const t = await getTranslations('common');
230
+ // Fetch Sitecore content for current locale
231
+ }
232
+ ```
233
+
234
+ ## Development Workflow
235
+
236
+ 1. **Install dependencies**: `npm install`
237
+ 2. **Configure environment**: Copy `.env.example` to `.env.local`
238
+ 3. **Start development**: `npm run dev`
239
+ 4. **Build for production**: `npm run build`
240
+
241
+ ## App Router Best Practices
242
+
243
+ ### Server vs Client Components
244
+
245
+ - Use Server Components for Sitecore content rendering (default)
246
+ - Use Client Components for user interactions
247
+ - Minimize client-side JavaScript
248
+ - Leverage server-side data fetching
249
+
250
+ ### Routing and Layouts
251
+
252
+ - Use layout.tsx for shared page structure
253
+ - Implement loading.tsx for loading states
254
+ - Create error.tsx for error boundaries
255
+ - Use page.tsx for route content
256
+ - Use [...path] for Sitecore catch-all routes
257
+
258
+ ### Performance Optimization
259
+
260
+ - Leverage Server Components for better performance
261
+ - Use streaming for improved loading experience
262
+ - Implement proper caching strategies
263
+ - Optimize images with Next.js Image component
264
+
265
+ ## Best Practices
266
+
267
+ ### Performance
268
+
269
+ - Optimize images using Next.js Image component
270
+ - Implement proper loading states
271
+ - Cache expensive operations appropriately
272
+ - Consider server-side rendering implications
273
+ - Lazy-load non-critical modules
274
+ - Use Server Components for better performance
275
+
276
+ ### Security
277
+
278
+ - Sanitize user inputs before processing
279
+ - Validate data at application boundaries
280
+ - Use HTTPS for all Sitecore connections
281
+ - Never expose sensitive configuration in client-side code
282
+ - Escape content when rendering to prevent XSS
283
+
284
+ ### Code Quality
285
+
286
+ - Follow DRY principle - extract common functionality
287
+ - Use SOLID principles for maintainable code
288
+ - Write self-documenting code with clear intent
289
+ - Implement proper error boundaries
290
+ - Test behavior, not implementation details
@@ -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.