Stay organized with collections Save and categorize content based on your preferences.
This document describes how to use Gemini Code Assist code customization and provides a few best practices. This feature lets you receive code recommendations, which draw from the internal libraries, private APIs, and the coding style of your organization.
Code customization is automatically triggered and provides suggestions based on what you write.
Consider the following:
Code completion needs a certain level of confidence to propose a suggestion. Ensure that a substantial amount of code is available so that relevant snippets are retrieved.
Code completion checks if you have required libraries in order to use certain elements of the function.
The following table provides guidance and examples about using code customization in specific use cases:
Use case
Things worth trying
Writing new code
Try the following to generate code in your IDE or Gemini Code Assist chat:
Generate code that would use terms which are already mentioned in your codebase.
Paste in your code, such as a functional signature or code with TODO comments, and then ask Gemini Code Assist to fill in or replace TODO comments with code. Add comments with explanation from context.
Try generating code with the following prompts in Gemini Code Assist chat:
"Write a main function where a connection to DATABASE is created. Include health checks."
"Write a FUNCTION_OR_CLASS in the following structure: EXPLAIN_STRUCTURE."
After you generate some code, try using a follow-up prompt to improve it:
"Try the /fix command to adjust the generated code—for example, syntax errors."
"Add missing imports."
"Try /fix on chat-generated code."
Cleaning, simplifying, and refactoring code
Try the following prompts in Gemini Code Assist chat:
"Can you merge IMPORTS_VARIABLES_OR_NOTE_EXPORTED_FUNCTIONS in this file?"
"How would you simplify the FUNCTION_NAME function?"
"Can you merge FUNCTION_NAME_1 and FUNCTION_NAME_2 into one function?"
"Could you inline some variables in FUNCTION_NAME?"
"Could you simplify variable naming in the function FUNCTION_NAME?"
Readability
Try the following prompts in Gemini Code Assist chat:
"Write the function FUNCTION_NAME in fewer lines of code, if possible."
"Add comments to the function FUNCTION_NAME."
"Remove unnecessary whitespaces in the function FUNCTION_NAME."
"Format the function FUNCTION_NAME in a similar way as the rest of the code."
Code review
Try the following prompts in Gemini Code Assist chat:
"Split the code in parts and explain each part using our codebase."
"Are there variables or keywords that could be shorter and more self-explanatory?"
"Can you give me useful code from the REPOSITORY_NAME_PACKAGE_MODULE context for this code?"
"What do you think about the function FUNCTION_NAME?"
Debugging
Try the following prompts in Gemini Code Assist chat:
"I am getting an error when I try to do X/add Y. Why?"
"Can you spot an error in the function FUNCTION_NAME?"
"How would you fix the function FUNCTION_NAME given this error message?"
Learning and onboarding
Try the following prompts in Gemini Code Assist chat:
"Split this code in parts and explain each of them using our codebase."
"Show how to call function FUNCTION_NAME?"
"Show how to run the main function in the ENVIRONMENT_NAME environment?"
"What is the key technical improvement we can do to make this code more performant?"
"Show me the implementation of FUNCTION_OR_CLASS_NAME to achieve better results and add what that specific element is"—for example, "Show me the implementation of function foo where foo is the name of the function."
Migration
Try the following prompts in Gemini Code Assist chat:
"Give me a strategy for how I can migrate FILE_NAME from LANGUAGE_1 to LANGUAGE_2"—for example, from Go to Python.
"Given the function FUNCTION_NAME in repository REPOSITORY_NAME, find me an equivalent function in language LANGUAGE_NAME that I can use."
Try the following chat-based or code generation transformation workflow using prompts:
"Take FILENAME_COMPONENT code already written in LANGUAGE_1 and refactor and migrate it to LANGUAGE_2"—for example, from Go to Python.
After you migrate some code, try the following:
Select smaller chunks and use /fix to get it into a state that you want.
Try the following prompts:
"Is there something which can be improved?"
"Give me possible pain points."
"How would you test this code if that migration is correct?"
Generating documentation
Try the following prompts in Gemini Code Assist chat:
"Summarize the code in package or folder X and provide documentation for the top five important methods."
"Generate documentation for FUNCTION_OR_CLASS_NAME."
"Shorten the documentation while preserving the key information."
Unit test generation
Try the following prompts in Gemini Code Assist chat:
"Generate unit tests for FILENAME."
"Add the most relevant test cases for the FUNCTION_NAME function."
"Remove test cases that you think don't bring much value."
Best practices
Use relevant variable and function names or code snippets. This guides code customization towards the most pertinent code examples.
Use index repositories that you want to scale, and avoid adding deprecated functionality. Code customization helps to scale to the code style, patterns, code semantics, knowledge, and implementations across the codebase. Bad examples of repositories to scale are deprecated functionalities, generated code, and legacy implementations.
For code retrieval use cases, use code generation functionality instead of code completion. Prompt using language such as "Using the definition of FUNCTION_NAME, generate the exact same function," or "Generate the exact implementation of FUNCTION_NAME."
Have includes or imports present in the file for the code that you want to retrieve to improve Gemini contextual awareness.
Execute only one action for each prompt. For example, if you want to retrieve code and have this code be implemented in a new function, perform these steps over two prompts.
For use cases where you want more than just code (such as code explanation, migration plan, or error explanation), use code customization for chat, where you have a conversation with Gemini with your codebase in context.
Note that AI model generation is non-deterministic. If you aren't satisfied with the response, executing the same prompt again might achieve a better result.
Note that generating unit tests generally works better if you open the file locally, and then from chat, ask to generate unit tests for this file or a specific function.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-02 UTC."],[[["Gemini Code Assist code customization allows users to receive tailored code recommendations based on their organization's internal libraries, private APIs, and coding style, but is exclusive to the Enterprise subscription."],["Code customization can be triggered via natural language chat, code generation, code transformation, and autocomplete features within the IDE."],["The tool can be used for various coding tasks, including writing new code, refactoring, improving readability, code review, debugging, learning, migration, documentation generation, and unit test generation."],["Best practices include using relevant variable and function names, avoiding deprecated code in indexed repositories, utilizing code generation for code retrieval, and ensuring necessary includes or imports are present in the file."],["When seeking explanations, migration plans, or error insights, leveraging the chat feature for conversations within the context of the codebase is recommended."]]],[]]