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:
- Carries forward confusion from the original error
- Patches symptoms instead of addressing root causes
- Pollutes context with failed attempts
- 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 SolutionExample: 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 existOneshot 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 expiredOneshot 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
| Situation | Approach |
|---|---|
| Fundamental misunderstanding | Oneshot β AI needs complete context |
| Type error / typo | Fix forward is fine |
| Wrong API shape | Oneshot β describe actual shape |
| Logic error | Oneshot β explain expected behavior |
| Missing import | Fix forward is fine |
| Security vulnerability | Oneshot β explain the threat model |
| Performance issue | Oneshot β 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 β WorksKey Takeaways
- Fresh context beats polluted context β AI works better with clean information
- Error logs are gold β They tell AI exactly what went wrong
- "Avoid X" is powerful β Explicitly state what NOT to do
- 3 strikes = restart β Don't waste time patching patches
"The fastest path forward is sometimes going back to the beginning."