Use AI in editor
Install the AI Assistant plugin
This functionality relies on the AI Assistant plugin, which you need to install and enable.
Press Ctrl+Alt+S to open settings and then select
.Open the Marketplace tab, find the AI Assistant plugin, and click Install (restart the IDE if prompted).
Generate code in the editor using prompts
Generate code and use prompts right in the editor.
Generate code in editor using prompts
Select a piece of code that you want to modify or place the caret anywhere in the editor and press Ctrl+\.
Alternatively, right-click anywhere in the editor to open the context menu, select AI Actions and then Generate Code.
In the input field, write your prompt and press Enter.
Wait for the generation to complete. The generated code will be shown in the same editor tab where you have invoked the input field.
If you want to improve the generated code, in the same input field, write a follow-up message with the new requirements and press Enter.
AI Assistant will regenerate the code while taking into account the new specifications.
If you want to regenerate the answer, click Regenerate or press Ctrl+F5.
Click Accept to insert the generated fragment.
If you want to revert some of the suggested changes, in the gutter, click Revert.
To discard all the suggested changes, click Discard in the input popup.
SQL error handling
AI Assistant can explain and fix SQL query execution errors in editor tabs. The corresponding actions are available in the error message area.
Explain SQL errors
AI Assistant can explain the SQL execution error in your code. You can also ask further questions about the error in AI chat.
This feature requires attaching the database schema to suggest proper explanations and fixes.
After running an SQL query and encountering a query execution error, click Explain with AI in the error message area.
DataGrip opens AI chat with an automatically sent prompt and AI Assistant’s response, providing an explanation of the error.
Fix SQL errors
AI Assistant can fix the SQL execution error in your code.
This feature requires attaching the database schema to suggest proper explanations and fixes.
After running an SQL query and encountering a query execution error, click Fix with AI in the error message area.
AI Assistant generates a fix for the query execution error in the editor.
Fix errors with AI
When DataGrip detects code that produces errors, it suggests a quick-fix directly within the editor.
AI Assistant can suggest more precise fixes applicable to your specific case due to its context awareness. This feature requires attaching the database schema to suggest proper explanations and fixes.
Place the caret at a highlighted error in the editor. Then click the red light bulb icon or press Alt+Enter to open the list of suggestions.
Click Fix with AI Assistant.
AI Assistant sends the entire file together with database schema as context to the LLM to determine which fix would be most suitable in this particular case.
The code is then updated directly in the editor.