Prompting best practices
Best practices for writing prompts to build and edit apps.
Crafting high-quality prompts results in apps that are more aligned with your needs, functionally complete, and working well. Incomplete or nonspecific prompting can result in more iteration, wasted time, and higher cost as the agent uses more tokens.
Consider the following best practices for writing effective prompts in the app builder.
Reference resources by name
You can @ mention a resource in your prompt to point the agent at a specific connection.
Give as much context as possible
Be as specific as you can about the type of app you want to create or the edits you want to make. The more detail you include about what you're trying to build, the better the agent can do on the first pass.
Upload key files
Use the file upload option to add additional context to your building session.
Iterate manually and with the agent
If the first output isn't exactly what you expected, try to reframe your prompt and add more context. You can also manually edit your app and come back to the agent to continue where you left off. Working with the agent is designed to be an iterative process.
Be specific about resource nuances
Databases (Retool Database, Postgres, MySQL, etc.) can be queried or modified using similar patterns, so the agent can reliably generate SQL queries. On the other hand, API request structures and specifications can vary widely between endpoints. Giving details about how your system is configured, or pasting API documentation into your prompt helps the agent understand the structure.
For REST API resources, attach an OpenAPI or Swagger specification on the resource configuration page. With a specification attached, the agent gets typed methods for every endpoint and knows the expected request and response shapes. Without one, the agent can only make untyped requests, and might need to make several requests by trial and error.
Create your data model before you build
For apps that create or maintain production data, switch to Plan mode and ask the agent to propose the data model before building or editing the app.
A useful plan should name every existing or proposed resource. If the app uses a database, the plan should identify the relevant schema and tables. For each table, the plan should include information about:
- The type of data the table stores.
- What one row represents (such as a refund record or an inventory item).
- Columns and column data types.
- Primary and foreign keys.
- Constraints and relationships between tables.
The plan should clearly distinguish existing tables and fields from proposed changes. Related records should be connected through stable IDs rather than changeable display values such as names.
Example 1: Model related records before building
Consider an app that tracks people, interviews, and findings. A person can participate in more than one interview. A finding can be supported by several interviews, and one interview can support several findings.
If the agent repeats a person's name and details inside every interview or finding, later edits can create several versions of the same person. If it stores only one interview ID on each finding, the model cannot represent the full entity relationship.
A comprehensive data model stores each person once, stores each interview once with the person ID and interview date, stores each finding once, and connects findings to interviews through a separate entity relationship.
Example 2: Separate a UI change from a data change
A builder could ask the agent to simplify an overview page or move administrative information into a different view. That sounds like a presentation change, but the agent may also rewrite queries, introduce a new resource, or change where information is stored. If the authoritative source is not clear, records can disappear from the UI or be copied into a second structure.
Prompt the agent to explicitly separate presentation work from schema and data work. Ask the agent to first identify the current source for every affected field and state what it plans to preserve.
Example 3: Plan a safe CSV import
Adding records from a CSV is another point where the data model matters. Before importing anything, the builder needs to know how a row will match an existing record, which values may be updated, what happens when fields conflict, and whether blank values can replace existing information.
Instruct the agent so that if no reliable matching key exists, the agent should stop and ask for one rather than guessing from a display name. The agent should also preview the result before writing data so the builder can review inserts, updates, conflicts, and possible duplicates.
Plan before you build
For complex changes, use Plan mode to ask the agent to create a wireframe or an outline of your app before writing any code. Review the plan, and correct the approach either manually or by prompting the agent. This gives you further control over the actions that the app building agent takes.
Ask for specific UI components
Apps are built with a defined set of libraries. If you have a specific component in mind, name it instead of describing it. For example, asking for a Sheet is more precise than asking for a side panel.
Scope requests to one feature at a time
The agent works through tasks in steps, pausing to check in as it goes. Breaking a large request into smaller, focused prompts—one feature or section at a time—gives you more control and leads to more complete results than asking the agent to build an entire app in a single message.
When making edits, naming the specific page or area you want changed helps the agent scope its work.