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,186 +1,186 @@
1
- # Sitecore Content SDK Next.js Project - Windsurf AI Rules
2
-
3
- ## Project Purpose and Tech Stack
4
-
5
- This is a **Sitecore Content SDK** application built with **Next.js** and **TypeScript**. The project follows Sitecore best practices for XM Cloud development and provides a modern, performant web application framework.
6
-
7
- ### Key Technologies
8
-
9
- - **Next.js** - React framework with SSR/SSG capabilities
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** - Component-based UI library
14
-
15
- ## Coding Standards
16
-
17
- ### TypeScript Standards
18
-
19
- - Use **strict mode** in tsconfig.json
20
- - Prefer type assertions over `any`: `value as ContentItem`
21
- - Use discriminated unions for complex state management
22
- - Enable strict null checks and strict function types
23
-
24
- ### Naming Conventions
25
-
26
- - **Variables/Functions**: camelCase (`getUserData()`, `isLoading`, `currentUser`)
27
- - **Components**: PascalCase (`SitecoreComponent`, `PageLayout`, `ContentBlock`)
28
- - **Constants**: UPPER_SNAKE_CASE (`API_ENDPOINT`, `DEFAULT_TIMEOUT`)
29
- - **Directories**: kebab-case (`src/components`, `src/api-clients`)
30
- - **Types/Interfaces**: PascalCase (`ContentItem`, `LayoutProps`, `SitecoreConfig`)
31
-
32
- ### Modular Layout
33
-
34
- ```
35
- src/
36
- components/ # UI components (React)
37
- lib/ # Configuration and utilities
38
- pages/ # Next.js pages
39
- assets/ # Static assets and styles
40
- types/ # TypeScript type definitions
41
- hooks/ # Custom React hooks
42
- ```
43
-
44
- ## Library Usage
45
-
46
- ### @sitecore-content-sdk
47
-
48
- - Use `SitecoreClient` for content fetching
49
- - Implement proper error handling with try/catch blocks
50
- - Cache API responses using React Query or SWR
51
- - Handle content preview vs. published content scenarios
52
-
53
- ```typescript
54
- import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
55
- import scConfig from 'sitecore.config';
56
-
57
- const client = new SitecoreClient({
58
- ...scConfig,
59
- });
60
- ```
61
-
62
- ### React Patterns
63
-
64
- - Use **Server Components** for data fetching and static content
65
- - Use **Client Components** for interactivity (use 'use client')
66
- - Implement proper error boundaries
67
- - Use React.memo for expensive components
68
- - Leverage useCallback and useMemo for performance optimization
69
-
70
- ### Sitecore Field Components
71
-
72
- - Always use Sitecore field components: `<Text>`, `<RichText>`, `<Image>`
73
- - Validate field existence before rendering
74
- - Handle empty/null fields gracefully
75
- - Prefer Sitecore field components over manual rendering
76
-
77
- ```typescript
78
- // Good: Using Sitecore field components
79
- <Text field={fields?.title} tag="h1" />
80
- <RichText field={fields?.content} />
81
- <Image field={fields?.backgroundImage} />
82
-
83
- // Avoid: Manual field value extraction unless necessary
84
- ```
85
-
86
- ## Example Patterns and Prompts
87
-
88
- ### Component Development
89
-
90
- ```typescript
91
- // Component props interface
92
- interface HeroProps {
93
- fields: {
94
- title: Field;
95
- subtitle: Field;
96
- backgroundImage: Field;
97
- };
98
- }
99
-
100
- export default function Hero({ fields }: HeroProps) {
101
- return (
102
- <div>
103
- <Text field={fields?.title} tag="h1" />
104
- <Text field={fields?.subtitle} tag="p" />
105
- <Image field={fields?.backgroundImage} />
106
- </div>
107
- );
108
- }
109
- ```
110
-
111
- ### Error Handling
112
-
113
- ```typescript
114
- async function fetchPageData(path: string): Promise<Page | null> {
115
- if (!path) {
116
- throw new Error('Page path is required');
117
- }
118
-
119
- try {
120
- const pageData = await client.getPage(path);
121
- return pageData;
122
- } catch (error) {
123
- throw new SitecoreFetchError(`Failed to fetch page data for ${path}`, error);
124
- }
125
- }
126
- ```
127
-
128
- ### Configuration
129
-
130
- ```typescript
131
- // sitecore.config.ts
132
- import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
133
-
134
- export default defineConfig({
135
- api: {
136
- edge: {
137
- contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
138
- clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
139
- edgeUrl:
140
- process.env.NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME ||
141
- process.env.SITECORE_EDGE_PLATFORM_HOSTNAME ||
142
- 'https://edge-platform.sitecorecloud.io',
143
- },
144
- local: {
145
- apiKey: process.env.SITECORE_API_KEY || '',
146
- apiHost: process.env.SITECORE_API_HOST || '',
147
- },
148
- },
149
- defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
150
- defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
151
- editingSecret: process.env.SITECORE_EDITING_SECRET,
152
- });
153
- ```
154
-
155
- ## Development Workflow
156
-
157
- 1. **Install dependencies**: `npm install`
158
- 2. **Configure environment**: Copy `.env.example` to `.env.local`
159
- 3. **Start development**: `npm run dev`
160
- 4. **Build for production**: `npm run build`
161
-
162
- ## Best Practices
163
-
164
- ### Performance
165
-
166
- - Optimize images using Next.js Image component
167
- - Implement proper loading states
168
- - Cache expensive operations appropriately
169
- - Consider server-side rendering implications
170
- - Lazy-load non-critical modules
171
-
172
- ### Security
173
-
174
- - Sanitize user inputs before processing
175
- - Validate data at application boundaries
176
- - Use HTTPS for all Sitecore connections
177
- - Never expose sensitive configuration in client-side code
178
- - Escape content when rendering to prevent XSS
179
-
180
- ### Code Quality
181
-
182
- - Follow DRY principle - extract common functionality
183
- - Use SOLID principles for maintainable code
184
- - Write self-documenting code with clear intent
185
- - Implement proper error boundaries
186
- - Test behavior, not implementation details
1
+ # Sitecore Content SDK Next.js Project - Windsurf AI Rules
2
+
3
+ ## Project Purpose and Tech Stack
4
+
5
+ This is a **Sitecore Content SDK** application built with **Next.js** and **TypeScript**. The project follows Sitecore best practices for XM Cloud development and provides a modern, performant web application framework.
6
+
7
+ ### Key Technologies
8
+
9
+ - **Next.js** - React framework with SSR/SSG capabilities
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** - Component-based UI library
14
+
15
+ ## Coding Standards
16
+
17
+ ### TypeScript Standards
18
+
19
+ - Use **strict mode** in tsconfig.json
20
+ - Prefer type assertions over `any`: `value as ContentItem`
21
+ - Use discriminated unions for complex state management
22
+ - Enable strict null checks and strict function types
23
+
24
+ ### Naming Conventions
25
+
26
+ - **Variables/Functions**: camelCase (`getUserData()`, `isLoading`, `currentUser`)
27
+ - **Components**: PascalCase (`SitecoreComponent`, `PageLayout`, `ContentBlock`)
28
+ - **Constants**: UPPER_SNAKE_CASE (`API_ENDPOINT`, `DEFAULT_TIMEOUT`)
29
+ - **Directories**: kebab-case (`src/components`, `src/api-clients`)
30
+ - **Types/Interfaces**: PascalCase (`ContentItem`, `LayoutProps`, `SitecoreConfig`)
31
+
32
+ ### Modular Layout
33
+
34
+ ```
35
+ src/
36
+ components/ # UI components (React)
37
+ lib/ # Configuration and utilities
38
+ pages/ # Next.js pages
39
+ assets/ # Static assets and styles
40
+ types/ # TypeScript type definitions
41
+ hooks/ # Custom React hooks
42
+ ```
43
+
44
+ ## Library Usage
45
+
46
+ ### @sitecore-content-sdk
47
+
48
+ - Use `SitecoreClient` for content fetching
49
+ - Implement proper error handling with try/catch blocks
50
+ - Cache API responses using React Query or SWR
51
+ - Handle content preview vs. published content scenarios
52
+
53
+ ```typescript
54
+ import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
55
+ import scConfig from 'sitecore.config';
56
+
57
+ const client = new SitecoreClient({
58
+ ...scConfig,
59
+ });
60
+ ```
61
+
62
+ ### React Patterns
63
+
64
+ - Use **Server Components** for data fetching and static content
65
+ - Use **Client Components** for interactivity (use 'use client')
66
+ - Implement proper error boundaries
67
+ - Use React.memo for expensive components
68
+ - Leverage useCallback and useMemo for performance optimization
69
+
70
+ ### Sitecore Field Components
71
+
72
+ - Always use Sitecore field components: `<Text>`, `<RichText>`, `<Image>`
73
+ - Validate field existence before rendering
74
+ - Handle empty/null fields gracefully
75
+ - Prefer Sitecore field components over manual rendering
76
+
77
+ ```typescript
78
+ // Good: Using Sitecore field components
79
+ <Text field={fields?.title} tag="h1" />
80
+ <RichText field={fields?.content} />
81
+ <Image field={fields?.backgroundImage} />
82
+
83
+ // Avoid: Manual field value extraction unless necessary
84
+ ```
85
+
86
+ ## Example Patterns and Prompts
87
+
88
+ ### Component Development
89
+
90
+ ```typescript
91
+ // Component props interface
92
+ interface HeroProps {
93
+ fields: {
94
+ title: Field;
95
+ subtitle: Field;
96
+ backgroundImage: Field;
97
+ };
98
+ }
99
+
100
+ export default function Hero({ fields }: HeroProps) {
101
+ return (
102
+ <div>
103
+ <Text field={fields?.title} tag="h1" />
104
+ <Text field={fields?.subtitle} tag="p" />
105
+ <Image field={fields?.backgroundImage} />
106
+ </div>
107
+ );
108
+ }
109
+ ```
110
+
111
+ ### Error Handling
112
+
113
+ ```typescript
114
+ async function fetchPageData(path: string): Promise<Page | null> {
115
+ if (!path) {
116
+ throw new Error('Page path is required');
117
+ }
118
+
119
+ try {
120
+ const pageData = await client.getPage(path);
121
+ return pageData;
122
+ } catch (error) {
123
+ throw new SitecoreFetchError(`Failed to fetch page data for ${path}`, error);
124
+ }
125
+ }
126
+ ```
127
+
128
+ ### Configuration
129
+
130
+ ```typescript
131
+ // sitecore.config.ts
132
+ import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
133
+
134
+ export default defineConfig({
135
+ api: {
136
+ edge: {
137
+ contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
138
+ clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
139
+ edgeUrl:
140
+ process.env.NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME ||
141
+ process.env.SITECORE_EDGE_PLATFORM_HOSTNAME ||
142
+ 'https://edge-platform.sitecorecloud.io',
143
+ },
144
+ local: {
145
+ apiKey: process.env.SITECORE_API_KEY || '',
146
+ apiHost: process.env.SITECORE_API_HOST || '',
147
+ },
148
+ },
149
+ defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
150
+ defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
151
+ editingSecret: process.env.SITECORE_EDITING_SECRET,
152
+ });
153
+ ```
154
+
155
+ ## Development Workflow
156
+
157
+ 1. **Install dependencies**: `npm install`
158
+ 2. **Configure environment**: Copy `.env.example` to `.env.local`
159
+ 3. **Start development**: `npm run dev`
160
+ 4. **Build for production**: `npm run build`
161
+
162
+ ## Best Practices
163
+
164
+ ### Performance
165
+
166
+ - Optimize images using Next.js Image component
167
+ - Implement proper loading states
168
+ - Cache expensive operations appropriately
169
+ - Consider server-side rendering implications
170
+ - Lazy-load non-critical modules
171
+
172
+ ### Security
173
+
174
+ - Sanitize user inputs before processing
175
+ - Validate data at application boundaries
176
+ - Use HTTPS for all Sitecore connections
177
+ - Never expose sensitive configuration in client-side code
178
+ - Escape content when rendering to prevent XSS
179
+
180
+ ### Code Quality
181
+
182
+ - Follow DRY principle - extract common functionality
183
+ - Use SOLID principles for maintainable code
184
+ - Write self-documenting code with clear intent
185
+ - Implement proper error boundaries
186
+ - Test behavior, not implementation details
@@ -183,6 +183,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
183
183
 
184
184
  ## References
185
185
 
186
+ - **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.
186
187
  - **CLAUDE.md** — Full coding standards and Sitecore patterns for this template.
187
188
  - **.cursor/rules/** — Project and Sitecore rules.
188
189
  - [Sitecore Content SDK](https://doc.sitecore.com/xmc/en/developers/content-sdk/sitecore-content-sdk-for-xm-cloud.html) — Official docs.
@@ -1,173 +1,9 @@
1
- # Claude Code Agent Guide for Sitecore Content SDK Next.js Project
1
+ # Claude Code Sitecore Content SDK Next.js (Pages 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** and **TypeScript**. The project follows Sitecore best practices for XM Cloud development and provides a modern, performant web application framework.
5
+ 1. **`AGENTS.md`** Canonical source of truth for this app: overview, commands, application structure, middleware, SitecoreClient, catch-all route, i18n, DO/DON'T, guardrails, boundaries
6
+ 2. **`.cursor/rules/`** — Coding rules for this template: general, javascript, sitecore, project-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** - React framework with SSR/SSG capabilities
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** - Component-based UI library
13
-
14
- ## Coding Standards
15
-
16
- ### TypeScript Standards
17
- - Use **strict mode** in tsconfig.json
18
- - Prefer type assertions over `any`: `value as ContentItem`
19
- - Use discriminated unions for complex state management
20
- - Enable strict null checks and strict function types
21
-
22
- ### Naming Conventions
23
- - **Variables/Functions**: camelCase (`getUserData()`, `isLoading`, `currentUser`)
24
- - **Components**: PascalCase (`SitecoreComponent`, `PageLayout`, `ContentBlock`)
25
- - **Constants**: UPPER_SNAKE_CASE (`API_ENDPOINT`, `DEFAULT_TIMEOUT`)
26
- - **Directories**: kebab-case (`src/components`, `src/api-clients`)
27
- - **Types/Interfaces**: PascalCase (`ContentItem`, `LayoutProps`, `SitecoreConfig`)
28
-
29
- ### Modular Layout
30
- ```
31
- src/
32
- components/ # UI components (React)
33
- lib/ # Configuration and utilities
34
- pages/ # Next.js pages
35
- assets/ # Static assets and styles
36
- types/ # TypeScript type definitions
37
- hooks/ # Custom React hooks
38
- ```
39
-
40
- ## Library Usage
41
-
42
- ### @sitecore-content-sdk
43
- - Use `SitecoreClient` for content fetching
44
- - Implement proper error handling with try/catch blocks
45
- - Cache API responses using React Query or SWR
46
- - Handle content preview vs. published content scenarios
47
-
48
- ```typescript
49
- import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
50
- import scConfig from 'sitecore.config';
51
-
52
- const client = new SitecoreClient({
53
- ...scConfig,
54
- });
55
- ```
56
-
57
- ### React Patterns
58
- - Use **Server Components** for data fetching and static content
59
- - Use **Client Components** for interactivity (use 'use client')
60
- - Implement proper error boundaries
61
- - Use React.memo for expensive components
62
- - Leverage useCallback and useMemo for performance optimization
63
-
64
- ### Sitecore Field Components
65
- - Always use Sitecore field components: `<Text>`, `<RichText>`, `<Image>`
66
- - Validate field existence before rendering
67
- - Handle empty/null fields gracefully
68
- - Prefer Sitecore field components over manual rendering
69
-
70
- ```typescript
71
- // Good: Using Sitecore field components
72
- <Text field={fields?.title} tag="h1" />
73
- <RichText field={fields?.content} />
74
- <Image field={fields?.backgroundImage} />
75
-
76
- // Avoid: Manual field value extraction unless necessary
77
- ```
78
-
79
- ## Example Patterns and Prompts
80
-
81
- ### Component Development
82
- ```typescript
83
- // Component props interface
84
- interface HeroProps {
85
- fields: {
86
- title: Field;
87
- subtitle: Field;
88
- backgroundImage: Field;
89
- };
90
- }
91
-
92
- export default function Hero({ fields }: HeroProps) {
93
- return (
94
- <div>
95
- <Text field={fields?.title} tag="h1" />
96
- <Text field={fields?.subtitle} tag="p" />
97
- <Image field={fields?.backgroundImage} />
98
- </div>
99
- );
100
- }
101
- ```
102
-
103
- ### Error Handling
104
- ```typescript
105
- async function fetchPageData(path: string): Promise<Page | null> {
106
- if (!path) {
107
- throw new Error('Page path is required');
108
- }
109
-
110
- try {
111
- const pageData = await client.getPage(path);
112
- return pageData;
113
- } catch (error) {
114
- throw new SitecoreFetchError(`Failed to fetch page data for ${path}`, error);
115
- }
116
- }
117
- ```
118
-
119
- ### Configuration
120
- ```typescript
121
- // sitecore.config.ts
122
- import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
123
-
124
- export default defineConfig({
125
- api: {
126
- edge: {
127
- contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
128
- clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
129
- edgeUrl:
130
- process.env.NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME ||
131
- process.env.SITECORE_EDGE_PLATFORM_HOSTNAME ||
132
- 'https://edge-platform.sitecorecloud.io',
133
- },
134
- local: {
135
- apiKey: process.env.SITECORE_API_KEY || '',
136
- apiHost: process.env.SITECORE_API_HOST || '',
137
- },
138
- },
139
- defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
140
- defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
141
- editingSecret: process.env.SITECORE_EDITING_SECRET,
142
- });
143
- ```
144
-
145
- ## Development Workflow
146
-
147
- 1. **Install dependencies**: `npm install`
148
- 2. **Configure environment**: Copy `.env.example` to `.env.local`
149
- 3. **Start development**: `npm run dev`
150
- 4. **Build for production**: `npm run build`
151
-
152
- ## Best Practices
153
-
154
- ### Performance
155
- - Optimize images using Next.js Image component
156
- - Implement proper loading states
157
- - Cache expensive operations appropriately
158
- - Consider server-side rendering implications
159
- - Lazy-load non-critical modules
160
-
161
- ### Security
162
- - Sanitize user inputs before processing
163
- - Validate data at application boundaries
164
- - Use HTTPS for all Sitecore connections
165
- - Never expose sensitive configuration in client-side code
166
- - Escape content when rendering to prevent XSS
167
-
168
- ### Code Quality
169
- - Follow DRY principle - extract common functionality
170
- - Use SOLID principles for maintainable code
171
- - Write self-documenting code with clear intent
172
- - Implement proper error boundaries
173
- - 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/`.