Skip to main content

Gemini Code Assist: A Guide With Examples

Learn how to install and use Google’s Gemini Code Assist in Visual Studio Code, with Python examples.
Mar 4, 2025  · 12 min read

There’s been a rise in open-source models lately, and, when it comes to code editing, players like Cursor AI and GitHub Copilot let users try their AI code assistants for free, but we quickly hit the paywall when using them to build any real project.

Gemini Code Assist, Google's AI code assistant, just got its own very generous free tier. It comes in the form of Visual Studio Code and JetBrains extensions. 

In this tutorial, we learn how to set it up on Visual Studio Code and how to use it with several practical examples.

Develop AI Applications

Learn to build AI applications using the OpenAI API.
Start Upskilling For Free

What Are AI Code Assistants?

AI code assistants use AI to help developers code more efficiently by suggesting code snippets, automating repetitive tasks, and providing real-time corrections in coding environments like Visual Studio Code. This lets developers spend less time on routine tasks and more on complex and creative work.

While chatbots can assist with coding tasks, they can be cumbersome to use because they require switching back and forth between the IDE and the AI platform, involving a lot of copying and pasting of code.

AI code assistants integrate directly into the coding environment. This allows them to be aware of our coding context and avoid having to explicitly provide code snippets when we ask questions. This also gives the code assistants the ability to directly modify the code, making it much faster to integrate changes.

How to Install Gemini Code Assist?

In this tutorial, we'll use Gemini Code Assist together with Visual Studio Code. Gemini Code Assist is a Visual Studio extension, so we can install it as we would any other extension:

  1. Click on the extensions tab on the left panel.
  2. Type "gemini code assist" in the search box.
  3. Click the "Install" button.

Installing Gemini Code Assist on Visual Studio Code

Once installed, the Gemini tab will appear on the left panel. To start using the code assistant, click on that tab with the Gemini logo and sign in to your Google account.

Activating Gemini Code Assist

Testing Gemini Code Assist

To test Gemini Code Assist, I decided to analyze a recent dataset of Spotify songs using Python. The dataset I used was from Kaggle and is available here.

To get started, create a folder and extract the songs.csv file into that folder. Then open the folder in Visual Studio Code. The plan is to start with no code and have Gemini Code Assist write everything for us.

Getting started

The first prompt I sent asked to create a Python function that loads the data into a pandas DataFrame.

First prompt for Gemini Code Assist on Visual Studio Code

Usually, the code assistant works by modifying existing code and showing us a diff with the new changes. Since there's no code yet in this case, we can ask it to create a new file with the proposed code by clicking the last button at the top right corner of the code close in the chat window.

Creating a new file from a given code snippet in Visual Studio Code

We then rename the file to songs.py.

Running the code

We can run the code using the integrated terminal in Visual Studio Code with the command:

python songs.py

In this case, we get an error:

ModuleNotFoundError: No module named 'pandas'

This is because the songs.py script is trying to use pandas, which isn't installed. This is a perfect opportunity to check if Gemini Code Assist is aware of the terminal inside Visual Studio Code or not.

I asked it to explain how to fix the error in the terminal. Unfortunately, it gave a generic answer showing that it didn't have the ability to access the terminal output. The alternative is to copy and paste the error text into the AI chat, which is a bit more cumbersome. But sure enough, doing so we get the correct answer that we need to run the command pip install pandas in the terminal.

This is an unfortunate limitation because, as a software engineer, asking questions about an error I see in the terminal is one of the most common cases where I use AI.

After installing pandas, we can successfully run the code.

Result of the first code run

Asking generic questions

Gemini Code Assist isn't limited to coding questions. We can also ask generic questions or data-related questions. Let's try to get an idea of the data we have in the songs.csv file by asking it to list all columns:

prompt for gemini code assist

In the answer, it created a function that lists the columns, but it also showed a list directly in the answer:

List of columns in the songs.csv file

Often, when using Gemini Code Assist, it seemed like it had some trouble distinguishing when I was asking a generic question that only warrants a textual answer from when I wanted it to write code. This is a minor problem because we can ignore the code part, but it does clutter the chat quite a bit.

Asking for new functionality

From the previous answer, we see that there's a track_popularity column. Let's ask Gemini Code Assist to implement a new function that gets the most popular song.

prompt for gemini code assist

When Gemini Code Assist writes code in the answer, the function doesn't automatically get integrated into our code. To do so, we click on the double arrow button "Diff with Open File." Make sure that, before clicking, the file to which the changes belong is the currently opened file in the editor; otherwise, the changes will be merged into the wrong file.

How to see the diff in gemini code assist

After pressing the button, we're presented with a diff. On the left we see the current state of the code and on the right the new state. Lines highlighted in red represent lines that will be deleted or changed while lines highlighted in yellow are the additions or changes.

Diffs in gemini code assist

We can look at the scrollbar on the right to locate these changes. Often, several locations in the file require changes, and it's important to take a look at all of them before accepting the changes.

Diff locations

By hovering over a change, we see an arrow in the middle:

diffs in gemini code assist

I find the icon unintuitive, but clicking this arrow will specify that we don't want to include that specific change. After deciding which one we want, we can incorporate the new code by clicking the "Accept” button at the top.

Integrating the changes

Autocomplete

So far, we've been interacting with Gemini Code Assist using the AI chat. This is already a much better workflow than having to copy and paste code back and forth between an AI platform and the code editor because everything is integrated in the same window and we see the diff, which makes it easy to see the new changes. However, that's not all Code Assist can do.

While we write code, the assistant will analyze what we're writing and provide code suggestions that can be integrated with the press of a button.

The track_popularity column in the dataset stores the popularity of a track. Let's write a function that displays the popularity of the songs by a given artist, sorted by their release date. We can use the track_album_release_date to sort.

As we write the function, Gemini Code Assist will suggest auto-completions. When we start writing the function signature, Gemini Code Assist will guess what we want from the function name:

Autocomplete example in gemini code assist

To incorporate a suggestion, we simply press the Tab key on the keyboard. Next, we want to create a copy of the DataFrame containing only the songs from the given artist:

Autocomplete example in gemini code assist

Sometimes, the code suggestion isn't what we want. In this case, we still need to manually write what we want or, if it's close enough, accept it and then edit it. In this example, the next step is to convert the track_album_release_date into a date format. However, for some reason, Gemini Code Assist wants to only get the release year, so I wrote the line manually.

Autocomplete fail in gemini code assist

Next, I want to sort the songs by date:

Autocomplete example in gemini code assist

Finally, I return the popularity scores:

Autocomplete example in gemini code assist

Targeting specific code

We can target specific code by first selecting it in the editor. When code is selected, a few automatic prompts will be suggested, such as "Explain this" or "Generate unit tests."

Prompt suggestions for selected code in gemini code assist

Being able to select a code snippet and ask what it does or how it works is very useful when getting into a new codebase. I found that this is often the hardest step when working on a new product with an existing codebase.

We can also ask it to modify the code with a custom prompt. For example, we can ask it to improve the analyze_artist_popularity_over_time() function we just created:

custom prompt in gemini code assist

In this case, it improved the function by adding some checks to prevent errors.

Free Plan Limitations 

The free plan of Gemini Code Assist for individuals has some limitations when compared to the Standard and Enterprise plans:

  • Limited customization and integration: The free plan does not allow you to connect your private source code repositories for customized code suggestions, which is available in the Enterprise plan.
  • Feature access: Certain advanced features in Gemini for Firebase and Apigee, as well as advanced AI-assisted automation in Application Integration, are available only in the Standard and Enterprise plans.
  • Security and compliance: The free plan lacks enterprise-grade security features and management tools, as well as IP indemnification, which are included in the Standard and Enterprise offerings.
  • Operational limits: The free plan offers a daily limit of 6,000 code-related requests and 240 chat requests, which may be sufficient for individual use but could be limiting for larger team projects.
  • Enterprise features and support: Enterprise context features for API creation and advanced app quality analysis is not available in the free plan.

For more details, check out Gemini Code Assist’s website.

My Impressions On Gemini Code Assist

I found Gemini Code Assist works quite well overall. In my experience, it performed similarly to its main competitors, Cursor and Copilot. It's really impressive for a free tool. The free tier supports up to 6,000 code-related requests and 240 chat requests every day. This should be more than enough for most programmers.

Another interesting feature we didn't cover here is their GitHub integration. Gemini Code Assist for GitHub helps by reviewing pull requests to find bugs and style issues and suggesting code changes and fixes automatically. This allows developers to focus more on writing code. If help is needed, users can ask Gemini by leaving a comment in their pull request.

One issue I found is that it seems to struggle a bit with past requests. I often found myself asking for some changes and then deciding to go in a different direction. However, in later iterations, it would keep wanting to integrate those changes. One such example was the function we wrote to display the popularity of a track over time. Initially, I wanted to make a plot with this data and then changed my mind. However, the code to plot that data kept being added to future unrelated requests, which was a bit annoying.

Dangers Of Code Assistants

Recently, I’ve seen more programmers express concerns, such as in this Reddit thread, about how using code assistants like Cursor or Copilot is slowly making them forget how to write code.

There’s no doubt that these tools provide incredible productivity boosts and not using them is putting us at a disadvantage relative to our peers. However, I think everything in life requires a balance, and when it comes to AI coding tools, it’s easy to fall into the trap of blindly accepting the code we’re given. At a minimum, we should take the time to read and understand what it generates.

Using code completion also seems like a better middle-ground because we at least need to start writing something to help retain muscle memory and prevent programmers from relying too much on AI tools. Code completion also tends to provide smaller chunks of code, making it easier to digest.

Conclusion

AI tools keep evolving, with costs decreasing and accessibility expanding. Gemini Code Assist exemplifies this trend by offering a robust AI code assistance tool for free.

This initiative from Google lowers the barrier to entry for developers, allowing virtually anyone to use powerful AI assistance in their coding tasks. It's particularly commendable that Gemini Code Assist provides features that are on par with, or even competitive with, paid services such as Cursor and Copilot. With up to 6,000 code-related requests and 240 chat requests available daily, it offers more than enough support for individual developers or small projects.


François Aubry's photo
Author
François Aubry
LinkedIn
Teaching has always been my passion. From my early days as a student, I eagerly sought out opportunities to tutor and assist other students. This passion led me to pursue a PhD, where I also served as a teaching assistant to support my academic endeavors. During those years, I found immense fulfillment in the traditional classroom setting, fostering connections and facilitating learning. However, with the advent of online learning platforms, I recognized the transformative potential of digital education. In fact, I was actively involved in the development of one such platform at our university. I am deeply committed to integrating traditional teaching principles with innovative digital methodologies. My passion is to create courses that are not only engaging and informative but also accessible to learners in this digital age.
Topics

Learn AI with these courses!

track

Developing AI Applications

23hrs hr
Learn to create AI-powered applications with the latest AI developer tools, including the OpenAI API, Hugging Face, and LangChain.
See DetailsRight Arrow
Start Course
See MoreRight Arrow
Related

tutorial

Gemini 2.0 Flash: Step-by-Step Tutorial With Demo Project

Learn how to use Google's Gemini 2.0 Flash model to develop a visual assistant capable of reading on-screen content and answering questions about it using Python.
François Aubry's photo

François Aubry

12 min

tutorial

Imagen 3: A Guide With Examples in the Gemini API

Learn how to generate images using Google’s Imagen 3 API with Python, including setting up your environment and adjusting options like aspect ratio and safety filters.
François Aubry's photo

François Aubry

12 min

tutorial

How to Use GitHub Copilot: Use Cases and Best Practices

Explore how GitHub Copilot works with Visual Studio Code. Learn about its features, pricing, and practical applications for students and developers.
Eugenia Anello's photo

Eugenia Anello

8 min

tutorial

Introducing Google Gemini API: Discover the Power of the New Gemini AI Models

Learn how to use Gemini Python API and its various functions to build AI-enabled applications for free.
Abid Ali Awan's photo

Abid Ali Awan

13 min

tutorial

Gemini 1.5 Pro API Tutorial: Getting Started With Google's LLM

To connect to the Gemini 1.5 Pro API, obtain your API key from Google AI for Developers, install the necessary Python libraries, and send requests and receive responses from the Gemini 1.5 Pro model.
Natasha Al-Khatib's photo

Natasha Al-Khatib

8 min

tutorial

ChatGPT Desktop: A Guide With VS Code and Terminal Examples

Learn how to optimize your coding workflow using the ChatGPT desktop app, with a focus on its integration with VS Code, the terminal, and Xcode.
François Aubry's photo

François Aubry

8 min

See MoreSee More