Optimal Planning Prompt Structure for Opus/Sonnet
Template for Feature Planning:
I need a detailed implementation plan for [FEATURE NAME].
Context:
- Tech stack: [languages, frameworks, libraries]
- Existing architecture: [brief description or relevant files]
- User story: [what the user needs to do]
Please provide:
1. IMPLEMENTATION BREAKDOWN
- List of files to create/modify
- For each file: specific functions/classes needed
- Dependencies between components
2. FUNCTION SPECIFICATIONS
For each major function, specify:
- Function signature (exact parameters and return types)
- Input validation requirements
- Core logic steps (numbered list)
- Error handling needed
- Expected output format
3. DATA STRUCTURES
- Exact interface/type definitions
- Example data shapes with sample values
4. EDGE CASES & VALIDATION
- Input edge cases to handle
- Error conditions to check
- Boundary conditions
5. TESTING CHECKLIST
- Unit test cases (with sample inputs/outputs)
- Integration test scenarios
6. IMPLEMENTATION ORDER
- Numbered sequence of what to build first
- Dependencies clearly marked
Format each section clearly so I can copy individual parts to another AI for implementation.
Example: Real Planning Prompt
I need a detailed implementation plan for a user authentication system.
Context:
- Tech stack: Node.js, Express, PostgreSQL, JWT
- Existing: Basic Express server with database connection
- User story: Users need to register, login, and access protected routes
Please provide:
1. IMPLEMENTATION BREAKDOWN
- Files to create/modify
- Functions needed in each file
- Component dependencies
2. FUNCTION SPECIFICATIONS
For registerUser, loginUser, verifyToken, and middleware:
- Exact function signatures
- Step-by-step logic
- Validation rules
- Error scenarios
3. DATA STRUCTURES
- User table schema
- JWT payload structure
- Request/response formats
4. EDGE CASES & VALIDATION
- Email format validation
- Password strength rules
- Duplicate user handling
- Invalid token scenarios
5. TESTING CHECKLIST
- Test cases with expected results
6. IMPLEMENTATION ORDER
- Build sequence with dependencies
Make each section copy-paste ready for implementation.
Key Elements That Make Plans “Haiku-Ready”
DO Include:
1. Exact Code Signatures
// Good - Haiku can implement directly
function validateEmail(email: string): boolean
function hashPassword(password: string): Promise<string>
function createUser(email: string, hashedPassword: string): Promise<User>
2. Step-by-Step Logic
// Good - Clear numbered steps
Function: authenticateUser(email, password)
Steps:
1. Query database for user by email
2. If user not found, return error "User not found"
3. Compare password with stored hash using bcrypt
4. If password incorrect, return error "Invalid password"
5. Generate JWT token with user.id and user.email
6. Return { token, user: { id, email } }
3. Concrete Examples
// Good - Shows exact format
Input example: { email: "user@example.com", password: "SecurePass123!" }
Output example: { token: "eyJhbGc...", user: { id: 5, email: "user@example.com" } }
Error example: { error: "User not found", code: 404 }
4. Explicit Validation Rules
// Good - Specific criteria
Password requirements:
- Minimum 8 characters
- At least one uppercase letter
- At least one number
- At least one special character (!@#$%^&*)
Email validation:
- Must match regex: /^[^\s@]+@[^\s@]+\.[^\s@]+$/
- Maximum 255 characters
DON’T Include:
1. Vague Descriptions
// Bad - Too abstract
"Implement robust authentication"
"Handle errors appropriately"
"Make it secure"
2. Implementation Choices Left Open
// Bad - Forces Haiku to decide
"Use JWT or sessions (your choice)"
"Store passwords securely"
"Pick an appropriate hashing algorithm"
3. Missing Error Details
// Bad - Unclear what to return
"Handle login failures"
// Good - Specific error responses
"If password wrong, return 401 with { error: 'Invalid credentials' }"
Template for Implementation Prompts to Haiku
Once you have Opus/Sonnet’s plan, structure your Haiku prompts like this:
Implement the following function according to this specification:
FUNCTION SPEC:
[paste exact section from Opus/Sonnet's plan]
REQUIREMENTS:
- Follow the exact signature provided
- Implement all numbered logic steps
- Include all error handling specified
- Use the exact error messages from the spec
CODE STYLE:
- [your preferred style guide]
- Add inline comments for each major step
Return only the implementation code.
Advanced: Sectioned Planning for Large Features
For complex features, ask Opus/Sonnet to break it into phases:
Create a 3-phase implementation plan for [feature]:
PHASE 1 - Core Data Layer
- Database models
- Basic CRUD operations
- No business logic yet
PHASE 2 - Business Logic
- Validation functions
- Service layer
- Error handling
PHASE 3 - API Layer
- Route handlers
- Middleware
- Response formatting
For each phase, provide the detailed specs format above.
This allows me to implement incrementally with a junior AI.
Pro Tips:
1. Ask for “Implementation Notes” Add to your planning prompt:
Include an "Implementation Notes" section with:
- Common pitfalls to avoid
- Library-specific gotchas
- Order of operations if it matters
2. Request Code Skeletons
For complex functions, provide a code skeleton with:
- Function signature
- Comments for each step
- TODO markers for implementation
3. Include Testing Instructions
For each function, specify:
- How to test it in isolation
- Mock data to use
- Expected console output or test assertions
4. Version the Plan Save Opus/Sonnet’s plans with version numbers. When you need changes:
Based on implementation plan v1.2, update the loginUser function to:
- [new requirement]
Provide only the updated function spec in the same format.
Example: Complete Workflow
Step 1 - To Opus/Sonnet:
Create implementation plan for [feature-name] feature.
[use template above]
Step 2 - Save Opus/Sonnet’s Output
Save as your-feature-name-plan.md
Step 3 - To Haiku (per section):
Implement this function from the spec:
[paste section 2.1 from plan: [your-feature-function] function]
Requirements from spec:
- Use the regex provided
- Return the exact boolean specified
- No additional dependencies
Step 4 - If Haiku struggles: Go back to Opus/Sonnet with:
The [your-feature-function] function needs more detail.
Current spec: [paste what you gave Haiku]
Issue: [what went wrong]
Provide a more detailed spec including:
- Exact regex pattern
- Step-by-step validation logic
- Example inputs (valid and invalid)
Measuring Success
Your plan is good enough when:
- You can copy/paste sections directly to Haiku
- Haiku asks no clarifying questions
- Haiku’s first attempt is 80%+ correct
- You only fix minor style issues, not logic