Project IDX facilitates your development workflows with an AI-assisted chatbot. Before you use any of the chat assistance from Gemini in IDX, make sure you add Gemini to your workspace.
Get started with Interactive Chat with Gemini
Open Project IDX. If you haven't already, add Gemini to your workspace.
Click the Gemini icon at the bottom of the workspace or press Cmd+Shift+Space (Ctrl+Shift+Space on ChromeOS, Windows or Linux). The Interactive Chat sidebar appears.
After Interactive Chat is enabled and active, you can ask Gemini questions and get code suggestions. Gemini can even update your project configuration files and code and can run terminal commands for you, directly within your workspace. Gemini might ask you to:
- Modify files: Gemini can add a feature, fix a bug, or refactor
code. When Gemini proposes changes to a file, you'll see two options:
- Update File: Directly update the file with Gemini's proposed changes.
- Review Changes: Open the proposed changes in another window for review before applying them.
Run terminal commands: Gemini can run commands like installing dependencies or starting a development server. It may propose these commands itself, or you can ask Gemini to run them. After Gemini proposes a command, the Run Terminal Command button appears. Click it to execute the command in a terminal within IDX. Gemini will run the command and interpret the results for you in the chat window, and will help determine next steps.
Complete complex tasks with Interactive Chat
With Interactive Chat with Gemini's workspace awareness and ability to modify files and run terminal commands, Gemini can help you complete complex development tasks, like:
- Documenting your code: Gemini in IDX can automatically generate documentation in the appropriate format for your code when you ask it to "Write my docs." After you review the changes (and, if necessary, refine Gemini's responses with additional prompts), you can add the documentation to your code with a single click.
- Writing test cases: Gemini in IDX can automatically update and generate unit tests. If you ask Gemini to "write my tests," Gemini finds an existing unit test file and can add missing tests to the file. If it doesn't find existing unit test files, it creates the unit test for you. After you review the test(s) and, if necessary, refine Gemini's responses using additional prompts, you can add or update the test file to your code with a single click—and then ask Gemini in IDX to run it!
- Managing dependencies: You can ask Gemini to detect missing dependencies in your code and resolve them directly from the chat interface.
- Refactoring code: You can ask Gemini to refactor code on your behalf, for example, extracting a function, or renaming a variable across multiple files. Gemini will generate a list of proposed changes and, after reviewing and applying changes, you can ask Gemini to update and execute unit tests to verify the refactor and ensure tests continue to pass.
- Generating and running Docker workflows: If you've enabled Docker in your workspace, you can quickly containerize your application by asking Gemini to create a Dockerfile (for example, "Create a Dockerfile for my app"). After Gemini generates the Dockerfile, it can build and run the container for you.
- Run unit and integration tests: You can initiate test execution by asking
Gemini to run specific test suites (for example, "Run my unit tests" or
"Run integration tests"). Interactive Chat with Gemini will execute the
appropriate command for your project (for example,
npm test
or a specific test runner command) and will display the test results within the chat interface.
Use slash commands in Gemini chat
You can guide the output Gemini chat provides by using slash commands,
shortcuts prefaced with a forward slash (/
). Enter / at the beginning of
your Gemini chat prompt and select the action you want from the list of
available slash commands.
For example, /generate acts as a prompt shortcut to generate code snippets. Enter /generate followed by a short description of what you want.
/generate css for a black background returns the following code snippet:
body {
background-color: black;
}
/* This CSS code sets the background color of the <body> element to black. This will make the background of the entire web page black. */
For a full list of slash commands, type / in Interactive Chat.
Manage your chat threads
You can keep different topics separate in your Gemini chats by starting different threads. You can then refer back to earlier threads based on topic.
To start a new chat:
Click the plus icon or select New Chat from the drop-down in the chat header bar.
Enter your prompt.
To switch to another chat thread:
Expand the dropdown with your chat threads in the chat header bar.
Select the chat thread you want to access.
Continue that chat thread or refer back to previous chats with Gemini in IDX.
To delete a chat thread:
Select the chat thread you want to delete from the chat thread dropdown in the chat header bar.
Click the trash icon in the chat header bar. Confirm that you want to delete the chat thread.
View code citations in chat
To help you verify the code suggestions, IDX shares information about the original source and associated licenses. You can see a complete log of code citations from the Gemini chat window by clicking the License Log icon in the chat header bar.
To learn more about Google code citations, see Generative Code Assistance.