Comandos eficazes
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
A eficácia do blueprint do aplicativo e a qualidade do código gerado dependem da clareza e dos detalhes dos seus comandos. Ao usar o App Prototyping agent, considere as orientações a seguir sobre comandos eficazes ao gerar e depurar aplicativos:
- Seja específico: defina claramente os recursos, as interações do usuário e os requisitos de dados do seus aplicativo. Peça tecnologias específicas, se possível. Por exemplo, se você for criar um web app com elementos 3D, peça para o Gemini usar o
three.js
.
- Pergunte sobre outras tarefas para configurar serviços: o Gemini pode escrever o código do seu aplicativo, mas não pode configurar serviços, ativar APIs ou provisionar recursos, como um bucket do Cloud Storage ou uma conta do Stripe.
Diga ao Gemini que, se ele escrever código para serviços específicos, também precisará informar a você como configurar esses serviços.
- Solicitar um projeto do Firebase: se você pedir ao App Prototyping agent para
ajudar a configurar os serviços do Firebase, ele vai provisionar um projeto do Firebase em
seu nome. Por exemplo, você pode pedir "Me ajude a adicionar o Firestore" ou "Conecte
meu app ao Firebase".
- Use o Gemini para refinar seu comando: use o Gemini para o Google, converse com o Gemini no Firebase na visualização do Code ou outras interfaces do Gemini para refinar e otimizar o comando.
- Dê contexto: inclua informações básicas sobre o propósito, o público-alvo e a experiência do usuário que você quer.
- Use exemplos: se possível, dê exemplos de como precisa ser a interação dos usuários com o app ou quais dados devem ser exibidos.
- Itere e refine: trate seu desenvolvimento de maneira iterativa. Comece por uma solicitação básica, adicione um recurso, teste-o, refine-o e depois adicione outro recurso.
Ao seguir essas orientações, é possível aumentar significativamente a qualidade e a relevância dos blueprints do aplicativo gerados pelo Firebase Studio e o sucesso ao depurar o aplicativo.
Usar outros comandos para refinar as respostas
Se os resultados iniciais não forem o que você espera, refine seus comandos adicionando mais detalhes ou dando instruções específicas:
- Adicione restrições: especifique restrições na IU, no modelo de dados ou nos recursos.
- Dê exemplos: exemplifique como precisa ser a interação dos usuários com o aplicativo e quais dados devem ser exibidos.
- Use palavras-chave: use palavras-chave para descrever os recursos que você quer que o LLM possa associar à classe de resposta esperada. Por exemplo, use Material Design em um comando para indicar que você quer que o aplicativo siga os padrões de design do Google.
- Peça mudanças específicas: peça mudanças específicas no código ou blueprint gerado. Adicione cada solicitação de recurso em uma solicitação separada.
- Peça para o modelo raciocinar: se você tiver problemas para conseguir os resultados esperados, peça para o modelo raciocinar com base no comando. Por exemplo, diga "Pense passo a passo. Quero criar uma caixa de entrada no meu aplicativo de tarefas. Ela precisa conter um botão 'Adicionar tarefa' e um botão 'Cancelar'".
Com essas técnicas, é possível refinar iterativamente seus comandos para conseguir os resultados esperados.
Exemplos de comandos eficazes para blueprints do aplicativo
Confira a seguir alguns exemplos de comandos eficazes para diferentes tipos de aplicativos:
Acompanhamento de tarefas simples:
Create a simple web app that displays a list of to-do items.
Users should be able to add new items to the list and mark items as complete.
Provide a way to delete items and export the list as a text file.
Use a clean and modern UI using Google Material Design principles.
Aplicativo de orçamento:
A budgeting and expense tracking app with spending categories, charts, and
budget goals. Include a clean dashboard with key insights. It should include
spending categories, charts, and budget goals. The app should allow users to
manually add expenses or upload csv files. The app should also allow users to
upload receipts, then use AI to convert the receipt into an expense entry that
users can edit. Data should be stored in browser cache, with download and
delete options.
Comando para app de jogo com ajuda do Gemini (Markdown):
Generate a delightful sliding number puzzle game (15-puzzle) with Javascript,
HTML, and CSS.
- **Setup:** Create a 4x4 grid with numbers 1-15 and one empty space. Use a
**solvable shuffling algorithm** to randomize the start.
- **Gameplay:** Allow clicking tiles **adjacent to the empty space** to slide
them. Count and display the number of moves.
- **Timer:** Include a **countdown timer** starting at **120 seconds**
(2 minutes).
- **End Conditions:**
- If solved (numbers 1-15 in order): Alert with an encouraging winning
statement generated by AI.
- If timer reaches 0: Alert with a funny retort generated by AI.
Dicas de depuração
É possível usar o Gemini no Firebase para ajudar a depurar o código pela conversa no seu espaço de trabalho do Code ou no App Prototyping agent.
Embora o Gemini possa escrever código por você, às vezes ele também pode produzir erros. Quando detecta um erro, ele tenta corrigi-lo. Se você achar que não é possível resolver o problema devido à mensagem de erro, tente algumas destas técnicas:
Descreva o problema: na interface da conversa, descreva o problema que está enfrentando da forma mais clara e concisa possível.
Embora o Gemini possa ter acesso ao contexto, como mensagens de erro e registros, ele pode não o entender por completo. Descrever o comportamento com a mensagem de erro pode ajudar o Gemini a corrigir erros mais rapidamente.
Faça perguntas específicas: não tenha medo de fazer perguntas diretas sobre o código ao Gemini. Por exemplo, "O que pode estar causando uma exceção de ponteiro nulo nesta função?" ou "Como posso evitar esta disputa?"
Divida problemas complexos: se você estiver lidando com um problema complexo, divida-o em partes menores e mais fáceis de gerenciar. Peça para o Gemini ajudar a depurar cada parte separadamente e pensar nos problemas passo a passo.
Use delimitadores de código: ao compartilhar snippets de código, use delimitadores de código para garantir que o código seja formatado corretamente. Isso facilita a leitura e a compreensão do código pelo Gemini.
Itere e refine: o Gemini nem sempre sugere a solução perfeita na primeira tentativa. Analise as respostas, faça perguntas para esclarecimento e dê mais informações conforme necessário.
Evite repetições de comandos: se o Gemini ficar preso em uma repetição ou não conseguir responder à pergunta, tente reformular o comando ou dar mais contexto. Às vezes, basta reformular sua pergunta para ajudar o Gemini a entender o que você quer.
Se reformular o comando não resolver a repetição, tente estas técnicas:
Inicie uma nova conversa: se você estiver usando a conversa do Gemini no Firebase no seu espaço de trabalho do Code, inicie uma nova sessão de conversa para redefinir o contexto do Gemini. Isso pode ajudar a evitar equívocos ou suposições que o Gemini tenha produzido na conversa anterior.
Contraponha-se com exemplos: se o Gemini gerar suposições incorretas, contraponha-se com exemplos para ajudá-lo a entender o comportamento correto.
Próximas etapas
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-08-22 UTC.
[null,null,["Última atualização 2025-08-22 UTC."],[],[],null,["The effectiveness of your app blueprint and the quality of the generated code\ndepend on the clarity and detail of your prompts. When using\nthe App Prototyping agent, consider the following guidelines for effective\nprompting when generating and debugging apps:\n\n- **Be specific:** Clearly define the features, user interactions, and data requirements of your app. Ask for specific technologies, where possible. For example, if trying to create a web app with 3D elements, you may want to ask Gemini to use `three.js`.\n- **Ask about additional tasks to set up services:** Gemini can write code for your app, but it cannot actually set up services, enable APIs, or provision resources (like a Cloud Storage bucket or a Stripe account). Make sure to tell Gemini that if it writes code for specific services that it should also tell you how to set up those services.\n- **Request a Firebase project:** If you ask the App Prototyping agent to help you set up Firebase services, it will provision a Firebase project on your behalf. For example, you can ask \"Help me add Firestore,\" or \"Connect my app to Firebase.\"\n- **Use Gemini to refine your prompt:** Use [Gemini for\n Google](https://gemini.google.com), [chat with\n Gemini in Firebase](/docs/studio/try-gemini) in Code view, or other Gemini surfaces to refine and optimize your prompt.\n- **Provide context:** Include background information about your app's purpose, target audience, and the user experience you want.\n- **Use examples:** If possible, provide examples of how users should interact with the app or what data should be displayed.\n- **Iterate and refine:** Approach your development *iteratively*. Consider starting with a basic request, then add a feature, test it, refine it, then add another feature.\n\nBy following these guidelines, you can significantly improve the quality and\nrelevance of the app blueprints generated by Firebase Studio and its\nsuccess when debugging your app.\n\nUse additional prompts to refine responses\n\nIf the initial results aren't what you expect, you can refine your prompts by\nadding more detail or providing specific instructions:\n\n- **Add constraints:** Specify constraints on the UI, data model, or features.\n- **Provide examples:** Provide examples of how users should interact with the app and what data should appear.\n- **Use keywords:** Use keywords to describe the features or capabilities you want that the LLM might associate with the class of output you want. For example, you might use *Material Design* in a prompt where you indicate that you want your app to adhere to Google design standards.\n- **Ask for specific changes:** Ask for specific changes to the generated code or blueprint. Add each feature request in a separate request.\n- **Ask the model to reason:** If you're having trouble getting the results you want, try asking the model to reason through the prompt. For example, you could say \"Think step by step. I want to create an input box for my task app. It should contain an 'Add task' button and a 'Cancel' button.\"\n\nBy using these techniques, you can iteratively refine your prompts to get the\nresults you want.\n\nExamples of effective prompts for app blueprints\n\nHere are some examples of effective prompts for different types of apps:\n\n**Simple task tracker:** \n\n Create a simple web app that displays a list of to-do items.\n Users should be able to add new items to the list and mark items as complete.\n Provide a way to delete items and export the list as a text file.\n Use a clean and modern UI using Google Material Design principles.\n\n**Budgeting app:** \n\n A budgeting and expense tracking app with spending categories, charts, and\n budget goals. Include a clean dashboard with key insights. It should include\n spending categories, charts, and budget goals. The app should allow users to\n manually add expenses or upload csv files. The app should also allow users to\n upload receipts, then use AI to convert the receipt into an expense entry that\n users can edit. Data should be stored in browser cache, with download and\n delete options.\n\n**Game app prompt with assistance from Gemini (Markdown):** \n\n Generate a delightful sliding number puzzle game (15-puzzle) with Javascript,\n HTML, and CSS.\n\n - **Setup:** Create a 4x4 grid with numbers 1-15 and one empty space. Use a\n **solvable shuffling algorithm** to randomize the start.\n - **Gameplay:** Allow clicking tiles **adjacent to the empty space** to slide\n them. Count and display the number of moves.\n - **Timer:** Include a **countdown timer** starting at **120 seconds**\n (2 minutes).\n - **End Conditions:**\n - If solved (numbers 1-15 in order): Alert with an encouraging winning\n statement generated by AI.\n - If timer reaches 0: Alert with a funny retort generated by AI.\n\nTips for debugging\n\nYou can use Gemini in Firebase to help you debug your code with\nchat in your **Code** workspace\nor the App Prototyping agent.\n\nWhile Gemini can write code for you, it might sometimes also\nproduce errors. When it detects an error, it will attempt\nto fix it. If you find that it isn't able to resolve the issue given\nthe error message, you can try some of the following techniques:\n\n- **Describe the issue:** In the chat interface, describe the\n problem you're encountering as clearly and concisely as possible.\n While Gemini might have access to context like error messages\n and logs, it might not understand the full context. Describing the behavior\n along with the error message can help Gemini fix errors\n faster.\n\n- **Ask specific questions:** Don't be afraid to ask Gemini\n direct questions about your code. For example, \"What could be causing a\n null pointer exception in this function?\" or \"How can I prevent\n this race condition?\"\n\n- **Break down complex problems:** If you're dealing with a complex\n issue, break it down into smaller, more manageable parts. Ask\n Gemini to help you debug each part separately and think\n through problems step-by-step.\n\n- **Use code fences:** When sharing code snippets, use code fences\n to ensure that the code is properly formatted. This makes it easier\n for Gemini to read and understand your code.\n\n- **Iterate and refine:** Gemini may not always provide the perfect\n solution on the first try. Review the responses, ask clarifying\n questions, and provide additional information as needed.\n\n- **Avoid prompting loops:** If Gemini gets stuck in a loop or is\n unable to answer your question, try rephrasing your prompt or\n providing additional context. Sometimes, just rewording your\n question can help Gemini understand what you're asking.\n\n If rephrasing your prompt doesn't resolve the loop, try\n the following techniques:\n - **Start a new chat:** If you're using Gemini in Firebase\n chat in your Code\n workspace, start a new chat session to reset\n Gemini's context. This can help break free from any\n misconceptions or assumptions that Gemini may have made\n in the previous conversation.\n\n - **Provide counter-examples:** If Gemini is making incorrect\n assumptions, provide counter-examples to help it understand\n the correct behavior.\n\nNext steps\n\n- [Get started with the App Prototyping agent](/docs/studio/get-started-ai).\n- [Develop, publish, and monitor an app following a guided tour of the App Prototyping agent](/docs/studio/solution-build-with-ai).\n- [Develop applications in a\n Firebase Studio workspace](/docs/studio/get-started-workspace)."]]