CodeMentor AI is a privacy-friendly coding assistant for LeetCode and NeetCode. It provides subtle hints, detailed approaches, and quick code analysis directly on problem pages. When supported, it uses on-device AI (Gemini Nano) for low-latency, offline-friendly help, and falls back gracefully when AI is unavailable.
- Smart hints and detailed solution approaches
- Code analysis of your current editor content (Monaco/CodeMirror)
- Voice commands (hint, explain, analyze, screenshot, open settings)
- Real-time code monitoring (optional)
- Progress tracking: hints, explanations, problems explored
- On-device AI via Gemini Nano when available
- Google Chrome (or Chromium-based) with Manifest V3 support
- Optional: Gemini Nano availability in the browser (
window.ai.languageModel)
- Download or clone this repository.
- Open Chrome and navigate to
chrome://extensions/. - Enable "Developer mode" (top-right toggle).
- Click "Load unpacked" and select the
extension/folder. - Pin the extension to your toolbar for quick access.
activeTab,tabs,scripting: Inject and communicate with content scriptsstorage: Persist your session and preferences locallyalarms: Auto-save your session every 5 minutestabCapture: Capture screenshots (for the Smart Capture feature)host_permissions: Restricted toleetcode.comandneetcode.io
- Open a LeetCode or NeetCode problem.
- Click the CodeMentor AI icon to open the popup.
- Use one of the main actions:
- Smart Hint: subtle guidance tailored to the problem
- Detailed Approach: step-by-step solution strategy
- Code Analysis: review the code currently in your editor
- Try the mic button for voice commands if your browser allows microphone access.
- "Give me a hint"
- "Explain the approach"
- "Analyze my code"
- "Take a screenshot"
- "Open settings"
- Hint Level: subtle, medium, detailed
- Explanation Style: concise, step-by-step, detailed
- Toggle: voice commands, code monitoring
- Clear session data
content-script.jsparses the problem page (title, difficulty, description, examples, constraints) and extracts code from Monaco/CodeMirror.background.jsmanages session persistence (viachrome.storage.local), autosave (viachrome.alarms), and orchestrates on-device AI prompts by messaging the content script.popup.html,popup.js,styles.csspower the UI and interactions.
- Checks
window.ai.languageModel.capabilities()in page context. - If available, creates a session to generate hints, explanations, and code feedback.
- If not available, uses robust non-AI fallbacks.
- "Please navigate to a LeetCode problem page": open a problem page before using the popup.
- Voice errors:
not-allowed: allow microphone access in the browser address barno-speech/audio-capture: check mic/OS audio settings
- AI unavailable:
- You’ll see a friendly error; the extension falls back automatically
- Ensure your Chrome supports on-device AI (Gemini Nano) and it’s enabled
- "No code detected":
- Ensure code exists in the editor; if live extraction fails, cached code is used when available.
- Load the
extension/folder via "Load unpacked" in Chrome. - Key files:
manifest.json– MV3 manifest and permissionscontent-script.js– page parsing, code extraction, AI sessionbackground.js– session, autosave, messaging, AI orchestrationpopup.html,popup.js,styles.css– UI and interactions
- Use Chrome DevTools → Applications → Service Workers to view background logs.
- Languages: JavaScript (ES6+), HTML, CSS
- Platform: Chrome Extension (Manifest V3)
- Browser APIs:
chrome.runtime,chrome.tabs,chrome.scripting,chrome.storage,chrome.alarms,chrome.tabCapture - AI: Gemini Nano Prompt API (
window.ai.languageModel) - Editors: Monaco, CodeMirror (DOM-based extraction)
- Deeper code understanding: test case generation, complexity checks
- Personalized learning paths with adaptive difficulty
- Multi-language support and richer templates
- Optional cloud sync of session data
- Support beyond LeetCode/NeetCode
MIT