Skip to content
| Marketplace
Sign in
Visual Studio>Tools>AI Studio
AI Studio

AI Studio

Emrah KONDUR

|
25,852 installs
| (7) | Free
Supercharge your Visual Studio workflow with AI-powered code generation, refactoring, documentation, and unit test creation. Analyze C# code and its solution dependencies for potential performance bottlenecks and security risks, with actionable recommendations, all from the ri...
Download

AI Studio

AI Studio is a Visual Studio 2022, 2026 extension that adds AI-assisted code generation, refactoring, documentation, testing, and security analysis to the IDE directly from the context menu.

  • Download from Visual Studio Marketplace
  • Report an issue or request a feature
image

Table of Contents

  • Highlights
  • Requirements
  • Installation
  • Quick Start
  • Command Cheat Sheet
  • Feature Walkthrough
  • Configuration
  • Advanced Customization
  • Troubleshooting and Feedback
  • License

Highlights

  • Seamless right-click workflow across C#, XAML, and most text-based files inside Visual Studio.
  • Supports OpenAI, Azure AI, Anthropic (Claude), and Ollama (local or cloud) — switch provider from the Options page.
  • Generates or updates code while preserving formatting, documentation, and project conventions.
  • Built-in commands for documentation, explanations, security review, and unit test creation keep teams in flow.
  • Integrated Output tool window supports follow-up chat, a dedicated New Chat command, and smooth streaming updates without focus jumps.

Requirements

  • Visual Studio 2022 17.10 or later with the VSIX extension workload installed. The extension uses the host's Roslyn 4.10+ workspace APIs for dependency analysis.
  • An API key for your chosen provider (not required for local Ollama) with network access from the IDE.
  • .NET Framework 4.8 SDK (installed with Visual Studio) for local builds.

Installation

Marketplace (recommended)

  1. Open Visual Studio and choose Extensions > Manage Extensions.
  2. Search for AI Studio.
  3. Click Download and restart Visual Studio to complete the installation.

Build from source

  1. Clone or fork this repository.
  2. Open AI Studio.sln in Visual Studio 2022.
  3. Build the solution in Release mode.
  4. Double-click the generated .vsix under bin\Release to install it into your local instance.

Quick Start

  1. Choose a provider and obtain an API key if required (see the Provider Setup section below).
  2. Configure AI Studio via Tools > Options > AI Studio > General: set the AI Provider, paste the key, and enter the model or deployment name.
  3. Pick a feature (for example, Code It) by selecting code, right-clicking, and choosing the desired AI Studio command.

Configuration Screenshot

Provider Setup

AI Studio supports four providers out of the box. Switch between them at any time under Tools > Options > AI Studio > General.

OpenAI

Setting Value
AI Provider OpenAI
API Key Your key from platform.openai.com/account/api-keys
Language Model e.g. gpt-4o-mini, gpt-4o, o4-mini
API Endpoint https://api.openai.com/v1/ (default)

Azure AI

Use this provider for Azure AI Foundry or Azure OpenAI resources that expose the Azure openai/v1 endpoint.

Setting Value
AI Provider AzureAI
API Key Your key from the Azure portal or Azure AI Foundry
Language Model The Azure model or deployment name, e.g. gpt-4o-mini
API Endpoint e.g. https://your-resource.openai.azure.com/openai/v1/

Enter the Azure base URL only. AI Studio appends /chat/completions automatically.

Anthropic (Claude)

Setting Value
AI Provider Anthropic
API Key Your key from console.anthropic.com/settings/keys
Language Model e.g. claude-sonnet-4-6, claude-opus-4-6, claude-haiku-4-5
API Endpoint (not used — hardcoded to https://api.anthropic.com/v1/messages)

Ollama

Ollama can run models locally on your machine or via the Ollama cloud.

Local

Setting Value
AI Provider Ollama
API Key (leave empty)
Language Model e.g. llama3.2, mistral, codestral
API Endpoint http://localhost:11434

Pull a model first with ollama pull llama3.2, then start Ollama before using AI Studio commands.

Cloud

Setting Value
AI Provider Ollama
API Key Your key from ollama.com (if required)
Language Model e.g. mistral, llama3.2
API Endpoint https://ollama.com

AI Studio uses Ollama's native /api/chat endpoint. The endpoint field should be the base URL only — do not include /api or any path suffix.

Using Any Other OpenAI-Compatible Endpoint

Select OpenAI as the provider and change the API Endpoint to your private or self-hosted URL (e.g. https://llm.internal/api/v1). Enter the API key issued by that gateway and set the appropriate model name.

Review context menu responses in Chat

All context menu commands show their responses in the Chat window first. No setting is required, and files stay unchanged until you choose to apply a result. This works with every provider, including local Ollama.

  • Replace Selection is available for Add Summary, Add Comments, and Refactor.
  • Insert into Editor is available for Code It and inserts after the original selection.
  • Copy is available for all responses, including explanations, security reviews, and unit tests.

Editor actions open a diff preview with Apply and Cancel. They target the original file and selection even after you switch editors. If that selection has changed or its editor has closed, run the command again. Cancelled, failed, or empty responses cannot be applied. Follow-up questions retain the original code and command context.

Command Cheat Sheet

Command When to use Output
Code It Turn TODOs or signatures into working code. Shows an implementation in Chat with an insert action.
Add Comments Document existing logic without manual XML comments. Adds inline comments or summaries.
Add Summary Produce XML doc comments for public APIs. Generates <summary> and related tags.
Refactor Improve readability or performance of selected code. Shows an optimized version in Chat with a replace action.
Explain Understand unfamiliar code quickly. Displays a plain-language explanation.
Security Check Inspect code and, for loaded C# projects, dependencies and upstream callers. Shows security findings with evidence, confidence, existing mitigations and suggested fixes.
Analyze Performance Review selected C# code and its solution dependencies for potential runtime bottlenecks. Shows evidence, confidence, suggested fixes, and analysis coverage in Chat.
Add Unit Tests Generate unit tests tailored to the selected method. Creates a new test class or method snippet.
New Chat Start a clean conversation without selecting code. Opens the AI Studio response window with an empty chat.

Feature Walkthrough

Code It

  1. Place the caret on an empty method or select a stub.
  2. Right-click and choose AI Studio > Code It.
  3. Review the generated implementation and accept or adjust as needed.

Add Comments

  1. Highlight the code you want documented.
  2. Run AI Studio > Add Comments.
  3. Review the commented code in Chat, then choose Replace Selection to preview and apply it.

Refactor

  1. Select a method or block.
  2. Choose AI Studio > Refactor.
  3. Compare the result with the original and apply the pieces you want to keep.

Add Summary

  1. Select a method header or type declaration.
  2. Run AI Studio > Add Summary.
  3. Review the documented code in Chat, then choose Replace Selection to preview and apply it.

Explain

  1. Highlight unfamiliar code.
  2. Choose AI Studio > Explain.
  3. Read the explanation in Chat and ask follow-up questions.

New Chat

  1. Right-click in the editor and choose AI Studio > New Chat.
  2. AI Studio opens the response window with an empty conversation.
  3. Type a question in the input bar and press Enter to send.

Security Check

  1. Select code that handles I/O, crypto, or user data.
  2. Run AI Studio > Security Check.
  3. For C# code in a loaded solution, AI Studio collects referenced source dependencies and searches up to two caller levels above the selected declarations. Calls through interface/base contracts are labeled as possible dispatch paths. Related method, partial/containing-type and base-declaration attributes are included with source locations where available.
  4. Review scope, prioritized findings, file/line evidence, relevant call paths, existing mitigations, exploitation assumptions and suggested fixes in Chat. Follow-up questions retain the collected context. Stop or Esc cancels collection or the AI response.

Security Check shares the bounded source collector used by Analyze Performance (five outgoing dependency levels, 80 declarations, 80,000 source-context characters, 6,000 examined references and 30 seconds overall). Caller discovery has a separate budget of 24 symbol queries, up to 24 caller declarations within the shared limit, and up to 10 seconds within the overall deadline. Attributes are bounded separately within the source-context budget. Any exhausted limits are reported in the context supplied to the AI.

This is an AI-assisted static review, not complete taint analysis or a guarantee that the application is secure. Collected guards and attributes must be assessed in context; neither attribute presence nor missing local checks alone establish whether an operation is protected. Middleware, global filters, authorization policies, routing and deployment configuration are not exhaustively collected.

Other languages and files outside a loaded C# project retain selection-only security review, explicitly identified as such. The selected code and any collected dependency/caller source are sent to the configured AI provider. Suggested changes are shown in Chat for review and copying; they are not applied automatically. Additional instructions remain configurable under Tools > Options > AI Studio > Commands > Security Check.

Analyze Performance

  1. Open a C# file in a loaded solution and select a method or code block (or place the caret inside a method).
  2. Choose AI Studio > Analyze Performance.
  3. AI Studio follows resolved method, constructor, property, field, and event references in the solution. It also collects possible interface implementations and virtual overrides, distinguishing them from known runtime targets.
  4. Review findings in Chat: severity, confidence, file/line evidence, conditions under which the issue matters, suggested code changes, and how to validate them. Follow-up questions retain the collected context. Use Stop or Esc to cancel collection or the AI response.

This is static analysis, not a benchmark. It does not execute your code or produce measured speedups. Suggestions are shown for review and copying; this command does not apply edits automatically.

The analysis uses the current editor snapshot, including unsaved changes, and sends the selected code plus collected dependency source to your configured AI provider. Collection runs in the background and is bounded to five dependency levels, 80 declarations, 80,000 source-context characters, 6,000 examined symbol references, and 30 seconds. Selections larger than 40,000 characters must be narrowed. When limits are reached, partial context and coverage limitations are supplied to the AI. It cannot inspect external service internals or unavailable package source, and reflection, delegates, dynamic dispatch, implicit compiler calls, and dependency-injection configuration may require manual investigation. It does not scan every member of every referenced type.

Customize additional instructions under Tools > Options > AI Studio > Commands > Analyze Performance.

Unit Test Generation

  1. Highlight a method to test.
  2. Run AI Studio > Add Unit Tests.
  3. For a loaded C# project, AI Studio searches the current solution snapshot for existing xUnit, NUnit or MSTest tests in that project and projects referencing it. Resolved references to the selected method/type rank above class-name matches and general project examples.
  4. AI Studio collects up to three reference test classes, their base-class chains (including partial declarations), constructors, setup/teardown code, fixture contracts, and referenced source helpers/builders. xUnit class fixtures and string-linked collection definitions in the test project are followed. Production dependencies are supplied separately.
  5. Review the reference classes, suggested destination and proposed tests in Chat. The generation instructions favor the chosen project's conventions, reuse accessible base-class members and existing factories/mocks, and avoid duplicating setup. Conflicting unit/integration infrastructure is presented as alternatives instead of being combined. Follow-up questions retain the collected context.

The output remains a reviewable code suggestion in Chat: this command does not insert tests, validate generated code or run tests. Framework/base-class choices made by the AI still require review. Test discovery requires resolved framework attributes; unloaded projects, missing references, custom frameworks, assembly-wide setup, global imports and external package implementations may limit the result. Other languages and files outside a loaded C# project keep selection-only generation.

Collection is bounded to 300 searched documents, three reference test classes, 24 source types, four infrastructure dependency levels, 12,000 examined symbol references, 48,000 test-source characters and 15 seconds. Production context has a separate budget of 32 declarations, 32,000 source-context characters and 15 seconds. Partial results and exhausted limits are reported to the AI. Stop or Esc cancels collection or streaming. Source collection never executes test setup or fixture code.

The selected code, collected production dependencies and test infrastructure source are sent to the configured AI provider. Disable Use Existing Test Context to send only the selection and configured instructions.

Test Configuration

Configure test generation under Tools > Options > AI Studio > Unit Test.

unit-test-ss
  • Use Existing Test Context enables solution-aware reference collection (on by default).
  • Preferred Test Project optionally restricts discovery to an exact loaded project name, such as MyApp.UnitTests. This helps separate unit and integration test infrastructure. A missing or unrelated project is reported rather than silently replaced.
  • Unit Testing Framework, Isolation Framework, Test/Dummy Data Framework and Assertion Framework are fallback preferences when the selected project's examples do not establish a convention.
  • Customize supplies explicit instructions, such as target project, naming rules or mocking preferences. These take precedence; conflicts with the existing project should be explained in the response.

Configuration

All configuration lives under Tools > Options > AI Studio:

  • General
    • Paste your API key, pick the default model, and decide whether to format AI changes automatically.
    • Toggle telemetry/diagnostics and adjust temperature or response size if needed.
  • Commands
    • Override the system prompt for each command, enforce coding guidelines, or switch to a custom model per command.
  • Unit Test
    • Configure existing-test discovery, a preferred test project, fallback frameworks and reusable custom instructions.

Advanced Customization

  • Custom prompts per command: Tailor Refactor to focus on performance while Configure Comments to prioritize XML docs using Tools > Options > AI Studio > Commands.
  • Bring your own endpoint: Point the extension at a private/self-hosted LLM gateway or any OpenAI-compatible proxy by entering the base URL and model ID in the General page.
  • Formatting control: Enable Format changed text to run Visual Studio formatting on every AI edit to keep diffs clean.
  • Response behavior: Decide whether AI should insert results inline, append to the Output window first, or prompt for confirmation.

Command Settings

Troubleshooting and Feedback

  • Verify your API key and quota if requests fail; the Output tool window surfaces errors returned by the provider.
  • Ensure Visual Studio can reach your provider endpoint (corporate proxies may need to allowlist it).
  • Capture screenshots/logs and open an issue for bugs or ideas.
  • Contributions are welcome via pull requests; please include before/after screenshots for UI tweaks.

License

AI Studio is released under the MIT License. Use it in personal or commercial projects with attribution.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft