Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Code2AssistNew to Visual Studio Code? Get it now.
Code2Assist

Code2Assist

kr

|
4 installs
| (0) | Free
Refactor, explain, or generate unit tests for selected code using a tiny local LLM via Python.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

🚀 Code2Assist

A powerful VS Code extension that leverages Phi-3 (an advanced local LLM) to enhance your coding experience with AI-powered code explanations, refactoring, and test generation.


✨ Features

  • 🔍 Code Explanation: Get detailed explanations of selected code blocks to understand complex logic
  • ♻️ Intelligent Refactoring: Automatically improve code quality, readability, and performance
  • 🧪 Test Generation: Create comprehensive unit tests for your code with a single click
  • 🧠 Fully Local AI: Runs entirely on your machine with no data sent to external servers
  • 🖥️ GPU Acceleration: Utilizes CUDA for faster processing when available
  • 🔋 Automatic Environment Setup: Handles all dependencies in an isolated virtual environment

🛠️ Installation

  1. Install the extension from the VS Code Marketplace.
  2. The extension will automatically set up its Python virtual environment and download the required models on first use.
  3. If you have a CUDA-capable GPU, the extension will detect and use it automatically.

📋 Requirements

  • VS Code: 1.60.0 or higher
  • Python: 3.8 or higher (system installation required)
  • Storage: At least 3GB free disk space for model files
  • RAM: Minimum 8GB (16GB+ recommended)
  • GPU: NVIDIA GPU with CUDA support (optional, but recommended for better performance)

🚦 Usage

🧠 Code Explanation

  • Select code you want to understand.
  • Right-click and select "Code2Assist: Explain Code" or use the command palette.
  • View the detailed explanation in a new panel.

♻️ Code Refactoring

  • Select code you want to refactor.
  • Right-click and select "Code2Assist: Refactor Code" or use the command palette.
  • The selected code will be replaced with the improved version.

🧪 Test Generation

  • Select code you want to write tests for.
  • Right-click and select "Code2Assist: Generate Tests" or use the command palette.
  • The tests will be added after your selected code.

💡 Commands

  • Code2Assist: Explain Code – Explain selected code
  • Code2Assist: Refactor Code – Refactor selected code
  • Code2Assist: Generate Tests – Generate unit tests for selected code
  • Code2Assist: Check Dependencies – Verify all required dependencies are installed
  • Code2Assist: Run GPU Diagnostics – Check CUDA support and GPU capabilities
  • Code2Assist: Reset Environment – Reset the Python virtual environment if issues occur

🛠️ How It Works

Code2Assist uses Microsoft's Phi-3-mini-4k-instruct model, a powerful yet efficient LLM designed specifically for code understanding and generation. The extension:

  • Runs the model locally using the Hugging Face Transformers library
  • Creates task-specific prompts based on your selected code
  • Processes the model's output to provide useful, contextual results
  • Manages all dependencies in an isolated Python virtual environment

🛟 Troubleshooting

GPU Not Detected

  • Run Code2Assist: Run GPU Diagnostics to see detailed information
  • Ensure you have the latest NVIDIA drivers installed
  • Check if CUDA is properly set up on your system
  • You can force GPU usage in settings if detection fails

Dependency Issues

  • Run Code2Assist: Check Dependencies to verify the environment
  • If issues persist, use Code2Assist: Reset Environment to rebuild the virtual environment
  • Check the output panel for specific error messages

⚡ Performance Optimization

  • For faster processing, ensure you have a CUDA-capable GPU
  • Close other GPU-intensive applications when using the extension
  • Consider adjusting the maximum token length in settings for quicker responses

⚙️ Configuration

Configure Code2Assist through VS Code settings:

  • code2assist.useGPU: Enable/disable GPU acceleration (default: true if available)
  • code2assist.maxTokens: Maximum token length for generated content (default: 1024)
  • code2assist.forceGpuUsage: Force GPU usage even if auto-detection fails (default: false)

🔒 Privacy & Security

Code2Assist processes all code locally on your machine. No data is sent to external servers, ensuring:

  • Complete privacy of your code
  • Ability to work in air-gapped environments
  • No dependency on internet connectivity for core functionality

📄 License

MIT License


🙏 Acknowledgements

  • Microsoft Phi-3 Model
  • Hugging Face Transformers

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


💬 Feedback & Support

If you encounter any issues or have suggestions for improvements, please open an issue on the GitHub repository.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft