A robust, flexible, and modern VS Code extension designed to streamline solving LeetCode problems directly from your editor.
Better LeetCode brings the full LeetCode experience directly into your IDE with native support and no annoying boilerplate code.
- Web Authorization Login: Authenticate securely using LeetCode's official authorize-login flow directly via your browser with built-in CSRF protection.
- Direct SQL Support: First-class support for database problems with customized SQL configurations (MySQL, MS SQL, Oracle SQL, PostgreSQL).
- Problem Hints: Toggle and view hints line-by-line directly in the problem description view.
- Discussion Browsing: Browse problem discussions with paginated comments, threaded replies, and a dedicated discussion webview panel.
- Flexible Submission: Submit solutions against default test cases or hidden test cases effortlessly.
- Language Switch on the Fly: Change your target programming language seamlessly from the editor.
- Interactive Configurations: Easily change your default language or database language on the fly.
- Quick Shortcuts: Speed up your workflow with keyboard shortcuts (
Cmd+;/Ctrl+;to test,Cmd+Enter/Ctrl+Enterto submit). - Intuitive UI Refreshing: Automatic refreshing on login/logout, and separate refresh triggers for Daily Challenge, Problems list, Study Lists, and Contests.
- No Boilerplate Comments: Write clean, standard code; the extension natively manages the underlying boilerplate.
- Native VS Code Tooling: Leverage VS Code's rich syntax highlighting, IntelliSense, auto-complete, and extensions.
- Integrated Debugger: Step through your code using VS Code's native debugger.
- Study Lists: Easily track and complete curated LeetCode study lists.
- Daily Problems: Quickly fetch and solve the daily LeetCode challenge with a single click.
To interact with LeetCode (fetch premium problems, submit solutions, track progress), you need to authenticate the extension. Better LeetCode supports two secure login methods:
- Click the Sign In button in the sidebar or run the command
Better LeetCode: Sign Infrom the Command Palette (Cmd+Shift+P/Ctrl+Shift+P). - Select Web Authorization (Recommended).
- Your browser will open the official LeetCode authorization page.
- Log in (if you aren't already) and authorize. The browser will securely redirect you back to VS Code, logging you in automatically.
If the web login flow does not work for your environment, you can manually paste your cookies:
- Go to LeetCode.com and log in.
- Open your browser's Developer Tools (usually
F12orCmd+Option+I). - Navigate to the Application tab (Chrome/Edge) or Storage tab (Firefox).
- Under Cookies, select
https://leetcode.com. - Find the cookie named
LEETCODE_SESSIONand copy its value. - Find the cookie named
csrftokenand copy its value. - In VS Code, run
Better LeetCode: Sign In, select LeetCode Cookie, and paste the tokens when prompted to authenticate.
- VS Code (version
^1.90.0or higher) - Node.js (version
^20.0.0or higher) - Bun (preferred package manager)
Initialize and install the required dependencies using Bun:
bun installTo run and debug the extension locally:
- Open the project directory in VS Code.
- Press
F5(or go to the Run and Debug view and select "Run Extension"). - A new window named [Extension Development Host] will launch.
- Open the Command Palette and type
Better LeetCode: Show Problem Statementor any other extension command to test it.
We use GitHub Actions to automate publishing the extension to the Visual Studio Marketplace.
- Ensure your extension version is updated in
package.json. - Push your changes to the
mainbranch. - Create a Release on GitHub with the new version tag (e.g.,
v1.3.0). - The GitHub Actions workflow will automatically bundle and publish the extension.
Note: You must have the VSCE_PAT secret configured in your repository settings (Settings > Secrets and variables > Actions). This Personal Access Token should be generated from your Azure DevOps organization with "Marketplace" > "Manage" scopes.
If you need to publish manually from your local machine:
- Install
vsceglobally:npm install -g @vscode/vsce
- Package the extension:
bun run package vsce package
- Publish the extension:
bun run publish
To maintain code quality and stability, please adhere to the rules defined in AGENTS.md:
- TypeScript Only: Write clean, type-safe TypeScript. Do not use the
anytype under any circumstances. - SOLID Principles: Keep components focused, modular, and decoupled.
- Comprehensive Testing: Write unit and integration tests for all core features and edge cases.
If you find this extension helpful and it saves you time, consider buying me a coffee to support its ongoing development!
