Skip to main content

Overview

When validation detects issues in generated code, Synapse’s self-correction system automatically attempts to fix them without manual intervention.

The Self-Correction Loop

1

Initial Generation

GPT-5 Mini generates code based on your prompt
2

Validation

MCP validator checks the code and returns a score with specific issues
3

Correction Decision

If score is below 90, self-correction is triggered
4

Fix Generation

AI analyzes the issues and generates corrected code
5

Re-validation

Corrected code is validated again
6

Success or Retry

Process repeats up to 3 times until score ≥ 90 or attempts exhausted

Success Rates

Common Corrections

Import Path Fixes

GraphQL Query Corrections

Hook Usage Fixes

How It Works

1. Issue Analysis

When validation fails, Synapse extracts specific issues:

2. Correction Prompt

Synapse creates a targeted correction prompt:

3. Intelligent Fixing

The AI understands context and makes precise fixes:
Recognizes common Shopify patterns and applies standard fixes
  • Import paths: Adds /checkout, /admin, /pos as appropriate
  • GraphQL: Uses Shopify’s schema to find correct field paths
  • Hooks: Moves to top level and restructures conditionals
  • Props: Matches TypeScript definitions
Maintains the original intent and structure
  • Keeps variable names
  • Preserves logic flow
  • Maintains comments
  • Retains error handling
Fixes multiple issues simultaneously
  • Prioritizes critical errors
  • Groups related fixes
  • Avoids creating new issues
  • Validates dependencies between fixes

Example Self-Correction Session

Original Generation

Validation Score: 62/100 Issues Found:
  • Import path missing /checkout
  • cart.totalPrice doesn’t exist
  • status prop should be tone

After Attempt 1

Validation Score: 95/100 Result: ✅ Success! Code ready to deploy.

When Self-Correction Fails

If self-correction doesn’t reach a score of 90 after 3 attempts:
  1. User Notification: You’re informed of the persistent issues
  2. Partial Deployment: Code can still be deployed if score ≥ 75
  3. Manual Review: Recommended for scores < 75
  4. Support Escalation: Complex issues are flagged for team review

Manual Intervention

You can always view and edit the generated code:

Configuration

You can adjust self-correction behavior:

Best Practices

Write Clear Prompts

Specific prompts lead to better initial code and fewer corrections

Review Corrections

Check what was changed to learn and improve future prompts

Report Patterns

If the same issue repeats, let us know to improve the system

Use Validation

Always validate before deploying, even with high scores

Limitations

Self-correction cannot fix:
  • Fundamental logic errors (wrong business rules)
  • Missing required features
  • Performance issues
  • Security vulnerabilities beyond basic validation
These require prompt revision or manual coding.

Next Steps

Validation Details

Learn what triggers self-correction

Debugging Guide

Fix issues manually when needed

Best Practices

Write prompts that generate better code

Troubleshooting

Common issues and solutions