Master advanced prompt structuring methods for complex tasks and consistent results
Structured prompting techniques help you break down complex requests into manageable components, resulting in more accurate and reliable AI responses. These methods are particularly useful for multi-step tasks, technical work, and scenarios requiring precise outputs.
<task>Create a REST API endpoint for user authentication</task><requirements>- Accept email and password via POST request- Validate credentials against database- Return JWT token on success- Return appropriate error codes for failures</requirements><constraints>- Use Express.js and TypeScript- Follow REST best practices- Include rate limiting- Add comprehensive error handling</constraints><output_format>Provide the complete TypeScript code with inline comments explaining security considerations.</output_format>
ZeroTwo’s AI models are trained to recognize and respect structured formatting, making this approach highly effective for complex requests.
<context>I'm building a e-commerce platform. We need to implement a shopping cart system that handles product additions, quantity updates, and price calculations including tax and shipping.</context><current_state>We have:- Product database with prices- User authentication system- Basic React frontend with Redux</current_state><requirements>1. Redux slice for cart management2. Persistent cart storage (localStorage)3. Real-time price calculations4. Tax calculation based on user location5. Shipping cost estimation</requirements><deliverables>- Redux cart slice with actions and reducers- React hooks for cart operations- TypeScript interfaces for cart items- Unit tests for calculation logic</deliverables><questions>- Should cart persist across devices?- How should we handle out-of-stock items?- Maximum items per cart?</questions>
I need to optimize this slow database query. Let's approach this systematically:Step 1: Analyze the current query execution planStep 2: Identify bottlenecks and missing indexesStep 3: Propose optimizationsStep 4: Provide the optimized queryStep 5: Explain expected performance improvementsCurrent query:[paste query here]Please work through each step explicitly before moving to the next.
Review the following code according to this checklist:Code: [paste code]Review criteria:□ Correctness - Does the code work as intended?□ Security - Are there vulnerabilities?□ Performance - Any optimization opportunities?□ Readability - Is it clear and well-structured?□ Best practices - Does it follow language conventions?□ Error handling - Are edge cases covered?□ Testing - Is the code testable?For each issue found:1. Severity level (Critical/High/Medium/Low)2. Description of the problem3. Recommended fix4. Code example of the fix
Document this function/class/module:Code: [paste code]Required sections:1. Overview - What it does and why it exists2. Parameters - Each parameter with type and description3. Returns - Return value type and description4. Exceptions - What errors can be thrown5. Usage examples - At least 2 realistic examples6. Notes - Important considerations or gotchas7. Related - Links to related functions or documentationFormat the output as JSDoc/TypeDoc/Python docstring [specify format].
Generate a password validation function with these exact constraints:MUST include:✓ Minimum 12 characters✓ At least one uppercase letter✓ At least one lowercase letter✓ At least one number✓ At least one special character (!@#$%^&*)✓ TypeScript with strict types✓ Comprehensive error messagesMUST NOT include:✗ External dependencies✗ Regex longer than 100 characters✗ Any console.log statements✗ More than 50 lines of codeOUTPUT requirements:- Function signature: validatePassword(password: string): ValidationResult- Return interface with isValid boolean and errors array- Include JSDoc comments- Include 5 unit test cases
Guide the AI to make decisions based on specified criteria.
Copy
Recommend a state management solution for my React app:App characteristics:- Team size: [specify]- App complexity: [simple/moderate/complex]- API integration: [yes/no]- Real-time features: [yes/no]- Performance critical: [yes/no]Decision logic:IF complexity is simple AND no real-time features: RECOMMEND: React Context APIELSE IF moderate complexity OR small team: RECOMMEND: ZustandELSE IF complex with many async operations: RECOMMEND: Redux ToolkitELSE IF real-time features: RECOMMEND: Jotai or RecoilFor the recommendation:1. Explain why it fits the criteria2. Provide setup code3. Show example usage4. List pros and cons5. Suggest migration path if needed
Encourage the AI to show its reasoning process for better results.
1
Explicit reasoning request
Add phrases that trigger step-by-step thinking:
Copy
Let's solve this problem step by step, showing all reasoning:Problem: [describe problem]Please:1. Identify the key challenges2. Consider multiple approaches3. Evaluate pros and cons of each4. Select the best approach with justification5. Implement the solution6. Explain why this solution is optimal
2
Self-critique prompts
Copy
Implement a caching layer for our API, then:1. Review your implementation2. Identify potential issues3. Consider edge cases4. Propose improvements5. Provide the refined versionBe your own critic and iterate to the best solution.
Act as a senior security engineer conducting a code security audit.Code to audit: [paste code]Audit framework:1. OWASP Top 10 vulnerabilities check2. Authentication and authorization review3. Input validation analysis4. Data exposure risks5. Cryptography usage review6. Dependency security check7. Error handling securityFor each category:- List findings (if any)- Severity rating- Exploitation scenario- Remediation steps with code examples- Prevention best practicesFormat output as a professional security audit report.