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 Discuss Mode between each step 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 Discuss Mode Frequently
Discuss Mode is your AI co-pilot, designed for debugging, brainstorming, and planning implementations without immediately altering your code.- When to use it: Switch to Discuss Mode after 2-3 failed “Try to Fix” attempts, 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 Discuss Mode, only clicking “Implement the plan” once fully satisfied. 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 Discuss Mode, paste a screenshot of the error, and prompt:
3. Remix as a Last Resort.
Sometimes, starting over takes less time, especially when stuck in a development quagmire.- What Remixing Does: Remix creates a clean copy of your project at T=0. You can then rebuild with improved prompts and clearer knowledge, using your old project purely as a reference.
- When to Remix: This is useful if you are stuck in a buggy loop, want to restart cleanly while preserving history, or need to disconnect a database service like Supabase and try a new approach.
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, xl
breakpoints) 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 Discuss Mode to avoid code execution.