Oneshot Paradigm

The Oneshot Paradigm

The most counterintuitive truth in AI-assisted development: fixing forward is slower than fixing backward.

The Principle

⚠️

When something doesn't work on the first try, go back to the original prompt with error logs and context. Don't try to patch the broken output.

❌ THE SLOW WAY (Fixing Forward)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Prompt β†’ Broken Code β†’ Fix attempt β†’ More bugs β†’          β”‚
β”‚           Fix attempt β†’ Still broken β†’ Fix attempt β†’       β”‚
β”‚           Context pollution β†’ Start over anyway            β”‚
β”‚                                                             β”‚
β”‚  Time: 45 minutes                                          β”‚
β”‚  Result: Frustrated, context polluted, same problem        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

βœ… THE FAST WAY (Oneshot Paradigm)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Prompt β†’ Broken Code β†’ STOP                               β”‚
β”‚                           ↓                                β”‚
β”‚  Original Prompt + Error Log + "Avoid this" β†’ Working Code β”‚
β”‚                                                             β”‚
β”‚  Time: 5 minutes                                           β”‚
β”‚  Result: Clean solution, fresh context                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Why This Works

AI models don't "learn" from mistakes in a conversation. When you try to fix broken code, the AI:

  1. Carries forward confusion from the original error
  2. Patches symptoms instead of addressing root causes
  3. Pollutes context with failed attempts
  4. Compounds errors with each iteration

Going back to the original prompt with new information gives AI a clean slate with complete context.

The Oneshot Formula

[Original Prompt] + [Error Log] + [What to Avoid] = Working Solution

Example: Failed API Integration

First Attempt (Failed):

"Create a function to fetch user data from the /api/users endpoint"

Result: Returns undefined, crashes on empty response.


❌ Fixing Forward (Don't do this):

"The function returns undefined, can you fix it?"
"It's still not working, now I get a type error"
"Actually the whole thing is broken, let's try again"

βœ… Oneshot Paradigm (Do this):

"Create a function to fetch user data from the /api/users endpoint.

Here's what happened on my first attempt:
- Error: Cannot read property 'data' of undefined
- The endpoint returns { users: [...] } not { data: [...] }

Requirements:
- Handle the actual response shape { users: [...] }
- Return empty array if no users
- Handle network errors gracefully"

Visual: The Oneshot Loop

         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚         INITIAL PROMPT               β”‚
         β”‚    "Create feature X..."             β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                        β–Ό
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚         AI GENERATES CODE            β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                        β–Ό
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚           TEST IT                    β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                   β”‚
              β–Ό                   β–Ό
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚  WORKS  β”‚         β”‚ FAILED  β”‚
         β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
              β”‚                   β”‚
              β–Ό                   β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”‚
         β”‚  SHIP!  β”‚              β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚
                                  β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    β”‚
    β”‚  DON'T fix forward!
    β”‚  Instead, go back to start:
    β”‚
    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              ENHANCED PROMPT                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Original prompt                            β”‚   β”‚
β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”‚
β”‚  β”‚ + Error log / what happened               β”‚   β”‚
β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”‚
β”‚  β”‚ + "Avoid [specific problem]"              β”‚   β”‚
β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”‚
β”‚  β”‚ + Additional constraints learned          β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
              β”‚ Fresh context, complete information
              β–Ό
         [AI generates correct code]

Real Examples

Example 1: Database Query

First attempt failed with:

Error: relation "users" does not exist

Oneshot retry:

"Write a query to get all active users.

Previous attempt failed with: relation "users" does not exist

Context I forgot to mention:
- Table is actually called "user_accounts" (not "users")
- Schema is "app" not "public"
- Active users have status = 'active' (not is_active = true)

Please query app.user_accounts where status = 'active'"

Example 2: React Component

First attempt failed with:

TypeError: Cannot read properties of undefined (reading 'map')

Oneshot retry:

"Create a UserList component that displays users.

My first attempt crashed with: Cannot read properties of undefined (reading 'map')

The issue was:
- Data comes from useQuery hook which is initially undefined
- Need to handle loading state
- Need to handle empty array case

Please include:
- Loading spinner while fetching
- Empty state message
- Null check before mapping"

Example 3: Authentication Flow

First attempt failed with:

401 Unauthorized - Token expired

Oneshot retry:

"Implement the login flow with JWT tokens.

First attempt failed because I didn't specify:
- Tokens expire after 15 minutes
- Need refresh token logic
- Need to handle 401 by refreshing, not logging out

Please implement with:
- Access token (15 min expiry)
- Refresh token (7 day expiry)
- Auto-refresh on 401 response
- Only logout if refresh also fails"

When to Use Oneshot vs. Fix Forward

SituationApproach
Fundamental misunderstandingOneshot β€” AI needs complete context
Type error / typoFix forward is fine
Wrong API shapeOneshot β€” describe actual shape
Logic errorOneshot β€” explain expected behavior
Missing importFix forward is fine
Security vulnerabilityOneshot β€” explain the threat model
Performance issueOneshot β€” provide benchmarks and targets

The 3-Strike Rule

If you've tried to fix something 3 times and it's still broken, STOP. Go back to the beginning with a fresh prompt containing everything you've learned.

Strike 1: "Fix this error" β†’ Still broken
Strike 2: "Try this instead" β†’ Different error
Strike 3: "What about..." β†’ Even more broken

STOP! β†’ Oneshot with full context β†’ Works

Key Takeaways

  1. Fresh context beats polluted context β€” AI works better with clean information
  2. Error logs are gold β€” They tell AI exactly what went wrong
  3. "Avoid X" is powerful β€” Explicitly state what NOT to do
  4. 3 strikes = restart β€” Don't waste time patching patches

"The fastest path forward is sometimes going back to the beginning."