> ## Documentation Index
> Fetch the complete documentation index at: https://lovable.generaltranslation.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Best practices

> Getting the Most Out of Lovable

This guide helps all users—new or experienced—get up to speed quickly and avoid common pitfalls when building on Lovable.

## 1. Set your foundation: Use the knowledge file

**Why it matters:** The [Knowledge](/features/knowledge) file is your project’s brain. It gets sent with every prompt and helps the AI understand the full context.

**What to include:**

* Your product vision (think of it like a PRD)
* User journeys and personas
* Key features and functionality
* Design systems and UI guidance
* Role-specific behavior (e.g. Admin, User, Investor)

<Tip>
  You can auto-generate a Knowledge file via Chat mode:

  ```
  Generate knowledge for my project at T=0 based on the features I’ve already implemented.
  ```
</Tip>

## 2. [Prompting](/prompting/prompting-one) Best practices

**Clear, verbose prompts = better output.** Think of the AI like your engineering partner—it only knows what you tell it.

**Prompting tips:**

* Be specific: Mention the exact page (e.g. `/dashboard`) and expected behavior.
* Use natural language

  ```
  I want users with the role Investor to access this component, but not Admins.
  ```
* Add screenshots: Especially useful for describing bugs or UX issues.
* Add guardrails: Tell the AI what **not** to touch. E.g.

  ```
  Do not edit /shared/Layout.tsx.
  ```
* Repeat important instructions across prompts. The AI’s memory can be limiting.
* Avoid trying to implement 5 things at once. Break work into smaller, testable chunks. Use Chat Mode between each block to validate before moving on.

  ```
  **Feature Breakdown Template:**
  Create the new page
  Add UI layout
  Connect the data
  Add logic + edge cases
  Test per role
  ```
* If your app has multiple roles (e.g. Admin, Investor, Startup), always define *which role* the prompt applies to. This helps avoid bugs caused by shared logic/components.

  ```
  As an Investor, I want to view the company dashboard, but I shouldn’t be able to edit it. Please isolate this feature to the Investor role only.
  ```

## 3. Use chat mode early and often

[**Chat mode**](https://docs.lovable.dev/features/labs#chat-mode) = your AI co-pilot. It helps you debug, brainstorm, and plan implementations—without editing your code until you’re ready.

**When to switch to Chat Mode:**

* After 2–3 failed “Try to Fix” attempts
* When debugging complex logic or database issues
* When planning new features

  ```
  Suggest 3 ways to implement X
  ```

<Tip>
  **Workflow tip:**

  Some users like to use Chat Mode for 60–70% of your time. Only click “Implement the plan” when you’re fully satisfied.
</Tip>

<Tip>
  If you forget using the Chat mode, this format improves output consistency and prevents collateral edits.

  ```
  On page /settings, implement [feature]. The expected behavior is [XYZ]. Please don’t touch component A, layout B, or shared logic unless necessary. Follow best practices from Tailwind / Supabase / X.
  ```
</Tip>

<Tip>
  To avoid unwanted code execution:

  ```
  Investigate but don’t write code yet.
  ```

  ```
  Suggest 3 ways to solve this without changing anything.
  ```

  This keeps control in your hands.
</Tip>

<Tip>
  When AI enters a "loop," use this sequence to avoid endless cycles of patching broken code:

  1. Switch to Chat mode
  2. Paste the error screenshot
  3. Say:

     ```
     Please investigate this without breaking other features. If needed, revert to the last working version and fix from there.
     ```
</Tip>

## 4. Avoid common pitfalls with Supabase

**Heads-up:** [Supabase](https://docs.lovable.dev/integrations/supabase) does not revert cleanly. If you revert a version, your database schema may break.

**Best practices:**

* Connect Supabase **after** front-end is stable
* If you must revert, prompt the AI:

  ```
  Please validate the SQL schema at T=0 and ensure no breaking changes have occurred.
  ```
* Always test database-linked features before publishing

## 5. Use Visual Edit for quick UI fixes

The [**Visual Edit tool**](https://docs.lovable.dev/features/visual-edit) is free and fast. Use it instead of prompts for:

* Changing text, colors, fonts, layout tweaks
* Editing multiple small elements at once
* Safe, credit-free commits (with undo available)

## 6. Use [GitHub](https://docs.lovable.dev/integrations/git-integration) + version control wisely

* Every edit is a commit. Use **pinning** to mark stable versions. After every working feature: **Pin it**
* After every bug: **Compare versions visually.** You can prompt with:

  ```
  Compare version at T–1 to T–0. What changed? What might be breaking?
  ```
* Come back to a stable version if you feel the AI has broken too much things.
* Use **GitHub branching** at your own risk. Avoid deleting branches before switching back to `main` in Lovable to prevent project sync issues.

## 7. When all else fails, remix

Many users realize: doing it all over takes less time the second time.

* [Remix](https://docs.lovable.dev/user-guides/quickstart#remix-an-existing-project:~:text=you%20to%20reuse-,the,-current%20state%20of) creates a clean copy of your project at T=0.
* Rebuild with better prompting + clearer knowledge
* Use your old project as reference only

**Use cases:**

* You're stuck in a buggy loop
* You want to restart clean with preserved history
* You need to disconnect Superbase and try a new path

<Tip>
  Remixing requires disconnecting Superbase first.
</Tip>

## 8. Stay patient, stay calm

You’re not alone. AI can be magical one moment and frustrating the next. The final 5% of any build is often the slowest—but the most important.

<Tip>
  **Golden rule:**

  Take your time with prompts. Re-check everything. Break work into small, testable blocks. The more precise your inputs, the better your outputs.
</Tip>

## 9. Use the docs and ask for help

* [Documentation](https://docs.lovable.dev) contains walkthroughs, templates, SEO tips, integrations, and more. You can ask questions directly in the doc AI assistant.
* Join the [Discord community](https://discord.gg/lovable-dev) for peer support.
* When ready, submit your project to [Lovable Launch](https://docs.lovable.dev/features/launched).

## 10. Bonus tips

* Add a voice note prompt using dictation (e.g. On Mac, use the mic to dictate long prompts) for long prompts. You’ll craft better input faster—especially useful when frustrated or tired.
* Use the “`I am frustrated…`” prompt pattern to nudge better AI focus
* After a major edit, always recheck multiple roles and their behavior (especially with conditional logic)
* Store stable versions as fallbacks for quick debugging
* If you're seeing unexpected side effects, this helps avoid bugs caused by overly generic logic.

  ```
  Create a component specifically for [role X] and do not reuse shared components unless clearly scoped.
  ```
