Prompting with Lovable
List of prompting strategies and approaches.
To help you make the most out of Lovable, we compiled a list of prompting strategies and approaches. Some of these were collected from our team’s experience, and others were shared with us by our community members.
What is prompting? Prompting is the term for textual, natural language inputs used to interact with Lovable. You can think of it as messages containing instructions you give to Lovable.
Since Lovable relies on large language models (LLMs), effective prompting strategies can significantly improve its efficiency and accuracy.
Basics
Prompts are the primary way to interact with Lovable app:
-
Welcome Screen: Start with prebuilt prompts or create your own.
-
Builder UI: Use the chat-based interface to iterate quickly.
Prompts serve as the backbone of all interactions.
Prompting strategies
These strategies will often work combined, depending on your specific use cases. Feel free to experiment with them and see which ones give the best results. While Lovable on its own can do a lot even from a very basic and generic prompt, using some of these strategies can help you achieve even better results.
Contextual prompting
Providing context can help Lovable understand the broader scope of your requirements. Before asking for specific tasks, you can set the stage with background information.
Setting the context
Another example:
Another example:
Incremental prompting
Our experience has shown that making incremental, smaller changes will yield better results than dumping a huge prompt and expecting AI to handle it well.
DON’T:
DO:
Another example:
Using image prompts
Recently we added support where users can upload images with their prompts and ask Lovable to build a solution based on it.
There are two main approaches here. The first one is a simple prompting approach.
Simple image upload prompting
You can upload an image and then add an example prompt like this:
Or, you can help AI better understand the content of the image and some additional specifics about it.
Image prompting with detailed instructions Excellent results can be achieved by adding specific instructions to the image uploaded. While the image is worth a thousand words, adding a couple of your own to describe desired functionality can go a long way - especially since interactions cannot always be obvious from a static image.
Feedback integration
Review the AI’s output and provide specific feedback for refinements.
Avoid ambiguity
Ensure your prompts are clear and unambiguous. Avoid vague terms and be as specific as possible about what you need.
DON’T:
DO:
Another example:
Unspecific prompt
Avoid unspecific and broad prompts
Add constraints
Sometimes, adding constraints can help focus the AI on what’s important and avoid unnecessary complexity.
Adding constraints
Advanced Prompting Strategies
Emphasizing Accessibility
Encourage the generation of code that adheres to accessibility standards and modern best practices. This ensures that the output is not only functional but also user-friendly and compliant with accessibility guidelines.
Predefined Components and Libraries
Specify the use of certain UI libraries or components to maintain consistency and efficiency in your project. This directs the AI to utilize specific tools, ensuring compatibility and a uniform design language across your application.
Implementing Chain of Thought (CoT) Prompts
For complex tasks, encourage the AI to process the problem step by step before providing a solution. This methodical approach helps in breaking down intricate tasks, leading to more accurate and comprehensive solutions.
Multilingual Prompting
When working in a multilingual environment, specify the desired language for both code comments and documentation. This ensures that the generated content is accessible to team members who speak different languages, enhancing collaboration.
Defining Project Structure and File Management
Clearly outline the project structure, including file names and paths, to ensure organized and maintainable code generation. This provides clarity on where new components should reside within the project, maintaining a coherent file organization.
Debugging and Issue Reporting
Debugging Instructions
Follow these steps for systematic debugging:
-
Task Identification: List and prioritize all tasks.
-
Internal Review: Verify your solution internally before submission.
-
Reporting: Confirm each completed task with clear, verifiable results.
-
DOM Validation: Ensure changes render in the DOM. Provide DOM tags or feedback for verification.
-
Qualifying Questions: Clarify any uncertainties before proceeding.
-
Error Handling and Logging: Use robust error handling and verbose
console.log
. Never remove logs until production. -
Debug Tools Management: Implement a global switch to disable tools in production.
-
Breakpoint Implementation: Add breakpoints for isolating GPT-related bugs.
-
Third-Party Packages: Check for reusable libraries before writing new code.
-
Leveraging Existing Systems: Build on pre-existing features to ensure consistency.
-
Code Audit: Perform a detailed analysis, document issues, and plan a solution before making changes.
Debugging Flow
To debug systematically:
-
Add failing test cases.
-
Isolate the problem and analyze dependencies.
-
Document findings before applying fixes.
Systematic Feedback
When reporting bugs or requesting changes:
-
Describe the current behavior and issue.
-
Outline the expected behavior.
-
Add specific constraints.
Be specific when correcting issues
Issues will happen, sometimes builds will fail and the app that was generated will not look exactly as you wanted it. Effective prompting can help you get back on track. Again, it’s important to be specific.
Avoid generic and very broad prompts
Instead, be more specific.
Make your prompts more detailed and specific
Using Dev console for reporting bugs
If you are more technical and an issue has happened, then pasting an error logged in the browser’s Console can be very helpful.
Typically, you’ll open the Dev tools and navigate to Console. If there are any errors or notifications visible, you can copy and paste them as a prompt.
Using Dev tools and console logs
Practical Debugging Example
A real-world step-by-step debugging flow in Lovable might look like this:
Step 1:
Step 2:
Step 3:
Lovable Prompts
To enhance your productivity, we’ve added specific Lovable Prompts for common scenarios:
Collaboration and Process Prompts
For working collaboratively or debugging with a team:
Error Debugging
Minor Errors:
Persistent Errors:
Major Errors:
Clean up Console Logs:
Refactoring
Refactoring After Request Made by Lovable:
Design
UI Changes:
Optimize for Mobile:
Modifying an Existing Feature:
Fragile Update:
Pre-Implementation Prompts
Before implementing significant changes:
Experiment with chat modes
Chat modes are an experimental feature which allow you to switch how you interact with Lovable. We shipped Chat modes with:
-
Default: Chat and make edits to your project.
-
Chat only: Chat without making edits to your project.
We may ship extra chat modes in the future, or remove them altogether as we experiment with different ways of interacting with Lovable.
Conclusion
Prompting in Lovable becomes more powerful when you combine strategies like incremental prompting, contextual instructions, and the newly introduced Lovable Prompts. Experiment, iterate, and leverage these practices to streamline your workflows, debug effectively, and build robust applications.