Stay organized with collectionsSave and categorize content based on your preferences.
This document describes how to useGemini Code Assist code customizationand 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.
The following table provides guidance and examples about using
code customization in specific use cases:
Unit test generation
Try the following prompts in Gemini Code Assist
chat:
"Generate unit tests forFILENAME."
"Add the most relevant test cases for theFUNCTION_NAMEfunction."
"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 ofFUNCTION_NAME, generate the exact same function," or
"Generate the exact implementation ofFUNCTION_NAME."
Have includes or imports present in the file for the code that you want to
retrieveto 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 testsgenerally works better if you open the
file locally, and then from chat, ask to generate unit tests for this file or
a specific function.
Get more relevant suggestions with remote repository context
You can get more contextually aware and relevant code suggestions by directing Gemini Code Assist to focus on specific remote repositories. By using the@symbol in the chat, you can select one or more repositories to be used as a primary source of context for your prompts. This is useful when you are working on a task that is mostly related to a specific set of microservices, libraries, or modules.
To use a remote repository as context, follow these steps in your IDE's chat:
Start your prompt with the@symbol. A list of available remote repositories that are indexed will appear.
Select the repository you want to use for context from the list. You can also start typing the repository name to filter the list.
After selecting the repository, write the rest of your prompt.
Gemini will then prioritize the selected repository when generating a response.
Example Prompts
Here are some examples of how you can use this feature:
To understand a repository:
"@REPOSITORY_NAMEWhat is the overall structure of this repository?"
"@REPOSITORY_NAMEI'm a new team member. Can you give me an overview of this repository's purpose and key modules?"
For code generation and modification:
"@REPOSITORY_NAMEImplement an authentication function similar to the one in this repository."
"@REPOSITORY_NAMERefactor the following code to follow the conventions in the selected repository."
"@REPOSITORY_A_NAMEHow can I use the latest functions from this repository to improve my code inREPOSITORY_B_NAME?"
For testing:
"@UNIT_TEST_FILE_NAMEGenerate unit tests forMODULEbased on the examples in the selected file."
By using remote repositories as a focused source of context, you can get more accurate and relevant suggestions from Gemini Code Assist, which can help you code faster and more efficiently.
[[["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-09-04 UTC."],[[["\u003cp\u003eGemini 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.\u003c/p\u003e\n"],["\u003cp\u003eCode customization can be triggered via natural language chat, code generation, code transformation, and autocomplete features within the IDE.\u003c/p\u003e\n"],["\u003cp\u003eThe 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.\u003c/p\u003e\n"],["\u003cp\u003eBest 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.\u003c/p\u003e\n"],["\u003cp\u003eWhen seeking explanations, migration plans, or error insights, leveraging the chat feature for conversations within the context of the codebase is recommended.\u003c/p\u003e\n"]]],[],null,["# Use Gemini Code Assist code customization\n\n| **Note:** Gemini Code Assist code customization is available only in Gemini Code Assist Enterprise. For more information, see [Gemini Code Assist supported features](/gemini/docs/codeassist/overview#supported-features).\n\nThis document describes how to use\n\n[Gemini Code Assist code customization](/gemini/docs/codeassist/code-customization-overview)\n\nand provides a few best practices. This feature lets you receive code\nrecommendations, which draw from the internal libraries, private APIs, and the\ncoding style of your organization.\n\nBefore you begin\n----------------\n\n1. [Set up Gemini Code Assist](/gemini/docs/discover/set-up-gemini) with an [Enterprise subscription](/gemini/docs/codeassist/overview#supported-features).\n2. [Set up Gemini Code Assist code customization](/gemini/docs/codeassist/code-customization-console).\n\nHow to use code customization\n-----------------------------\n\nThe following table lists ways to use\nGemini Code Assist code customization:\n\nUse cases and prompt examples\n-----------------------------\n\nThe following table provides guidance and examples about using\ncode customization in specific use cases:\n\nBest practices\n--------------\n\n- **Use relevant variable and function names or code snippets.** This guides code customization towards the most pertinent code examples.\n- **Use index repositories that you want to scale, and avoid adding deprecated\n 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.\n- **For code retrieval use cases, use code generation functionality instead of\n code completion** . Prompt using language such as \"Using the definition of \u003cvar translate=\"no\"\u003eFUNCTION_NAME\u003c/var\u003e, generate the exact same function,\" or \"Generate the exact implementation of \u003cvar translate=\"no\"\u003eFUNCTION_NAME\u003c/var\u003e.\"\n- **Have includes or imports present in the file for the code that you want to\n retrieve** to improve Gemini contextual awareness.\n- **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.\n- **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.\n- **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.\n- **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.\n\n### **Get more relevant suggestions with remote repository context**\n\nYou can get more contextually aware and relevant code suggestions by directing Gemini Code Assist to focus on specific remote repositories. By using the \u003ckbd\u003e@\u003c/kbd\u003e symbol in the chat, you can select one or more repositories to be used as a primary source of context for your prompts. This is useful when you are working on a task that is mostly related to a specific set of microservices, libraries, or modules.\n\nTo use a remote repository as context, follow these steps in your IDE's chat:\n\n1. Start your prompt with the \u003ckbd\u003e@\u003c/kbd\u003e symbol. A list of available remote repositories that are indexed will appear.\n2. Select the repository you want to use for context from the list. You can also start typing the repository name to filter the list.\n3. After selecting the repository, write the rest of your prompt.\n\nGemini will then prioritize the selected repository when generating a response.\n\n#### **Example Prompts**\n\nHere are some examples of how you can use this feature:\n\n- **To understand a repository:**\n - \"\u003ckbd\u003e@\u003c/kbd\u003e\u003cvar translate=\"no\"\u003eREPOSITORY_NAME\u003c/var\u003e What is the overall structure of this repository?\"\n - \"\u003ckbd\u003e@\u003c/kbd\u003e\u003cvar translate=\"no\"\u003eREPOSITORY_NAME\u003c/var\u003e I'm a new team member. Can you give me an overview of this repository's purpose and key modules?\"\n- **For code generation and modification:**\n - \"\u003ckbd\u003e@\u003c/kbd\u003e\u003cvar translate=\"no\"\u003eREPOSITORY_NAME\u003c/var\u003e Implement an authentication function similar to the one in this repository.\"\n - \"\u003ckbd\u003e@\u003c/kbd\u003e\u003cvar translate=\"no\"\u003eREPOSITORY_NAME\u003c/var\u003e Refactor the following code to follow the conventions in the selected repository.\"\n - \"\u003ckbd\u003e@\u003c/kbd\u003e\u003cvar translate=\"no\"\u003eREPOSITORY_A_NAME\u003c/var\u003e How can I use the latest functions from this repository to improve my code in \u003cvar translate=\"no\"\u003eREPOSITORY_B_NAME\u003c/var\u003e?\"\n- **For testing:**\n - \"\u003ckbd\u003e@\u003c/kbd\u003e\u003cvar translate=\"no\"\u003eUNIT_TEST_FILE_NAME\u003c/var\u003e Generate unit tests for \u003cvar translate=\"no\"\u003eMODULE\u003c/var\u003e based on the examples in the selected file.\"\n\nBy using remote repositories as a focused source of context, you can get more accurate and relevant suggestions from Gemini Code Assist, which can help you code faster and more efficiently."]]