@decocms/start 0.19.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.
- package/.cursor/skills/deco-api-call-dedup/SKILL.md +443 -0
- package/.cursor/skills/deco-apps-architecture/SKILL.md +255 -0
- package/.cursor/skills/deco-apps-architecture/app-pattern.md +288 -0
- package/.cursor/skills/deco-apps-architecture/commerce-types.md +239 -0
- package/.cursor/skills/deco-apps-architecture/new-app-guide.md +268 -0
- package/.cursor/skills/deco-apps-architecture/scripts-codegen.md +148 -0
- package/.cursor/skills/deco-apps-architecture/shared-utils.md +181 -0
- package/.cursor/skills/deco-apps-architecture/vtex-deep-structure.md +253 -0
- package/.cursor/skills/deco-apps-architecture/website-app.md +169 -0
- package/.cursor/skills/deco-apps-vtex-porting/SKILL.md +189 -0
- package/.cursor/skills/deco-apps-vtex-porting/adaptation-patterns.md +335 -0
- package/.cursor/skills/deco-apps-vtex-porting/commerce-porting.md +155 -0
- package/.cursor/skills/deco-apps-vtex-porting/cookie-auth-patterns.md +148 -0
- package/.cursor/skills/deco-apps-vtex-porting/structure-map.md +234 -0
- package/.cursor/skills/deco-apps-vtex-porting/transform-mapping.md +99 -0
- package/.cursor/skills/deco-apps-vtex-porting/website-porting.md +194 -0
- package/.cursor/skills/deco-apps-vtex-review/SKILL.md +234 -0
- package/.cursor/skills/deco-async-rendering-architecture/SKILL.md +270 -0
- package/.cursor/skills/deco-async-rendering-site-guide/SKILL.md +417 -0
- package/.cursor/skills/deco-cms-layout-caching/SKILL.md +293 -0
- package/.cursor/skills/deco-cms-route-config/SKILL.md +388 -0
- package/.cursor/skills/deco-core-architecture/SKILL.md +185 -0
- package/.cursor/skills/deco-core-architecture/blocks.md +196 -0
- package/.cursor/skills/deco-core-architecture/deco-vs-deco-start.md +191 -0
- package/.cursor/skills/deco-core-architecture/engine.md +220 -0
- package/.cursor/skills/deco-core-architecture/hooks-components.md +157 -0
- package/.cursor/skills/deco-core-architecture/plugins-clients.md +136 -0
- package/.cursor/skills/deco-core-architecture/runtime.md +116 -0
- package/.cursor/skills/deco-core-architecture/site-usage.md +165 -0
- package/.cursor/skills/deco-e2e-testing/SKILL.md +372 -0
- package/.cursor/skills/deco-e2e-testing/discovery.md +337 -0
- package/.cursor/skills/deco-e2e-testing/scripts/scaffold.sh +81 -0
- package/.cursor/skills/deco-e2e-testing/selectors.md +175 -0
- package/.cursor/skills/deco-e2e-testing/templates/package.json +18 -0
- package/.cursor/skills/deco-e2e-testing/templates/playwright.config.ts +65 -0
- package/.cursor/skills/deco-e2e-testing/templates/scripts/baseline.ts +279 -0
- package/.cursor/skills/deco-e2e-testing/templates/scripts/run-e2e.ts +194 -0
- package/.cursor/skills/deco-e2e-testing/templates/specs/ecommerce-flow.spec.ts +612 -0
- package/.cursor/skills/deco-e2e-testing/templates/tsconfig.json +12 -0
- package/.cursor/skills/deco-e2e-testing/templates/utils/metrics-collector.ts +918 -0
- package/.cursor/skills/deco-e2e-testing/troubleshooting.md +602 -0
- package/.cursor/skills/deco-edge-caching/SKILL.md +316 -0
- package/.cursor/skills/deco-full-analysis/SKILL.md +898 -0
- package/.cursor/skills/deco-full-analysis/checklists/asset-optimization.md +251 -0
- package/.cursor/skills/deco-full-analysis/checklists/bug-fix.md +189 -0
- package/.cursor/skills/deco-full-analysis/checklists/cache-strategy.md +144 -0
- package/.cursor/skills/deco-full-analysis/checklists/dependency-update.md +150 -0
- package/.cursor/skills/deco-full-analysis/checklists/hydration-fix.md +191 -0
- package/.cursor/skills/deco-full-analysis/checklists/image-optimization.md +180 -0
- package/.cursor/skills/deco-full-analysis/checklists/loader-optimization.md +165 -0
- package/.cursor/skills/deco-full-analysis/checklists/seo-fix.md +183 -0
- package/.cursor/skills/deco-full-analysis/checklists/site-cleanup.md +281 -0
- package/.cursor/skills/deco-full-analysis/discovery.md +548 -0
- package/.cursor/skills/deco-incident-debugging/SKILL.md +378 -0
- package/.cursor/skills/deco-incident-debugging/headless-mode.md +510 -0
- package/.cursor/skills/deco-incident-debugging/learnings-index.md +227 -0
- package/.cursor/skills/deco-incident-debugging/triage-workflow.md +312 -0
- package/.cursor/skills/deco-islands-migration/SKILL.md +251 -0
- package/.cursor/skills/deco-loader-n-plus-1-detector/SKILL.md +275 -0
- package/.cursor/skills/deco-performance-audit/SKILL.md +530 -0
- package/.cursor/skills/deco-performance-audit/tools-reference.md +428 -0
- package/.cursor/skills/deco-performance-audit/workflow.md +457 -0
- package/.cursor/skills/deco-server-functions-invoke/SKILL.md +92 -0
- package/.cursor/skills/deco-server-functions-invoke/architecture.md +166 -0
- package/.cursor/skills/deco-server-functions-invoke/generator.md +122 -0
- package/.cursor/skills/deco-server-functions-invoke/problem.md +98 -0
- package/.cursor/skills/deco-server-functions-invoke/troubleshooting.md +110 -0
- package/.cursor/skills/deco-site-deployment/SKILL.md +396 -0
- package/.cursor/skills/deco-site-memory-debugging/SKILL.md +121 -0
- package/.cursor/skills/deco-site-memory-debugging/cdp-connection.md +222 -0
- package/.cursor/skills/deco-site-memory-debugging/memory-analysis.md +362 -0
- package/.cursor/skills/deco-site-patterns/SKILL.md +124 -0
- package/.cursor/skills/deco-site-patterns/app-composition.md +337 -0
- package/.cursor/skills/deco-site-patterns/client-patterns.md +341 -0
- package/.cursor/skills/deco-site-patterns/cms-wiring.md +230 -0
- package/.cursor/skills/deco-site-patterns/section-patterns.md +340 -0
- package/.cursor/skills/deco-site-scaling-tuning/SKILL.md +240 -0
- package/.cursor/skills/deco-site-scaling-tuning/analysis-scripts.md +267 -0
- package/.cursor/skills/deco-start-architecture/SKILL.md +218 -0
- package/.cursor/skills/deco-start-architecture/admin-protocol.md +156 -0
- package/.cursor/skills/deco-start-architecture/cms-resolution.md +201 -0
- package/.cursor/skills/deco-start-architecture/code-quality.md +158 -0
- package/.cursor/skills/deco-start-architecture/gap-analysis.md +129 -0
- package/.cursor/skills/deco-start-architecture/sdk-utilities.md +197 -0
- package/.cursor/skills/deco-start-architecture/worker-entry-caching.md +154 -0
- package/.cursor/skills/deco-startup-analysis/SKILL.md +248 -0
- package/.cursor/skills/deco-storefront-test-checklist/SKILL.md +369 -0
- package/.cursor/skills/deco-tanstack-hydration-fixes/SKILL.md +468 -0
- package/.cursor/skills/deco-tanstack-navigation/SKILL.md +681 -0
- package/.cursor/skills/deco-tanstack-search/SKILL.md +411 -0
- package/.cursor/skills/deco-tanstack-storefront-patterns/SKILL.md +1013 -0
- package/.cursor/skills/deco-to-tanstack-migration/SKILL.md +518 -0
- package/.cursor/skills/deco-to-tanstack-migration/references/codemod-commands.md +174 -0
- package/.cursor/skills/deco-to-tanstack-migration/references/commerce/README.md +78 -0
- package/.cursor/skills/deco-to-tanstack-migration/references/deco-framework/README.md +128 -0
- package/.cursor/skills/deco-to-tanstack-migration/references/gotchas.md +719 -0
- package/.cursor/skills/deco-to-tanstack-migration/references/imports/README.md +70 -0
- package/.cursor/skills/deco-to-tanstack-migration/references/platform-hooks/README.md +154 -0
- package/.cursor/skills/deco-to-tanstack-migration/references/signals/README.md +220 -0
- package/.cursor/skills/deco-to-tanstack-migration/references/vite-config/README.md +78 -0
- package/.cursor/skills/deco-to-tanstack-migration/templates/package-json.md +55 -0
- package/.cursor/skills/deco-to-tanstack-migration/templates/root-route.md +110 -0
- package/.cursor/skills/deco-to-tanstack-migration/templates/router.md +96 -0
- package/.cursor/skills/deco-to-tanstack-migration/templates/setup-ts.md +167 -0
- package/.cursor/skills/deco-to-tanstack-migration/templates/vite-config.md +122 -0
- package/.cursor/skills/deco-to-tanstack-migration/templates/worker-entry.md +67 -0
- package/.cursor/skills/deco-typescript-fixes/SKILL.md +178 -0
- package/.cursor/skills/deco-typescript-fixes/common-fixes.md +330 -0
- package/.cursor/skills/deco-typescript-fixes/strategy.md +148 -0
- package/.cursor/skills/deco-variant-selection-perf/SKILL.md +272 -0
- package/.cursor/skills/deco-vtex-fetch-cache/SKILL.md +225 -0
- package/.cursor/skills/find-skills/SKILL.md +133 -0
- package/.cursor/skills/incident-report/SKILL.md +179 -0
- package/.cursor/skills/incident-report/references/5-whys.md +75 -0
- package/.cursor/skills/incident-report/templates/client-report.md +187 -0
- package/.cursor/skills/incident-report/templates/internal-report.md +206 -0
- package/.cursor/skills/template-skill/SKILL.md +38 -0
- package/.github/workflows/release.yml +32 -0
- package/.releaserc.json +25 -0
- package/CLAUDE.md +135 -0
- package/GAP_ANALYSIS.md +224 -0
- package/GAP_ANALYSIS_V2.md +1013 -0
- package/biome.json +39 -0
- package/knip.json +5 -0
- package/package.json +87 -0
- package/scripts/generate-blocks.ts +69 -0
- package/scripts/generate-invoke.ts +378 -0
- package/scripts/generate-schema.ts +657 -0
- package/src/admin/cors.ts +29 -0
- package/src/admin/decofile.ts +72 -0
- package/src/admin/index.ts +24 -0
- package/src/admin/invoke.ts +163 -0
- package/src/admin/liveControls.ts +29 -0
- package/src/admin/meta.ts +70 -0
- package/src/admin/render.ts +205 -0
- package/src/admin/schema.ts +686 -0
- package/src/admin/setup.ts +44 -0
- package/src/cms/index.ts +59 -0
- package/src/cms/loader.ts +180 -0
- package/src/cms/registry.ts +162 -0
- package/src/cms/resolve.ts +1005 -0
- package/src/cms/sectionLoaders.ts +294 -0
- package/src/hooks/DecoPageRenderer.tsx +444 -0
- package/src/hooks/LazySection.tsx +109 -0
- package/src/hooks/LiveControls.tsx +108 -0
- package/src/hooks/SectionErrorFallback.tsx +85 -0
- package/src/hooks/index.ts +8 -0
- package/src/index.ts +5 -0
- package/src/matchers/builtins.ts +184 -0
- package/src/matchers/posthog.ts +154 -0
- package/src/middleware/decoState.ts +55 -0
- package/src/middleware/healthMetrics.ts +131 -0
- package/src/middleware/index.ts +80 -0
- package/src/middleware/liveness.ts +21 -0
- package/src/middleware/observability.ts +205 -0
- package/src/routes/adminRoutes.ts +83 -0
- package/src/routes/cmsRoute.ts +302 -0
- package/src/routes/components.tsx +34 -0
- package/src/routes/index.ts +15 -0
- package/src/sdk/analytics.ts +72 -0
- package/src/sdk/cacheHeaders.ts +268 -0
- package/src/sdk/cachedLoader.ts +206 -0
- package/src/sdk/clx.ts +3 -0
- package/src/sdk/cookie.ts +39 -0
- package/src/sdk/createInvoke.ts +57 -0
- package/src/sdk/csp.ts +59 -0
- package/src/sdk/env.ts +27 -0
- package/src/sdk/index.ts +63 -0
- package/src/sdk/instrumentedFetch.ts +137 -0
- package/src/sdk/invoke.ts +133 -0
- package/src/sdk/mergeCacheControl.ts +150 -0
- package/src/sdk/redirects.ts +217 -0
- package/src/sdk/requestContext.ts +184 -0
- package/src/sdk/serverTimings.ts +68 -0
- package/src/sdk/signal.ts +41 -0
- package/src/sdk/sitemap.ts +143 -0
- package/src/sdk/urlUtils.ts +117 -0
- package/src/sdk/useDevice.ts +82 -0
- package/src/sdk/useId.ts +7 -0
- package/src/sdk/useScript.ts +101 -0
- package/src/sdk/workerEntry.ts +703 -0
- package/src/sdk/wrapCaughtErrors.ts +107 -0
- package/src/types/index.ts +39 -0
- package/src/types/widgets.ts +13 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,898 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deco-full-analysis
|
|
3
|
+
description: Run a full analysis of a Deco site - generates AGENTS.md with architecture, navigation flows, caching inventory, block health, and optimization findings. Includes 114 learnings from real sites as 9 checklists.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Deco Full Analysis
|
|
7
|
+
|
|
8
|
+
Run a comprehensive analysis of a Deco e-commerce site. Generates **AGENTS.md** - a complete guide with architecture, custom code inventory, navigation flows, and everything an AI agent needs to work effectively with the codebase.
|
|
9
|
+
|
|
10
|
+
Includes **114 optimization learnings** from real Deco sites organized into 9 checklists covering loaders, images, caching, SEO, hydration, assets, bugs, dependencies, and site cleanup.
|
|
11
|
+
|
|
12
|
+
## When to Use This Skill
|
|
13
|
+
|
|
14
|
+
- Onboarding to a new Deco site
|
|
15
|
+
- Before making significant changes
|
|
16
|
+
- Understanding the site's architecture
|
|
17
|
+
- Documenting custom implementations
|
|
18
|
+
- Preparing for code reviews
|
|
19
|
+
- **Validating block configurations** match TypeScript Props
|
|
20
|
+
|
|
21
|
+
## What It Produces
|
|
22
|
+
|
|
23
|
+
### 1. AGENTS.md
|
|
24
|
+
A comprehensive guide for AI agents containing:
|
|
25
|
+
- Framework versions and stack (Fresh vs HTMX)
|
|
26
|
+
- Apps installed and their versions
|
|
27
|
+
- Key page blocks (Home, PDP, PLP, Search, etc.)
|
|
28
|
+
- **Navigation flow** - How pages connect to each other
|
|
29
|
+
- **Lazy loading map** - Which sections are lazy on each page
|
|
30
|
+
- **Caching inventory** - Which loaders have cache vs don't
|
|
31
|
+
- Custom sections, loaders, and actions
|
|
32
|
+
- Integration details (VTEX, Shopify, etc.)
|
|
33
|
+
- **Critical user journeys** - Common flows to test
|
|
34
|
+
- **Debugging tips** - How to troubleshoot common issues
|
|
35
|
+
- Top committers and ownership
|
|
36
|
+
|
|
37
|
+
### 2. BLOCKS_DIAGNOSTICS.md
|
|
38
|
+
A human-readable diagnostics report from block validation:
|
|
39
|
+
- **Summary metrics** - Total files, valid %, errors, unused counts
|
|
40
|
+
- **Critical issues** - Top errors grouped by root cause with impact assessment
|
|
41
|
+
- **Schema errors** - Tables of sections/loaders/actions with type mismatches
|
|
42
|
+
- **Unused code inventory** - Categorized lists for cleanup review
|
|
43
|
+
- **Prioritized recommendations** - Actionable fix suggestions
|
|
44
|
+
- **Re-run commands** - How to regenerate the report
|
|
45
|
+
|
|
46
|
+
### 3. validation-report.json
|
|
47
|
+
Structured JSON report for programmatic use:
|
|
48
|
+
- Timestamps and project metadata
|
|
49
|
+
- Summary counts (sections, errors, warnings, unused)
|
|
50
|
+
- Detailed error list with file, line, property, message
|
|
51
|
+
- Full unused files list
|
|
52
|
+
|
|
53
|
+
### 4. README.md Updates
|
|
54
|
+
If the README is outdated or missing key info:
|
|
55
|
+
- How to run the site locally
|
|
56
|
+
- Environment setup
|
|
57
|
+
- Key commands
|
|
58
|
+
- Link to AGENTS.md
|
|
59
|
+
|
|
60
|
+
## Workflow
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
1. Analyze deno.json → Framework versions, dependencies, apps
|
|
64
|
+
2. Analyze .deco/blocks/ → Page configurations, key blocks
|
|
65
|
+
3. Map page navigation → How pages link together
|
|
66
|
+
4. Identify lazy sections → Find Rendering/Lazy.tsx wrappers
|
|
67
|
+
5. Analyze loaders/ → Custom data loading
|
|
68
|
+
6. Audit cache headers → Check for `export const cache`
|
|
69
|
+
7. Analyze sections/ → Custom UI components
|
|
70
|
+
8. Analyze actions/ → Custom mutations
|
|
71
|
+
9. Run block validation → Generate validation-report.json
|
|
72
|
+
10. Generate BLOCKS_DIAGNOSTICS.md → Human-readable diagnostics
|
|
73
|
+
11. Search Deco docs → Understand patterns used
|
|
74
|
+
12. Check git log → Top committers
|
|
75
|
+
13. Generate AGENTS.md → Comprehensive guide with all sections
|
|
76
|
+
14. Update README.md → Quick start, run commands
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Tools Used
|
|
80
|
+
|
|
81
|
+
### Code Analysis (file system)
|
|
82
|
+
- Read `deno.json` for dependencies and versions
|
|
83
|
+
- Read `.deco/blocks/*.json` for page configurations
|
|
84
|
+
- List `sections/`, `loaders/`, `actions/` directories
|
|
85
|
+
- Read key component files
|
|
86
|
+
|
|
87
|
+
### Deco Documentation
|
|
88
|
+
```
|
|
89
|
+
SearchDecoCx({ query: "blocks sections loaders" })
|
|
90
|
+
```
|
|
91
|
+
Use this to understand Deco patterns and concepts.
|
|
92
|
+
|
|
93
|
+
### Git Analysis
|
|
94
|
+
```bash
|
|
95
|
+
git log --format='%an' | sort | uniq -c | sort -rn | head -10
|
|
96
|
+
```
|
|
97
|
+
Find top committers (code owners).
|
|
98
|
+
|
|
99
|
+
## Key Files to Analyze
|
|
100
|
+
|
|
101
|
+
| File/Directory | Purpose |
|
|
102
|
+
|----------------|---------|
|
|
103
|
+
| `deno.json` | Framework versions, apps, dependencies |
|
|
104
|
+
| `.deco/blocks/pages-*.json` | Page configurations |
|
|
105
|
+
| `.deco/blocks/Header*.json` | Header configurations |
|
|
106
|
+
| `sections/` | Custom UI components |
|
|
107
|
+
| `loaders/` | Custom data loaders |
|
|
108
|
+
| `actions/` | Custom mutations |
|
|
109
|
+
| `apps/` | App configurations |
|
|
110
|
+
| `fresh.gen.ts` | Generated routes/islands |
|
|
111
|
+
| `manifest.gen.ts` | Generated manifest |
|
|
112
|
+
|
|
113
|
+
## Framework Detection
|
|
114
|
+
|
|
115
|
+
### Fresh Stack (SSR + Islands)
|
|
116
|
+
```json
|
|
117
|
+
// deno.json
|
|
118
|
+
{
|
|
119
|
+
"imports": {
|
|
120
|
+
"@deco/deco": "jsr:@deco/deco@...",
|
|
121
|
+
"preact": "npm:preact@...",
|
|
122
|
+
"$fresh/": "..."
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
- Uses `islands/` for interactive components
|
|
127
|
+
- Uses `routes/` for pages
|
|
128
|
+
- Sections render on server
|
|
129
|
+
|
|
130
|
+
### HTMX Stack
|
|
131
|
+
```json
|
|
132
|
+
// deno.json
|
|
133
|
+
{
|
|
134
|
+
"imports": {
|
|
135
|
+
"@deco/deco/htmx": "..."
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
- Uses HTMX for interactivity
|
|
140
|
+
- Sections can have `hx-*` attributes
|
|
141
|
+
|
|
142
|
+
## Understanding Page Blocks
|
|
143
|
+
|
|
144
|
+
Page blocks in `.deco/blocks/pages-*.json` define which sections appear on each page:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"name": "Home (principal)",
|
|
149
|
+
"__resolveType": "website/pages/Page.tsx",
|
|
150
|
+
"sections": [
|
|
151
|
+
{ "__resolveType": "site/sections/Header/Header.tsx" },
|
|
152
|
+
{ "__resolveType": "website/sections/Rendering/Lazy.tsx",
|
|
153
|
+
"section": { "__resolveType": "site/sections/Product/ProductShelf.tsx" }
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Key patterns:
|
|
160
|
+
- `site/sections/*` - Custom sections in the repo
|
|
161
|
+
- `website/sections/*` - Sections from website app
|
|
162
|
+
- `Rendering/Lazy.tsx` - Lazy-loaded sections
|
|
163
|
+
- `Rendering/Deferred.tsx` - Deferred sections
|
|
164
|
+
|
|
165
|
+
## App Analysis
|
|
166
|
+
|
|
167
|
+
Apps in Deco provide loaders, sections, and integrations. Check `deno.json`:
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"imports": {
|
|
172
|
+
"apps/": "https://cdn.jsdelivr.net/gh/deco-cx/apps@...",
|
|
173
|
+
// or forked
|
|
174
|
+
"apps/": "https://cdn.jsdelivr.net/gh/OrgName/deco-apps@..."
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Common apps:
|
|
180
|
+
- `apps/vtex/` - VTEX integration
|
|
181
|
+
- `apps/shopify/` - Shopify integration
|
|
182
|
+
- `apps/wake/` - Wake integration
|
|
183
|
+
- `apps/website/` - Core website features
|
|
184
|
+
- `apps/analytics/` - Analytics
|
|
185
|
+
|
|
186
|
+
## Custom Code Analysis
|
|
187
|
+
|
|
188
|
+
### Custom Sections
|
|
189
|
+
```
|
|
190
|
+
sections/
|
|
191
|
+
├── Header/
|
|
192
|
+
│ └── Header.tsx # Custom header
|
|
193
|
+
├── Product/
|
|
194
|
+
│ ├── ProductShelf.tsx
|
|
195
|
+
│ └── ProductCard.tsx
|
|
196
|
+
└── Footer/
|
|
197
|
+
└── Footer.tsx
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Custom Loaders
|
|
201
|
+
```
|
|
202
|
+
loaders/
|
|
203
|
+
├── search/
|
|
204
|
+
│ └── intelligenseSearch.ts # Custom search
|
|
205
|
+
├── product/
|
|
206
|
+
│ └── productDetails.ts
|
|
207
|
+
└── getUserGeolocation.ts
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Custom Actions
|
|
211
|
+
```
|
|
212
|
+
actions/
|
|
213
|
+
├── cart/
|
|
214
|
+
│ └── addToCart.ts
|
|
215
|
+
└── newsletter/
|
|
216
|
+
└── subscribe.ts
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## AGENTS.md Template
|
|
220
|
+
|
|
221
|
+
```markdown
|
|
222
|
+
# AGENTS.md - [Site Name]
|
|
223
|
+
|
|
224
|
+
## Quick Reference
|
|
225
|
+
|
|
226
|
+
| Item | Value |
|
|
227
|
+
|------|-------|
|
|
228
|
+
| Framework | Deco + Fresh |
|
|
229
|
+
| Deco Version | @deco/deco@1.x.x |
|
|
230
|
+
| Platform | VTEX / Shopify / Wake |
|
|
231
|
+
| Apps Version | apps@commit-hash |
|
|
232
|
+
|
|
233
|
+
## How to Run
|
|
234
|
+
|
|
235
|
+
\`\`\`bash
|
|
236
|
+
deno task dev
|
|
237
|
+
# or
|
|
238
|
+
deno task start
|
|
239
|
+
\`\`\`
|
|
240
|
+
|
|
241
|
+
## Architecture
|
|
242
|
+
|
|
243
|
+
### Stack
|
|
244
|
+
- **Framework**: Deco with Fresh (SSR + Islands)
|
|
245
|
+
- **Platform**: VTEX IO
|
|
246
|
+
- **CDN**: Deco Edge
|
|
247
|
+
|
|
248
|
+
### Key Pages
|
|
249
|
+
| Page | Block | Route | Custom? |
|
|
250
|
+
|------|-------|-------|---------|
|
|
251
|
+
| Home | pages-Home-123 | `/` | Yes |
|
|
252
|
+
| PDP | pages-PDP-456 | `/:slug/p` | Yes |
|
|
253
|
+
| PLP | pages-PLP-789 | `/category-slug` | Yes |
|
|
254
|
+
| Search | pages-Search-101 | `/s` | Yes |
|
|
255
|
+
|
|
256
|
+
### Navigation Flow
|
|
257
|
+
|
|
258
|
+
\`\`\`
|
|
259
|
+
Home (/)
|
|
260
|
+
├── Search (/s) ───────────────────┐
|
|
261
|
+
├── Category (PLP) ────────────────┤
|
|
262
|
+
│ └── Subcategory ─────────────┤
|
|
263
|
+
└── Product Cards ────────────────→┴─→ PDP (/:slug/p)
|
|
264
|
+
├── Add to Cart → Minicart
|
|
265
|
+
└── Buy Now → Checkout
|
|
266
|
+
\`\`\`
|
|
267
|
+
|
|
268
|
+
### Lazy Loading Map
|
|
269
|
+
|
|
270
|
+
Which sections are lazy-loaded on each key page:
|
|
271
|
+
|
|
272
|
+
| Page | Lazy Sections | Above Fold |
|
|
273
|
+
|------|---------------|------------|
|
|
274
|
+
| Home | ProductShelf, InstagramPosts, FAQ | HeroBanner, Carousel |
|
|
275
|
+
| PDP | Reviews, BuyTogether, SimilarProducts | ProductInfo, Gallery |
|
|
276
|
+
| PLP | ProductShelf (pagination) | Header, Filters |
|
|
277
|
+
|
|
278
|
+
### Caching Inventory
|
|
279
|
+
|
|
280
|
+
| Loader | Cache | TTL | Notes |
|
|
281
|
+
|--------|-------|-----|-------|
|
|
282
|
+
| `loaders/search/intelligenseSearch.ts` | ❌ None | - | Should add SWR |
|
|
283
|
+
| `loaders/product/buyTogether.ts` | ✅ SWR | 5min | Good |
|
|
284
|
+
| `loaders/getUserGeolocation.ts` | ❌ None | - | Should cache per session |
|
|
285
|
+
| `vtex/loaders/categories/tree.ts` | ❌ None | - | High volume, needs cache |
|
|
286
|
+
|
|
287
|
+
### Custom Code
|
|
288
|
+
| Type | Count | Examples |
|
|
289
|
+
|------|-------|----------|
|
|
290
|
+
| Sections | 15 | ProductShelf, CustomHeader |
|
|
291
|
+
| Loaders | 8 | intelligenseSearch |
|
|
292
|
+
| Actions | 3 | addToCart |
|
|
293
|
+
|
|
294
|
+
## Critical User Journeys
|
|
295
|
+
|
|
296
|
+
### 1. Browse & Purchase
|
|
297
|
+
\`\`\`
|
|
298
|
+
Home → Search/Category → PDP → Add to Cart → Checkout
|
|
299
|
+
\`\`\`
|
|
300
|
+
|
|
301
|
+
### 2. Direct Search
|
|
302
|
+
\`\`\`
|
|
303
|
+
Home → Searchbar → Search Results → PDP → Add to Cart
|
|
304
|
+
\`\`\`
|
|
305
|
+
|
|
306
|
+
### 3. Account Access
|
|
307
|
+
\`\`\`
|
|
308
|
+
Any Page → Login → Account Dashboard → Orders/Wishlist
|
|
309
|
+
\`\`\`
|
|
310
|
+
|
|
311
|
+
## Debugging Tips
|
|
312
|
+
|
|
313
|
+
### Common Issues
|
|
314
|
+
|
|
315
|
+
| Issue | How to Debug |
|
|
316
|
+
|-------|--------------|
|
|
317
|
+
| Section not rendering | Check `.deco/blocks/pages-*.json` for `__resolveType` |
|
|
318
|
+
| Loader returning empty | Add `console.log` in loader, check browser devtools |
|
|
319
|
+
| Slow page load | Check lazy sections with `?__d` debug flag |
|
|
320
|
+
| Cache not working | Verify `export const cache` in loader file |
|
|
321
|
+
| VTEX errors | Check VTEX account in `.deco/blocks/vtex.json` |
|
|
322
|
+
|
|
323
|
+
### Useful Debug Commands
|
|
324
|
+
|
|
325
|
+
\`\`\`bash
|
|
326
|
+
# Check which loaders are called on a page
|
|
327
|
+
curl -sI "https://site.com/page?__d" | grep server-timing
|
|
328
|
+
|
|
329
|
+
# Find sections with a specific loader
|
|
330
|
+
grep -r "loaderName" .deco/blocks/
|
|
331
|
+
|
|
332
|
+
# Check for missing cache headers
|
|
333
|
+
grep -L "export const cache" loaders/**/*.ts
|
|
334
|
+
\`\`\`
|
|
335
|
+
|
|
336
|
+
### Performance Flags
|
|
337
|
+
|
|
338
|
+
- `?__d` - Shows server timing with loader breakdown
|
|
339
|
+
- `?__d=verbose` - Extended debug info
|
|
340
|
+
- Check `/deco/render` calls in Network tab for lazy sections
|
|
341
|
+
|
|
342
|
+
## Block Health
|
|
343
|
+
|
|
344
|
+
Run `deno task validate-blocks -report validation-report.json` to check for configuration issues.
|
|
345
|
+
|
|
346
|
+
| Status | Count |
|
|
347
|
+
|--------|-------|
|
|
348
|
+
| ✅ Valid | 85 |
|
|
349
|
+
| ⚠️ Warnings | 3 |
|
|
350
|
+
| ⚠️ Unused | 14 |
|
|
351
|
+
| ❌ Errors | 8 |
|
|
352
|
+
|
|
353
|
+
### Sections with Errors
|
|
354
|
+
- `sections/Product/NotFound.tsx` (7 errors) - missing required props
|
|
355
|
+
- `loaders/SAP/createCase.ts` (9 errors) - type mismatches
|
|
356
|
+
|
|
357
|
+
### Unused Files (candidates for removal)
|
|
358
|
+
- `sections/Product/Wishlist.tsx`
|
|
359
|
+
- `sections/Social/InstagramPosts.tsx`
|
|
360
|
+
- `loaders/legacy/oldProductLoader.ts`
|
|
361
|
+
|
|
362
|
+
## Code Owners
|
|
363
|
+
|
|
364
|
+
| Contributor | Commits |
|
|
365
|
+
|-------------|---------|
|
|
366
|
+
| dev1@co.com | 150 |
|
|
367
|
+
| dev2@co.com | 89 |
|
|
368
|
+
|
|
369
|
+
## Important Files
|
|
370
|
+
|
|
371
|
+
- `deno.json` - Dependencies and tasks
|
|
372
|
+
- `.deco/blocks/` - Page configurations
|
|
373
|
+
- `sections/` - Custom UI components
|
|
374
|
+
- `loaders/` - Custom data loading
|
|
375
|
+
|
|
376
|
+
## Common Tasks
|
|
377
|
+
|
|
378
|
+
### Add a new section
|
|
379
|
+
1. Create file in `sections/YourSection.tsx`
|
|
380
|
+
2. Export default component with Props interface
|
|
381
|
+
3. Add to page via Admin or `.deco/blocks/`
|
|
382
|
+
|
|
383
|
+
### Modify a page
|
|
384
|
+
1. Find the page block in `.deco/blocks/pages-*.json`
|
|
385
|
+
2. Edit sections array
|
|
386
|
+
3. Or use the Deco Admin UI
|
|
387
|
+
|
|
388
|
+
### Add caching to a loader
|
|
389
|
+
\`\`\`typescript
|
|
390
|
+
// loaders/myLoader.ts
|
|
391
|
+
export const cache = "stale-while-revalidate";
|
|
392
|
+
export const cacheKey = (props: Props) => \`\${props.key}\`;
|
|
393
|
+
\`\`\`
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## Example Output
|
|
397
|
+
|
|
398
|
+
When you run this skill on an e-commerce site, you'll discover:
|
|
399
|
+
|
|
400
|
+
- Using Deco + Fresh stack
|
|
401
|
+
- Platform integration (VTEX, Shopify, etc.)
|
|
402
|
+
- Custom intelligent search loader
|
|
403
|
+
- Forked or custom deco-apps
|
|
404
|
+
- 50+ custom sections
|
|
405
|
+
- Key pages: Home, PDP, PLP, Search, Checkout
|
|
406
|
+
- Top contributors and their commit counts
|
|
407
|
+
|
|
408
|
+
## Block Validation (validate-blocks)
|
|
409
|
+
|
|
410
|
+
Run block validation to ensure JSON configurations match TypeScript Props.
|
|
411
|
+
|
|
412
|
+
### How to Run
|
|
413
|
+
|
|
414
|
+
**Run directly from any deco site directory (no installation needed):**
|
|
415
|
+
```bash
|
|
416
|
+
# Validate all sections, loaders, and actions
|
|
417
|
+
deno run -A https://deco.cx/validate
|
|
418
|
+
|
|
419
|
+
# Generate a JSON report for analysis
|
|
420
|
+
deno run -A https://deco.cx/validate -report validation-report.json
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
**Optional: Add as a deno task for convenience:**
|
|
424
|
+
|
|
425
|
+
Add to your site's `deno.json`:
|
|
426
|
+
```json
|
|
427
|
+
{
|
|
428
|
+
"tasks": {
|
|
429
|
+
"validate-blocks": "deno run -A https://deco.cx/validate"
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Then run:
|
|
435
|
+
```bash
|
|
436
|
+
deno task validate-blocks -report validation-report.json
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### What It Validates
|
|
440
|
+
|
|
441
|
+
1. **Type Matching** - JSON values match Props interface types
|
|
442
|
+
2. **Required Properties** - All required props are present
|
|
443
|
+
3. **Unused Files** - Sections, loaders, and actions not referenced in any block
|
|
444
|
+
4. **Extra Properties** - Properties in JSON not defined in types (with `-unused` flag)
|
|
445
|
+
5. **Anti-Patterns** - Dead code and structural issues (see Anti-Patterns section below)
|
|
446
|
+
|
|
447
|
+
### Unused Detection
|
|
448
|
+
|
|
449
|
+
| Type | Detection | Auto-Removal |
|
|
450
|
+
|------|-----------|--------------|
|
|
451
|
+
| **Unused Sections** | ✅ Detected | ✅ With `-rm-sections` |
|
|
452
|
+
| **Unused Loaders** | ✅ Detected | ❌ Manual only* |
|
|
453
|
+
| **Unused Actions** | ✅ Detected | ❌ Manual only* |
|
|
454
|
+
| **Unused Properties** | ✅ With `-unused` | ✅ With `-rm-vars` |
|
|
455
|
+
|
|
456
|
+
*Loaders and actions are not auto-removed because they may be imported dynamically.
|
|
457
|
+
|
|
458
|
+
### Sample Output
|
|
459
|
+
|
|
460
|
+
```
|
|
461
|
+
🔍 Validating sections, loaders, and actions...
|
|
462
|
+
|
|
463
|
+
✅ sections/Header/Header.tsx - 15 occurrence(s)
|
|
464
|
+
⚠️ sections/Footer/Footer.tsx - 1 occurrence(s), 2 warning(s)
|
|
465
|
+
❌ sections/Category/CategoryGrid.tsx - 1 error(s)
|
|
466
|
+
- "items": required property missing
|
|
467
|
+
|
|
468
|
+
═══════════════════════════════════════
|
|
469
|
+
📊 SUMMARY
|
|
470
|
+
═══════════════════════════════════════
|
|
471
|
+
Total sections/loaders/actions: 95
|
|
472
|
+
Total occurrences: 284
|
|
473
|
+
✅ No issues: 85
|
|
474
|
+
⚠️ With warnings: 3
|
|
475
|
+
⚠️ Unused: 3
|
|
476
|
+
❌ With errors: 4
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### JSON Report (`-report` flag)
|
|
480
|
+
|
|
481
|
+
Generate a structured JSON report for automated analysis:
|
|
482
|
+
|
|
483
|
+
```bash
|
|
484
|
+
deno run -A https://deco.cx/validate -report validation-report.json
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
The report includes:
|
|
488
|
+
- `summary`: Total counts (sections, errors, warnings, unused)
|
|
489
|
+
- `sectionsWithErrors`: Detailed error list with file, line, property, message
|
|
490
|
+
- `sectionsWithWarnings`: Detailed warning list
|
|
491
|
+
- `unusedSections`: List of unreferenced files
|
|
492
|
+
|
|
493
|
+
Use the report to:
|
|
494
|
+
1. Track validation status over time
|
|
495
|
+
2. Integrate with CI/CD pipelines
|
|
496
|
+
3. Generate AGENTS.md Block Health sections automatically
|
|
497
|
+
|
|
498
|
+
### Diagnostics MD Report
|
|
499
|
+
|
|
500
|
+
After running block validation with `-report`, generate a human-readable diagnostics file:
|
|
501
|
+
|
|
502
|
+
```bash
|
|
503
|
+
# 1. Run validation and save JSON report
|
|
504
|
+
deno run -A https://deco.cx/validate -report validation-report.json
|
|
505
|
+
|
|
506
|
+
# 2. Generate BLOCKS_DIAGNOSTICS.md from the JSON report
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
The diagnostics MD should include:
|
|
510
|
+
- **Summary table** - Total files, valid, errors, warnings, unused counts
|
|
511
|
+
- **Critical issues** - Top errors grouped by root cause
|
|
512
|
+
- **Sections with errors** - Table of files with error counts
|
|
513
|
+
- **Loader/action errors** - Separate section for non-section files
|
|
514
|
+
- **Warnings** - Props interface issues
|
|
515
|
+
- **Unused code inventory** - Sections, loaders, actions not referenced
|
|
516
|
+
- **Recommendations** - Prioritized fix suggestions
|
|
517
|
+
- **How to re-run** - Commands to regenerate the report
|
|
518
|
+
|
|
519
|
+
#### BLOCKS_DIAGNOSTICS.md Template
|
|
520
|
+
|
|
521
|
+
```markdown
|
|
522
|
+
# Block Validation Diagnostics - [Site Name]
|
|
523
|
+
|
|
524
|
+
**Generated:** [Date]
|
|
525
|
+
**Tool:** validate-blocks v1.1.0
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## Summary
|
|
530
|
+
|
|
531
|
+
| Metric | Count |
|
|
532
|
+
|--------|-------|
|
|
533
|
+
| **Total files analyzed** | X |
|
|
534
|
+
| **Total block occurrences** | X |
|
|
535
|
+
| **Valid (no issues)** | X (X%) |
|
|
536
|
+
| **With warnings** | X (X%) |
|
|
537
|
+
| **Unused files** | X (X%) |
|
|
538
|
+
| **With errors** | X (X%) |
|
|
539
|
+
| **Total errors** | X |
|
|
540
|
+
|
|
541
|
+
---
|
|
542
|
+
|
|
543
|
+
## Critical Issues
|
|
544
|
+
|
|
545
|
+
### 1. [Root Cause Name] (X errors)
|
|
546
|
+
|
|
547
|
+
**File:** `sections/Example/Example.tsx`
|
|
548
|
+
**Impact:** HIGH/MEDIUM/LOW - Affects X pages
|
|
549
|
+
|
|
550
|
+
[Description of the issue and root cause]
|
|
551
|
+
|
|
552
|
+
**Affected Pages (sample):**
|
|
553
|
+
- page1.json
|
|
554
|
+
- page2.json
|
|
555
|
+
|
|
556
|
+
**Fix Required:** [Specific instructions]
|
|
557
|
+
|
|
558
|
+
---
|
|
559
|
+
|
|
560
|
+
## Sections with Schema Errors
|
|
561
|
+
|
|
562
|
+
| Section | Errors | Issue |
|
|
563
|
+
|---------|--------|-------|
|
|
564
|
+
| `sections/Example.tsx` | X | Missing required prop |
|
|
565
|
+
|
|
566
|
+
---
|
|
567
|
+
|
|
568
|
+
## Unused Code (X files)
|
|
569
|
+
|
|
570
|
+
### Unused Sections (X files)
|
|
571
|
+
|
|
572
|
+
| Section | Notes |
|
|
573
|
+
|---------|-------|
|
|
574
|
+
| `sections/Unused.tsx` | Consider removal |
|
|
575
|
+
|
|
576
|
+
### Unused Loaders (X files)
|
|
577
|
+
|
|
578
|
+
| Loader | Notes |
|
|
579
|
+
|--------|-------|
|
|
580
|
+
| `loaders/unused.ts` | May be called dynamically |
|
|
581
|
+
|
|
582
|
+
---
|
|
583
|
+
|
|
584
|
+
## Recommendations
|
|
585
|
+
|
|
586
|
+
### Priority 1 - [Issue Name] (HIGH)
|
|
587
|
+
[Specific fix instructions]
|
|
588
|
+
|
|
589
|
+
### Priority 2 - [Issue Name] (MEDIUM)
|
|
590
|
+
[Specific fix instructions]
|
|
591
|
+
|
|
592
|
+
---
|
|
593
|
+
|
|
594
|
+
## How to Re-run Validation
|
|
595
|
+
|
|
596
|
+
\`\`\`bash
|
|
597
|
+
deno run -A https://deco.cx/validate -report validation-report.json
|
|
598
|
+
\`\`\`
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
#### Task: Generate Diagnostics MD
|
|
602
|
+
|
|
603
|
+
When analyzing a site, always generate both files:
|
|
604
|
+
|
|
605
|
+
1. **validation-report.json** - For programmatic use
|
|
606
|
+
2. **BLOCKS_DIAGNOSTICS.md** - For human review
|
|
607
|
+
|
|
608
|
+
The diagnostics MD makes it easier to:
|
|
609
|
+
- Share findings with the team
|
|
610
|
+
- Track issues in PRs/tickets
|
|
611
|
+
- Reference specific errors without parsing JSON
|
|
612
|
+
- Prioritize fixes by impact
|
|
613
|
+
|
|
614
|
+
### Cleanup Options
|
|
615
|
+
|
|
616
|
+
```bash
|
|
617
|
+
# Remove properties not in Props interface
|
|
618
|
+
deno task validate-blocks -rm-vars
|
|
619
|
+
|
|
620
|
+
# Remove unused section files (with confirmation - type 'yes')
|
|
621
|
+
deno task validate-blocks -rm-sections
|
|
622
|
+
|
|
623
|
+
# Show warnings for extra properties
|
|
624
|
+
deno task validate-blocks -unused
|
|
625
|
+
|
|
626
|
+
# Use custom blocks directory
|
|
627
|
+
deno task validate-blocks -blocks /path/to/.deco/blocks
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
### Anti-Patterns Detection
|
|
631
|
+
|
|
632
|
+
The validator detects structural issues beyond type mismatches:
|
|
633
|
+
|
|
634
|
+
#### 1. Dead Code (`never` rule)
|
|
635
|
+
Sections with `website/matchers/never.ts` rule will never execute:
|
|
636
|
+
|
|
637
|
+
```json
|
|
638
|
+
{
|
|
639
|
+
"__resolveType": "website/flags/multivariate/section.ts",
|
|
640
|
+
"variants": [{
|
|
641
|
+
"rule": { "__resolveType": "website/matchers/never.ts" }, // 💀 DEAD CODE
|
|
642
|
+
"value": { "__resolveType": "site/sections/Product/ProductShelf.tsx" }
|
|
643
|
+
}]
|
|
644
|
+
}
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
**Impact**: Bloats page config, confuses developers, slows admin load.
|
|
648
|
+
**Fix**: Remove the entire variant or replace with `always` matcher.
|
|
649
|
+
|
|
650
|
+
#### 2. Lazy Wrapping Multivariate (Anti-Pattern)
|
|
651
|
+
Lazy should not wrap multivariate - the flag evaluation happens immediately anyway:
|
|
652
|
+
|
|
653
|
+
```json
|
|
654
|
+
{
|
|
655
|
+
"__resolveType": "website/sections/Rendering/Lazy.tsx",
|
|
656
|
+
"section": {
|
|
657
|
+
"__resolveType": "website/flags/multivariate/section.ts", // ❌ WRONG
|
|
658
|
+
"variants": [...]
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
**Why it's wrong**: Lazy defers rendering, but multivariate flags are evaluated at request time regardless. If you need lazy loading per variant, the multivariate should wrap Lazy sections:
|
|
664
|
+
|
|
665
|
+
```json
|
|
666
|
+
{
|
|
667
|
+
"__resolveType": "website/flags/multivariate/section.ts",
|
|
668
|
+
"variants": [{
|
|
669
|
+
"rule": { "__resolveType": "website/matchers/always.ts" },
|
|
670
|
+
"value": {
|
|
671
|
+
"__resolveType": "website/sections/Rendering/Lazy.tsx", // ✅ CORRECT
|
|
672
|
+
"section": { "__resolveType": "site/sections/Product/ProductShelf.tsx" }
|
|
673
|
+
}
|
|
674
|
+
}]
|
|
675
|
+
}
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
#### Sample Anti-Pattern Output
|
|
679
|
+
|
|
680
|
+
```
|
|
681
|
+
🚨 ANTI-PATTERNS DETECTED
|
|
682
|
+
|
|
683
|
+
💀 Dead Code (40 sections with 'never' rule):
|
|
684
|
+
📄 pages-Home.json: 30 dead code section(s)
|
|
685
|
+
📄 pages-BlackFriday.json: 10 dead code section(s)
|
|
686
|
+
|
|
687
|
+
⚠️ Lazy wrapping Multivariate (5 instances):
|
|
688
|
+
📄 pages-Home.json
|
|
689
|
+
Path: sections.variants[0].value[5]
|
|
690
|
+
Lazy wrapping multivariate is an anti-pattern...
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
### Common Block Corruption Patterns
|
|
694
|
+
|
|
695
|
+
#### Exploded Strings
|
|
696
|
+
Sometimes strings get corrupted into character-indexed objects:
|
|
697
|
+
|
|
698
|
+
```json
|
|
699
|
+
// ❌ Corrupted
|
|
700
|
+
{
|
|
701
|
+
"image": {
|
|
702
|
+
"0": "h", "1": "t", "2": "t", "3": "p", "4": "s",
|
|
703
|
+
"5": ":", "6": "/", "7": "/", ...
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// ✅ Should be
|
|
708
|
+
{
|
|
709
|
+
"image": "https://example.com/image.jpg"
|
|
710
|
+
}
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
**Detection**: Objects with 50+ numeric keys where values are single characters.
|
|
714
|
+
**Fix Script**: Reconstruct string from numeric keys sorted by index.
|
|
715
|
+
|
|
716
|
+
#### Arrays as Objects
|
|
717
|
+
Sometimes arrays get saved as indexed objects:
|
|
718
|
+
|
|
719
|
+
```json
|
|
720
|
+
// ❌ Corrupted
|
|
721
|
+
{
|
|
722
|
+
"items": { "0": {...}, "1": {...}, "2": {...} }
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// ✅ Should be
|
|
726
|
+
{
|
|
727
|
+
"items": [{...}, {...}, {...}]
|
|
728
|
+
}
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
### Loader-Injected Props Pattern
|
|
732
|
+
|
|
733
|
+
When a loader injects props at runtime (like `device` from `ctx.device`), use this pattern:
|
|
734
|
+
|
|
735
|
+
```typescript
|
|
736
|
+
// sections/Product/ProductShelfGroup.tsx
|
|
737
|
+
|
|
738
|
+
export interface Props {
|
|
739
|
+
shelves: ShelfConfig[];
|
|
740
|
+
/**
|
|
741
|
+
* @hide
|
|
742
|
+
*/
|
|
743
|
+
device: "mobile" | "desktop" | "tablet"; // Required with @hide
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
export function loader(props: Props, _req: Request, ctx: AppContext) {
|
|
747
|
+
return {
|
|
748
|
+
...props,
|
|
749
|
+
device: ctx.device, // Loader always provides actual device
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
**In the JSON block**, store a default value (will be overwritten by loader):
|
|
755
|
+
```json
|
|
756
|
+
{
|
|
757
|
+
"__resolveType": "site/sections/Product/ProductShelfGroup.tsx",
|
|
758
|
+
"shelves": [...],
|
|
759
|
+
"device": "mobile"
|
|
760
|
+
}
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
**Why this pattern:**
|
|
764
|
+
1. `@hide` prevents the prop from showing in admin UI
|
|
765
|
+
2. Prop is required in Props, so TypeScript is happy
|
|
766
|
+
3. JSON has a value, so deco admin validation passes
|
|
767
|
+
4. Loader overwrites with actual runtime value
|
|
768
|
+
|
|
769
|
+
**Validator divergence**: Our script validates against the `Props` interface. Deco admin may validate against `SectionProps<typeof loader>` which includes loader return types. If you see admin errors not caught by the script, check for loader-injected props.
|
|
770
|
+
|
|
771
|
+
### Nested Props with Loader-Injected Values
|
|
772
|
+
|
|
773
|
+
When a section has nested props that reference another component's Props (which includes loader-injected values like `device`), you must Omit those values:
|
|
774
|
+
|
|
775
|
+
```typescript
|
|
776
|
+
// ❌ WRONG - ProductShelfProps includes required `device`
|
|
777
|
+
export interface ProductShelfTimedOffersConfig {
|
|
778
|
+
type: "ProductShelfTimedOffers";
|
|
779
|
+
props: ProductShelfTimedOffersProps; // shelfProps.device is required!
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// ✅ CORRECT - Omit device from nested props
|
|
783
|
+
type ShelfPropsWithoutDevice = Omit<ProductShelfProps, "device">;
|
|
784
|
+
|
|
785
|
+
export interface ProductShelfTimedOffersConfig {
|
|
786
|
+
type: "ProductShelfTimedOffers";
|
|
787
|
+
props: Omit<ProductShelfTimedOffersProps, "shelfProps" | "shelfPropsOffer"> & {
|
|
788
|
+
shelfProps: ShelfPropsWithoutDevice;
|
|
789
|
+
shelfPropsOffer?: ShelfPropsWithoutDevice;
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
**Why**: The parent component injects `device` at runtime, but deco admin validates the JSON before runtime. If nested props require `device`, admin shows validation errors even though the code works.
|
|
795
|
+
|
|
796
|
+
### Add to AGENTS.md
|
|
797
|
+
|
|
798
|
+
Include block health summary:
|
|
799
|
+
|
|
800
|
+
```markdown
|
|
801
|
+
## Block Health
|
|
802
|
+
|
|
803
|
+
| Status | Count |
|
|
804
|
+
|--------|-------|
|
|
805
|
+
| ✅ Valid | 85 |
|
|
806
|
+
| ⚠️ Warnings | 3 |
|
|
807
|
+
| ⚠️ Unused | 14 |
|
|
808
|
+
| ❌ Errors | 8 |
|
|
809
|
+
|
|
810
|
+
**Files with errors**:
|
|
811
|
+
- sections/Product/NotFound.tsx (7 errors)
|
|
812
|
+
- loaders/SAP/createCase.ts (9 errors)
|
|
813
|
+
|
|
814
|
+
**Unused files** (candidates for removal):
|
|
815
|
+
- sections/Product/Wishlist.tsx
|
|
816
|
+
- sections/Social/InstagramPosts.tsx
|
|
817
|
+
- actions/legacy/oldAction.ts
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
## Optimization Checklists
|
|
821
|
+
|
|
822
|
+
Based on 105 learnings from real Deco sites, run these checklists during analysis:
|
|
823
|
+
|
|
824
|
+
### Available Checklists
|
|
825
|
+
|
|
826
|
+
| Checklist | Items | Key Focus |
|
|
827
|
+
|-----------|-------|-----------|
|
|
828
|
+
| [loader-optimization.md](checklists/loader-optimization.md) | 33 | Lazy sections, VTEX simulation, deduplication |
|
|
829
|
+
| [image-optimization.md](checklists/image-optimization.md) | 18 | LCP, eager/lazy loading, responsive images |
|
|
830
|
+
| [cache-strategy.md](checklists/cache-strategy.md) | 7 | SWR, cache keys, rate limiting |
|
|
831
|
+
| [seo-fix.md](checklists/seo-fix.md) | 10 | JSON-LD, meta tags, canonicals |
|
|
832
|
+
| [hydration-fix.md](checklists/hydration-fix.md) | 9 | SDK race conditions, SSR/client mismatch |
|
|
833
|
+
| [asset-optimization.md](checklists/asset-optimization.md) | 17 | Third-party scripts, lazy loading, CSP |
|
|
834
|
+
| [bug-fix.md](checklists/bug-fix.md) | 8 | Defensive coding, content sanitization |
|
|
835
|
+
| [dependency-update.md](checklists/dependency-update.md) | 3 | Version alignment, Deco 2.0 |
|
|
836
|
+
| [site-cleanup.md](checklists/site-cleanup.md) | 9 | Platform files, dead code, type fixes |
|
|
837
|
+
|
|
838
|
+
### Top Patterns to Check
|
|
839
|
+
|
|
840
|
+
**Loader Optimization** (most common):
|
|
841
|
+
- [ ] Heavy sections wrapped in Lazy (BuyTogether, Reviews, Shelves)
|
|
842
|
+
- [ ] VTEX simulation set to `skip` or `only1P`
|
|
843
|
+
- [ ] No sync product loaders in Header
|
|
844
|
+
- [ ] AbortController timeout on external APIs
|
|
845
|
+
|
|
846
|
+
**Image Optimization**:
|
|
847
|
+
- [ ] LCP image has `loading="eager"` and `fetchPriority="high"`
|
|
848
|
+
- [ ] First 4-6 PLP products are eager loaded
|
|
849
|
+
- [ ] All images use Deco `<Image />` component
|
|
850
|
+
- [ ] SVGs bypass optimization proxy
|
|
851
|
+
|
|
852
|
+
**Cache Strategy**:
|
|
853
|
+
- [ ] Custom loaders have `export const cache = "stale-while-revalidate"`
|
|
854
|
+
- [ ] Cache keys are deterministic (no URL params, sorted arrays)
|
|
855
|
+
- [ ] Common loaders use shared blocks for deduplication
|
|
856
|
+
|
|
857
|
+
**SEO**:
|
|
858
|
+
- [ ] JSON-LD escapes `<` character
|
|
859
|
+
- [ ] Every page has SEO section
|
|
860
|
+
- [ ] Prices have exactly 2 decimal places
|
|
861
|
+
|
|
862
|
+
**Hydration**:
|
|
863
|
+
- [ ] No direct `window`/`document` access without `IS_BROWSER` check
|
|
864
|
+
- [ ] External widgets wait for load via callback
|
|
865
|
+
- [ ] No `Math.random()` for ID generation
|
|
866
|
+
|
|
867
|
+
### How to Use Checklists
|
|
868
|
+
|
|
869
|
+
1. **During analysis**: Reference relevant checklists when examining code
|
|
870
|
+
2. **In AGENTS.md**: Include findings table showing pass/fail for each area
|
|
871
|
+
3. **For recommendations**: Use checklist items as specific action items
|
|
872
|
+
|
|
873
|
+
### Example Findings Table (add to AGENTS.md)
|
|
874
|
+
|
|
875
|
+
```markdown
|
|
876
|
+
## Optimization Audit
|
|
877
|
+
|
|
878
|
+
| Category | Status | Key Findings |
|
|
879
|
+
|----------|--------|--------------|
|
|
880
|
+
| Loader Optimization | 🟡 | 3 sections need Lazy wrapping |
|
|
881
|
+
| Image Optimization | 🔴 | LCP banner missing fetchPriority |
|
|
882
|
+
| Cache Strategy | 🔴 | 5 loaders missing cache config |
|
|
883
|
+
| SEO | 🟢 | All pages have SEO section |
|
|
884
|
+
| Hydration | 🟢 | No SSR/client mismatches found |
|
|
885
|
+
| Asset Optimization | 🟡 | Chat widget loads on all pages |
|
|
886
|
+
| Bug Fixes | 🟢 | No critical issues |
|
|
887
|
+
| Dependencies | 🟡 | Consider updating to latest apps |
|
|
888
|
+
```
|
|
889
|
+
|
|
890
|
+
## Next Steps After Generating AGENTS.md
|
|
891
|
+
|
|
892
|
+
1. Review the generated AGENTS.md
|
|
893
|
+
2. **Run block validation** to generate `validation-report.json`
|
|
894
|
+
3. **Generate BLOCKS_DIAGNOSTICS.md** from the validation report
|
|
895
|
+
4. **Run through optimization checklists** for each category
|
|
896
|
+
5. Check if README.md needs updates
|
|
897
|
+
6. Identify areas that need documentation
|
|
898
|
+
7. Use the performance-audit skill for runtime analysis
|