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

CodeMentor

NikhilCodeMentor

|
4 installs
| (0) | Free
AI-powered Python code analysis and feedback using Hugging Face models
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

CodeMentor VS Code Extension

CodeMentor is an AI-powered VS Code extension that enhances Python coding with real-time feedback. Using Hugging Face's distilgpt2, it offers detailed code explanations (Ctrl+E), concise hints (Ctrl+Y), and automated solutions (Ctrl+Shift+S) for syntax errors and improvements. Feedback is saved to CodeMentor_Feedback.txt, making it ideal for learning and debugging.

Features

  • Explain Mode (Ctrl+E): Detailed explanations of your Python code, including functionality and potential improvements.
  • Hint Mode (Ctrl+Y): Concise hints to fix errors or optimize code without revealing the full solution.
  • Solution Mode (Ctrl+Shift+S): Corrected code with explanations for syntax errors or enhancements.
  • Set Hugging Face Token (Ctrl+Shift+T): Configure your Hugging Face API token for AI-powered feedback.
  • Flake8 Integration: Checks for PEP 8 style violations and suggests fixes via autopep8.

Screenshots

Solution Mode Solution Mode fixing a missing colon in test.py

Installation

  1. Install from Marketplace:

    • Search for CodeMentor in VS Code Extensions (Ctrl+Shift+X) or visit Visual Studio Marketplace.
    • Click Install.
  2. Set Up Python Environment:

    • Install Python 3.11 (recommended) or 3.13: Python Downloads.
    • Verify:
      python --version
      
    • Install dependencies:
      pip install watchdog flake8 requests autopep8 huggingface_hub transformers==4.44.2 torch
      
  3. Configure Hugging Face Token:

    • Get a token from Hugging Face Settings.
    • In VS Code, press Ctrl+Shift+T and enter your token.
    • Or set the environment variable:
      # Windows
      set HF_TOKEN=your_hf_token
      
  4. System Requirements:

    • ~2GB RAM for distilgpt2 (default model).
    • ~50GB RAM/GPU for mistralai/Mixtral-8x7B-Instruct-v0.1 (optional, edit mentor.py line 88).

Usage

  1. Open a Python file (e.g., test.py) in VS Code.
  2. Use these commands:
    • Ctrl+E: Explain code functionality and suggest improvements.
    • Ctrl+Y: Get a hint to fix or improve code.
    • Ctrl+Shift+S: Receive corrected code with an explanation.
  3. Feedback is saved to CodeMentor_Feedback.txt in the same directory as your Python file.

Example

For test.py:

def add(a, b)  # Missing colon
    return a + b
  • Solution Mode (Ctrl+Shift+S) output:
    Solution: Corrected code:
    ```python
    def add(a, b):
        return a + b
    
    Explanation: Added missing colon after the function definition.
    
    

Setting Up a GitHub Repository

To contribute, fork, or publish updates, set up a GitHub repository for the source code.

Prerequisites

  • Git: Install from Git and verify:
    git --version
    
  • Node.js: Install from Node.js and verify:
    node --version
    npm --version
    
  • VSCE: Install the VS Code Extension CLI:
    npm install -g vsce
    vsce --version
    
  • GitHub Account: Sign up at GitHub.

Steps to Create and Push to GitHub

  1. Navigate to Project Directory:

    cd "C:\Users\NIKHIL\OneDrive - South Indian Education Society\python practice\codebunny"
    
  2. Initialize Git Repository (if not already initialized):

    git init
    
  3. Create .gitignore: Create a .gitignore file to exclude unnecessary files:

    echo "node_modules/
    

*.vsix CodeMentor_Feedback.txt .vscode/ *.log" > .gitignore


4. **Fix Corrupted `README.md`**:
- If `README.md` contains `�` characters, open it in VS Code or a text editor (e.g., Notepad++).
- Ensure it’s saved in UTF-8 encoding:
  - In VS Code, click the encoding in the bottom-right (e.g., `UTF-16`) and select **Save with Encoding** > **UTF-8**.
- Replace with the content above or copy it manually.

5. **Add and Commit Files**:
Add all relevant files (`package.json`, `extension.js`, `mentor.py`, `README.md`, `LICENSE`, `images/codementor.png`):
```bash
git add .
git commit -m "Initial commit: Add CodeMentor extension files with corrected README"
  1. Create GitHub Repository:

    • Go to GitHub.
    • Set:
      • Repository Name: Code-Mentor
      • Description: AI-powered VS Code extension for Python code analysis
      • Visibility: Public (recommended) or Private
      • Initialize with README: Uncheck (you have your own README.md)
    • Click Create repository.
  2. Link and Push to GitHub:

    git remote add origin https://github.com/Rancidgift57/Code-Mentor.git
    git branch -M main
    git push -u origin main
    
  3. Update package.json: Ensure the repository field points to your GitHub URL:

    "repository": {
      "type": "git",
      "url": "https://github.com/Rancidgift57/Code-Mentor"
    }
    

    Commit if changed:

    git add package.json
    git commit -m "Update repository URL in package.json"
    git push origin main
    

Publishing to Visual Studio Marketplace

To publish version 0.0.3 with the corrected README.md and LICENSE:

  1. Resolve Git Working Directory Error: The npm version patch error (Git working directory not clean) from 6:59 PM IST, July 21, 2025, occurs due to uncommitted changes.

    • Check:
      git status
      
      Example output:
      Changes not staged for commit:
        modified:   README.md
        modified:   package.json
      Untracked files:
        LICENSE
        images/codementor.png
      
    • Commit:
      git add README.md LICENSE package.json images/codementor.png
      git commit -m "Add README.md, LICENSE, and update package.json for v0.0.3"
      git push origin main
      
    • Verify clean status:
      git status
      # Should show: nothing to commit, working tree clean
      
  2. Create Publisher Account (if not done):

    • Go to Visual Studio Marketplace.
    • Sign in with a Microsoft account.
    • Create publisher:
      • ID: nikhil-codementor
      • Name: NikhilCodeMentor
  3. Create Personal Access Token (PAT):

    • Go to Azure DevOps.
    • Profile > Personal access tokens > New Token.
    • Set:
      • Name: VSCodeExtensionPublish
      • Organization: All accessible organizations
      • Expiration: 1 year
      • Scopes: Marketplace > Acquire and Publish
    • Copy the token securely.
  4. Package the Extension:

    npm install -g vsce
    vsce package
    
    • Creates codementor-0.0.2.vsix (or 0.0.3 if version updated).
    • Verify files:
      vsce ls
      
      Expected: README.md, LICENSE, package.json, extension.js, mentor.py, images/codementor.png.
  5. Test Locally:

    code --install-extension codementor-0.0.2.vsix
    
    • Test with test.py:
      def add(a, b)  # Missing colon
          return a + b
      
    • Run Ctrl+Shift+S and check CodeMentor_Feedback.txt:
      Solution: Corrected code:
      ```python
      def add(a, b):
          return a + b
      
      Explanation: Added missing colon.
    • Verify README.md in Extensions view (Ctrl+Shift+X).

Contributing

File issues or pull requests at GitHub.

License

MIT

Contact

For support, email: nnair7598@gmail.com.

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