🔀
Conditional Generation
Generate contextually appropriate responses based on user attributes.
The Challenge
Different users need different levels of detail, different tone, and different features. Managing this in code means branching logic that obscures the actual prompt content.
The Solution
Use case blocks to define content for each user tier and condition triggers for specific scenarios—all in the prompt itself.
feature_support.prompt
init do@version: 1.0@major: 1params:@user_tier: enum[free, pro, enterprise]@feature_request: str@current_plan_limit: intend initcase @user_tier dofree: # Free tier restrictionsYou are helping a free-tier user.Keep responses concise (2-3 sentences).Do not provide advanced configurations.Mention upgrade option: "Pro users get more detailed responses."pro: # Pro tierYou are helping a Pro-tier user.Provide detailed responses with examples.Include configuration options where relevant.Suggest advanced optimizations.enterprise: # Enterprise tierYou are helping an Enterprise customer.Provide comprehensive solutions.Include security and compliance considerations.Offer custom integration support.end @user_tierif @feature_request has "limit" doThe user is hitting a limit. Current: @current_plan_limit.Explain the limit kindly and suggest alternatives.end @feature_requestcase @feature_request type doapi: Focus on API integration details.sdk: Provide code examples in multiple languages.docs: Generate reference documentation.security: Include security best practices and compliance notes.end @feature_request typeresponse do{"tier": "@user_tier","response_type": "feature_support","upgrade_suggested": @user_tier is "free"}end response
Key Benefits
- Content variations are visible in one place
- Business logic lives in prompts, not code
- Response contract tracks which tier was served