A powerful Visual Studio Code extension that leverages Ollama AI models to analyze, explain, and provide enhancement suggestions for your code directly within your IDE.
- Explain Code: Get detailed explanations of selected code snippets in natural language
- Enhancement Suggestions: Receive AI-powered recommendations to improve code quality, performance, and best practices
- Dedicated sidebar panel with an intuitive interface
- Real-time streaming responses for faster feedback
- Collapsible sections for better organization
- Markdown rendering with syntax highlighting
- Support for multiple Ollama models
- Works with any programming language supported by VS Code
- Automatically detects the language of selected code
- Context-aware explanations based on language syntax
Before using this extension, you need to have:
-
Ollama installed on your system
- Download from ollama.ai
- Ensure Ollama service is running
-
At least one Ollama model downloaded
- Example:
ollama pull codellama - Recommended models for code analysis:
codellama- Meta's code-specialized LLMdeepseek-coder- Excellent for code understandingphind-codellama- Fine-tuned for coding tasksmistral- General-purpose with good code capabilities
- Example:
- Download the
.vsixfile - Open VS Code
- Go to Extensions view (
Ctrl+Shift+X/Cmd+Shift+X) - Click the
...menu at the top of the Extensions view - Select "Install from VSIX..."
- Choose the downloaded
.vsixfile
- Clone this repository
- Run
npm installto install dependencies - Run
npm run compileto build the extension - Press
F5to open a new VS Code window with the extension loaded
- Click on the Ollama icon in the Activity Bar (left sidebar)
- The "Code Explainer" panel will open
- Select Code: Highlight the code you want to analyze in any file
- Choose Model: Select an Ollama model from the dropdown in the panel
- Select Mode:
- Explain Code: Get a detailed explanation of what the code does
- Suggest Enhancements: Receive recommendations for improvements
- Analyze: Click the "Analyze Selected Code" button
- View Results: The analysis will stream in real-time in the panel
You can also use the Command Palette:
- Press
Ctrl+Shift+P/Cmd+Shift+P - Type "Explain Code with Ollama"
- Press Enter (make sure code is selected first)
The extension uses streaming responses from Ollama, providing instant feedback as the AI generates the analysis. No more waiting for the entire response to complete!
All responses are rendered as markdown with:
- Syntax-highlighted code blocks
- Formatted headers and lists
- Tables and blockquotes
- Inline code formatting
- Selected Code: View the code being analyzed with syntax highlighting
- Analysis Result: Expandable/collapsible sections keep your workspace organized
- Dynamically loads all available Ollama models
- Refresh models without restarting VS Code
- Remembers your last selected model
- Ensure Ollama is installed and running
- Check if Ollama service is accessible at
http://localhost:11434 - Verify you have at least one model installed:
ollama list
- Click the "Refresh Models" button in the panel
- Ensure at least one model is installed via
ollama pull <model-name>
- Make sure you have selected code in the active editor
- Verify the selected model is available and running
- Check VS Code's Output panel (View � Output � Ollama Code Explainer) for errors
Currently, the extension works with default Ollama settings. Future versions will include:
- Custom Ollama API endpoint configuration
- Temperature and other model parameter controls
- Custom prompt templates
- History of previous analyses
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Watch mode for development
npm run watch
# Run tests
npm test- VS Code version
^1.105.0or higher - Ollama service running locally
- Node.js for development
Contributions are welcome! Please feel free to submit issues or pull requests.
- Add support for custom prompts
- Implement analysis history/cache
- Add more analysis modes (debug, optimize, document)
- Support for remote Ollama instances
- Integration with other AI providers
- Large code selections may take longer to analyze
- Requires Ollama to be running locally (no cloud support yet)
- Initial release of VS Code Code Suggest and Explaining Extension
- Code explanation with Ollama integration
- Enhancement suggestions mode
- Real-time streaming responses
- Markdown rendering with syntax highlighting
- Multi-model support
- Interactive webview panel
If you encounter any issues or have feature requests, please file an issue on the GitHub repository.
Enjoy enhanced code understanding with AI-powered analysis!