All Collections
Enterprise
OverflowAI
Explain Code with the Visual Studio Code Integration
Explain Code with the Visual Studio Code Integration

Use the OverflowAI Visual Studio Code Integration to explain, optimize, and debug code.

Joel Bradley avatar
Written by Joel Bradley
Updated over a week ago

Applies to: Enterprise

This documentation is for Stack Overflow Enterprise. Free, Basic, and Business users can access their documentation here. Find your plan.


Overview

This module is included in the OverflowAI add-on. If you're ready to elevate and enhance your team's capabilities with OverflowAI, reach out to our sales team today.

The Explain Code module of the Stack Overflow for Microsoft Visual Studio Code (VSC) extension can help you understand small code snippets—or even entire blocks of code—directly in your IDE. Explain Code accesses data from the internet (including the vast repository of questions and answers at www.stackoverflow.com) to provide explanations, insights, and solutions related to the code you're working on.

The Explain Code module leverages many technologies to give you the answers you need: code analysis, intelligent query generation, Stack Overflow's API, language processing, machine learning models, IDE integration, and more.

NOTE: Before you can use the OverflowAI Explain Code module, you must first install the Stack Overflow for Teams Visual Studio Code extension by following these instructions. Your Stack Overflow site must also have Unified Search enabled.

Use the Explain Code module

First, open your VSC project. Depending on your extension version and type of code you've selected, you may see Explain links above definitions, classes, functions, methods, and other large code structures.

To have the Stack Overflow VSC extension explain any of these blocks, click Explain.

You can also select a block of code for the extension to explain. After you select a block of code, look for a yellow light bulb button.

Click the yellow light bulb and select Explain from the "More Actions…" menu. You can also bring up the "More Actions..." menu by pressing CTRL-. or OPTION-. (period) on your keyboard. Finally, you can use VSC's command palette to access the Explain Code module. Select the code and right-click on it. Select Command Palette, then enter "ide-ext.explainCode".

View the code explanation

After you start the code explanation process, the IDE extension searches Stack Overflow for relevant discussions, answers, and explanations related to the code. It then uses AI to generate a concise, accurate explanation of the code. You'll see the code explanation in VSC's left-hand column.

Sometimes you'll see the extension's comments after your source code block, as below.

Other times you'll see the extension's comments inside the source code block, after the code.

The Explain Code results area is a running transcript, allowing you to scroll back to view previous interactions with the AI. You can also enter additional questions and commands into the "What would you like to know?" box at the bottom of the transcript. Since the Explain Code function relies on data from the whole internet, be sure to leave the chat box's scope setting at All for any follow-up questions.

If the result of your AI search is an answer that will benefit your community, the Draft Article module makes it easy to create a new Stack Overflow for Teams article based on the conversation (learn more).

When to use the Explain Code function

Learning
If you're learning a new programming language or concept, use the Explain Code module on snippets of code to reinforce your understanding and provide explanations.

Understanding a new library or framework
When you're integrating a new library or framework into your project and you're not sure how certain functions or methods work, use the Explain Code module to provide examples and explanations.

Example prompt: Give me examples of the SymPy library in Python.

Optimization
When you're looking to optimize a piece of code for performance or efficiency, use the Explain Code module to provide insights into best practices and alternative approaches from other developers.

Example prompt: Optimize this code.

Code review
If you come across a piece of code that seems unfamiliar or overly complex during a code review, use the Explain Code module to help you understand its purpose and functionality without interrupting the flow of your review.

Debugging
If you encounter an error or unexpected behavior in your code, highlight the problematic code and use the Explain Code module to find similar issues and relevant solutions. You can also use the Stack Overflow Error Code Search module.

Example prompt: Debug this code.

NOTE: While the Explain Code module can be a time-saver, carefully evaluate all suggestions and solutions to ensure they fit with your specific project requirements and coding standards.


If you need further support or have questions, contact your site administrator.

Did this answer your question?