Prompting Best Practices
1. Mastering Prompt Engineering for Better Output:
Treat the AI as your engineering partner; it only knows what you explicitly tell it.- Clarity and Verbosity: Clear and verbose prompts lead to superior output. Be specific, mentioning exact pages (e.g.,
/dashboard) and expected behaviours. Use natural language for your requests, such as
- Visual Aids: Add screenshots, especially when describing bugs or UX issues. This provides visual context that words alone might miss.
- Guardrails and Limitations: Tell the AI what not to touch. For instance, you might instruct:
- Repetition for Retention: AI’s memory can be limited, so repeat important instructions across prompts if necessary.
- Break Down Complex Tasks: Avoid trying to implement multiple things simultaneously. Break your work into smaller, testable chunks. Use Plan Mode between steps to validate before proceeding. A useful template for feature breakdown includes:
- Role-Specific Instructions: If your application supports multiple user roles, always define which role the prompt applies to. This helps prevent bugs arising from shared logic or components. For example:
2. Leverage Plan Mode Frequently
Plan Mode is your AI co-pilot, designed for debugging, brainstorming, and planning implementations without immediately altering your code.- When to use it: Switch to Plan Mode after 2-3 failed “Attempt fix” tries, when debugging complex logic or database issues, or when planning new features. You can prompt it to
- Workflow Recommendation: Some users find it effective to spend 60-70% of their time in Plan Mode, only switching to Build Mode once fully satisfied with the plan. This approach enhances output consistency and prevents unintended edits.
- Controlled Interaction: To avoid unwanted code execution, use prompts like “Investigate but don’t write code yet” or “Suggest 3 ways to solve this without changing anything”. This maintains control in your hands.
- Escaping AI Loops: If the AI enters a “loop” of patching broken code, switch to Plan Mode, paste a screenshot of the error, and prompt:
3. Revert, Fork or Start Over
Sometimes, going back takes less time than pushing forward, especially when stuck in a development quagmire.- Revert: Use Revert on an earlier message to restore the project to that working state, then rebuild the problematic feature step by step. Reverting erases all changes made after that point and cannot be undone.
- Fork: Use Fork from here on a message to create a new project from that point in the conversation. This lets you try a different approach while keeping the original project untouched.
- Start over: If the project has drifted too far, start a new project with improved prompts and clearer requirements, using the old project purely as a reference.
- Third-party services: A forked or remixed project starts with the same keys and settings as the original. If the original uses services such as Stripe, ask Lumi to update the keys and settings in the new project. See Troubleshooting.
4. Cultivate Patience and Calm
AI development can be unpredictable; magical one moment, frustrating the next. The final stages of a build often take the longest.- Golden Rule: Take your time with prompts, re-check everything, and break down work into small, testable blocks. Precision in your inputs directly correlates with the quality of your outputs.
5. Bonus Tips for Enhanced Workflow
- “I am frustrated…” Pattern: Employ the “I am frustrated…” prompt pattern to help the AI focus better.
- Post-Edit Checks: After any major edit, always recheck multiple roles and their behaviours, particularly for conditional logic.
- Fallback Versions: Store stable versions as fallbacks for quick debugging.
- Role-Specific Components: To avoid bugs from overly generic logic, prompt the AI to
Prompt Library – Strategies and Examples
The prompt library provides a collection of reusable prompt patterns and examples for common development scenarios with Lumi’s AI. Think of these as templates to adapt for your projects.- Starting Projects
- When to use: At the very beginning of a project to help the AI understand high-level requirements and build the foundation. It acts as your initial project brief.
- How to use: Outline the application type, key technologies (frontend, backend, services), and primary features. Direct the AI on where to begin, typically the main page or a crucial feature.
- UI/UX Design Enhancements
- When to use: To refine the visual appeal of your application without altering its functionality. This includes polishing the UI, adjusting layouts, or implementing a specific design style.
- How to use: Clearly define the scope of design changes and emphasise that functionality must remain untouched. Guide the AI on the desired aesthetic (e.g., modern, minimalist). Address multiple changes one at a time and mention any UI parts that should not have their logic altered.
- Ensuring Responsiveness
- When to use: When your app needs to adapt its layout across various screen sizes (mobile, tablet, desktop). Ideal as a final pass on UI-heavy tasks.
- How to use: Emphasise a mobile-first approach and instruct the AI to ensure responsiveness across standard breakpoints. Mention specific CSS framework guidelines (e.g., Tailwind’s
sm, md, lg, xlbreakpoints) and request the avoidance of fixed widths.
- Refactoring Code
- When to use: Periodically, especially when code becomes messy or slow. Refactoring improves code structure, readability, or performance without altering its external behaviour.
- How to use: Identify the scope (file, feature, or codebase). For specific files, prompt: “Refactor this file for clarity and efficiency, but do not alter its functionality or output”. Specify focus areas like reducing duplication or simplifying logic. For larger refactors, ask the AI to plan in steps or audit the code first.
- App Types and Features
- Strategic Planning with AI
- When to use: Before starting a complex, multi-step implementation, or when you have a large feature that needs breaking down. Planning prompts allow you to outline an approach before code is written, saving credits and preventing misdirection.
- How to use: Ask the AI for a plan or checklist. For example, “Outline a step-by-step plan for X” or “Before coding, list the steps you will take to implement Y”. This is best done in Plan Mode to avoid code changes.