Skip to content

Commit ea796dd

Browse files
[prompts] Make validation automatic instead of optional
Changes all style-creation prompts to automatically validate instead of asking the user. Validation is fast (offline only), catches issues early, and provides immediate feedback without friction. Rationale: - All validation tools are offline (no API calls, no cost) - Fast execution (milliseconds) - Follows development tool patterns (ESLint, TypeScript, tests) - Results are informational - users can ignore warnings for prototypes - Better to show issues immediately than discover them later Updated prompts: - create-and-preview-style: Step 5 now validates automatically - build-custom-map: Step 5 now validates automatically - design-data-driven-style: Step 8 now validates automatically - setup-mapbox-project: Validates before presenting final summary Changes: - Removed user question "Would you like to validate?" - Added automatic validation step after style creation - Validation results included in final summary - Note added that warnings can be ignored for prototypes Benefits: - Catches expression errors before runtime - Ensures WCAG accessibility compliance by default - Identifies optimization opportunities immediately - Especially valuable for AI-generated styles (build-custom-map) - Data-driven styles get complex expression validation Example flow: 1. Create style ✓ 2. Generate preview ✓ 3. Automatically validate ✓ (new - runs without asking) 4. Present: Preview URL + Validation report Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent 5101407 commit ea796dd

File tree

4 files changed

+74
-48
lines changed

4 files changed

+74
-48
lines changed

src/prompts/BuildCustomMapPrompt.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,27 @@ Follow these steps to create and preview the styled map:
8989
instructionText += `\n - Set zoom level to: ${previewZoom}
9090
- The preview will use an existing public token automatically
9191
92-
5. **Present results**
92+
5. **Validate the style**
93+
- Automatically run validation using the prepare-style-for-production prompt
94+
- Pass the style ID from step 3 as the style_id_or_json parameter
95+
- This checks:
96+
* Expression syntax (especially important for AI-generated styles)
97+
* Color contrast for accessibility (WCAG AA)
98+
* Style optimization opportunities
99+
- Validation is fast (offline processing only)
100+
101+
6. **Present complete results**
93102
- Show the user:
94103
* A summary of the theme and customizations applied
95104
* The style ID for future reference
96105
* The preview URL to view the map
106+
* Validation results summary:
107+
- ✅ Issues found or "Style is production-ready"
108+
- Expression validation status (critical for generated styles)
109+
- Accessibility compliance (WCAG AA)
110+
- Optimization recommendations
97111
* Suggestions for further customization if desired
98-
99-
6. **Validate the style (recommended for production)**
100-
- After presenting the preview, ask the user:
101-
* "Would you like to validate this style for production readiness? This will check expressions, accessibility, and optimize the style."
102-
- If yes:
103-
* Use the prepare-style-for-production prompt
104-
* Pass the style ID from step 3 as the style_id_or_json parameter
105-
- If no:
106-
* Note: "You can validate later by running the prepare-style-for-production prompt when needed"
107-
- For experimental or demo maps, validation can be skipped
112+
- Note: Validation warnings can be ignored for experimental maps
108113
109114
**Theme interpretation tips:**
110115
- "Dark cyberpunk": Dark backgrounds, neon colors (cyan, magenta, purple), high contrast
@@ -118,10 +123,11 @@ Follow these steps to create and preview the styled map:
118123

119124
instructionText += `\n\n**Important notes:**
120125
- The style_builder_tool is powered by AI and may need refinement
126+
- Validation runs automatically to catch any issues in generated expressions
121127
- You can iterate on the style by making additional calls to style_builder_tool
122128
- If the initial result doesn't match expectations, try refining the theme description
123129
- Consider the map's use case when choosing zoom levels and preview locations
124-
- For production deployment, always validate styles to ensure quality and accessibility`;
130+
- For experimental maps, validation warnings can be addressed later`;
125131

126132
return [
127133
{

src/prompts/CreateAndPreviewStylePrompt.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,33 @@ Follow these steps carefully:
112112
instructionText += `\n - Set zoom level to: ${previewZoom}
113113
- The tool will automatically use the public token you created/found earlier
114114
115-
5. **Present results**
115+
5. **Validate the style**
116+
- Automatically run validation using the prepare-style-for-production prompt
117+
- Pass the style ID from step 3 as the style_id_or_json parameter
118+
- This checks:
119+
* Expression syntax and correctness
120+
* Color contrast for accessibility (WCAG AA)
121+
* Style optimization opportunities
122+
- Validation is fast (offline processing only)
123+
124+
6. **Present complete results**
116125
- Show the user:
117126
* The created style ID
118127
* The preview URL (they can click to open in browser)
128+
* Validation results summary:
129+
- ✅ Issues found or "Style is production-ready"
130+
- Expression validation status
131+
- Accessibility compliance (WCAG AA)
132+
- Optimization recommendations
119133
* Instructions to share or embed the preview
120-
121-
6. **Validate the style (recommended for production)**
122-
- After presenting the preview, ask the user:
123-
* "Would you like to validate this style for production readiness? This will check expressions, accessibility, and optimize the style."
124-
- If yes:
125-
* Use the prepare-style-for-production prompt
126-
* Pass the style ID from step 3 as the style_id_or_json parameter
127-
- If no:
128-
* Note: "You can validate later by running the prepare-style-for-production prompt when needed"
129-
- For quick prototypes or demos, validation can be skipped
134+
- Note: Validation warnings can be ignored for quick prototypes
130135
131136
**Important notes:**
132137
- The preview_style_tool will automatically fetch and use an available public token
133138
- Make sure the style is created successfully before generating the preview
139+
- Validation runs automatically to catch issues early (offline, fast)
134140
- If any step fails, provide clear error messages and suggest fixes
135-
- For production deployment, always validate styles to catch issues early`;
141+
- For quick prototypes, validation warnings can be addressed later`;
136142

137143
return [
138144
{

src/prompts/DesignDataDrivenStylePrompt.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -395,31 +395,32 @@ Show property values as labels:
395395
- Use red/green combinations (colorblind-unfriendly)
396396
- Forget to handle null/undefined property values
397397
398-
## Step 8: Validate the Style (Recommended for Production)
398+
## Step 8: Validate the Style
399399
400-
After creating your data-driven style:
400+
After creating your data-driven style, automatically run validation:
401401
402-
1. **Ask the user about validation:**
403-
- "Would you like to validate this data-driven style for production readiness? This will check expression syntax, accessibility, and optimize the style."
404-
- Data-driven styles use complex expressions that benefit from validation
405-
406-
2. **If yes, validate:**
402+
1. **Run validation:**
407403
- Use the prepare-style-for-production prompt
408404
- Pass the style ID as the style_id_or_json parameter
405+
- Data-driven styles use complex expressions that benefit from validation
409406
- This checks:
410407
* Expression syntax and type correctness
411-
* Color contrast for accessibility (WCAG AA/AAA)
408+
* Color contrast for accessibility (WCAG AA)
412409
* Overall style optimization
410+
- Validation is fast (offline processing only)
411+
412+
2. **Present validation results:**
413+
- Include validation summary with the preview:
414+
* ✅ Issues found or "Style is production-ready"
415+
* Expression validation status (critical for data-driven styles)
416+
* Accessibility compliance (WCAG AA)
417+
* Optimization recommendations
413418
- This ensures your expressions work correctly with real data
414419
415-
3. **If no:**
416-
- Note: "You can validate later using prepare-style-for-production when ready for production"
417-
418-
4. **When validation is especially important:**
419-
- ✅ Production maps with real user data
420-
- ✅ Styles with complex nested expressions
421-
- ✅ Maps requiring accessibility compliance
422-
- ⚠️ Quick prototypes can skip validation initially
420+
3. **Note for users:**
421+
- Validation runs automatically to catch issues early
422+
- For quick prototypes, warnings can be addressed later
423+
- Complex nested expressions especially benefit from validation
423424
424425
## Step 9: Documentation
425426

src/prompts/SetupMapboxProjectPrompt.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,27 @@ Type: ${projectType}
254254

255255
instructionText += `
256256
257-
📋 **Optional: Validate the Style for Production**
258-
259-
Before deploying to production, consider validating the created style:
260-
- Ask the user: "Would you like to validate this style for production readiness? This will check expressions, accessibility, and optimize the style."
261-
- If yes, use the prepare-style-for-production prompt with the style ID created above
262-
- If no, note that validation is recommended before production deployment
263-
264-
The setup is now complete! The user can start building their map application.`;
257+
📋 **Validate the Style**
258+
259+
Automatically validate the created style:
260+
- Use the prepare-style-for-production prompt with the style ID created above
261+
- This checks:
262+
* Expression syntax and correctness
263+
* Color contrast for accessibility (WCAG AA)
264+
* Style optimization opportunities
265+
- Validation is fast (offline processing only)
266+
- Include validation results in the final summary
267+
268+
🎉 **Setup Complete!**
269+
270+
Present the complete setup summary:
271+
- All tokens created with proper security restrictions
272+
- Map style created and validated
273+
- Preview URL for testing
274+
- Validation results (any issues or "✅ Production-ready")
275+
- Next steps for integration
276+
277+
The user can now start building their map application with confidence that their setup follows best practices.`;
265278

266279
return [
267280
{

0 commit comments

Comments
 (0)