{"post":{"slug":"how-to-build-vscode-extension-2026","title":"How to build a VS Code extension in 2026 (a working tutorial)","excerpt":"Build, test, and publish a VS Code extension in 2026. The current API, the publishing flow, and the gotchas.","category":"code","date":"January 28, 2026","author":"ByteLedger Team","content":"<span class=\"dropcap\">B</span>uilding a VS Code extension in 2026 is a one-evening project for a working developer. The API surface is large but well-shaped, the tooling generates a working starter in two minutes, and the marketplace publishing flow is a single command. The trick is knowing which API surface to touch — and which to leave alone.\n\nThis guide walks through the path that ships.\n\n## What changed in 2026\n\nVS Code's extension API kept growing.\n\n- **Language Model API is GA.** Extensions can call Copilot's models with the user's existing entitlement.\n- **Chat participants are first-class.** Custom `@you` commands inside the chat view.\n- **Web extensions are mainstream.** The same code can run in vscode.dev with a small extra config.\n\n## How we picked the path\n\nFive steps that map to a working extension.\n\n- **Generate with `yo code`**\n- **Pick the smallest API that does the job**\n- **Test in a fresh extension host**\n- **Package with `vsce package`**\n- **Publish with `vsce publish`**\n\n## 1. Generate the starter\n\nInstall `yo` and `generator-code`. Run `yo code`, pick \"New Extension (TypeScript)\", give it a name. You get a working extension with a sample command, a test runner, and a launch config. Run \"Run Extension\" from VS Code's debugger and a second window opens with your extension loaded.\n\nThe trade-off: the generator uses npm by default. If you prefer pnpm or Bun, swap the package manager after generation.\n\n## 2. Pick the right API surface\n\nThe most common APIs in 2026:\n\n- **Commands** — bind a function to a palette entry or keybinding.\n- **Tree views** — sidebar lists. Lightweight and fast.\n- **Code actions and quick fixes** — light-bulb suggestions in the editor.\n- **Language Model API** — call Copilot models with the user's entitlement.\n- **Chat participant** — register an `@you` handler in the chat panel.\n\nAvoid webviews unless you need actual HTML rendering. They cost startup time and the message-passing API is fiddly.\n\n## 3. Test before you publish\n\nRun the extension in the integrated debugger. Then run it in a fresh user-data directory (`code --extensionDevelopmentPath=. --user-data-dir=/tmp/test`) to catch state-related bugs. Check activation events — extensions that activate on `*` slow down editor startup for every user.\n\n## 4. Publish\n\nCreate a publisher on the Marketplace, generate a personal access token in Azure DevOps. Run `vsce package` to produce a `.vsix`, then `vsce publish` to upload it. Each new version is live within minutes.\n\n## Comparison: Extension API surfaces in April 2026\n\n| API | Complexity | Performance cost | Best for |\n| --- | --- | --- | --- |\n| Commands | Low | None | Everything starts here |\n| Tree views | Low | Low | Sidebar UIs |\n| Status bar | Very low | None | Quick info |\n| Webview | High | High | Real HTML UIs only |\n| Language Model | Medium | Depends | AI-powered features |\n\n## Common mistakes to avoid\n\n**Activating on `*`.** Every user pays for your extension's startup time. Use specific activation events.\n\n**Building a webview when a tree view fits.** Webviews look impressive in screenshots and feel slow in daily use.\n\n**Forgetting `engines.vscode`.** Pin a minimum VS Code version. New API breaks old VS Code. Old API breaks new behavior.\n\n## FAQ\n\n**Can my extension call OpenAI directly?**\nYes, but you must handle the user's API key yourself. The Language Model API is the easier path because it uses the user's existing Copilot entitlement.\n\n**Will my extension work in Cursor?**\nIn most cases yes — Cursor is a VS Code fork and supports the same extension API.\n\n**How do I monetize an extension?**\nThe Marketplace itself does not handle payments. Most paid extensions use a license-key flow with an external payment provider.\n\n## Where to go next\n\nFor related guides see [Best VS Code extensions in 2026](/blog/best-vscode-extensions-2026), [Best AI coding assistants in 2026](/blog/best-ai-coding-assistants-2026), and [How to use Claude for coding in 2026](/blog/how-to-use-claude-for-coding-2026).","hue":315,"metaTitle":"Build a VS Code Extension in 2026: Tutorial","metaDescription":"A working 2026 tutorial for building, testing, and publishing a VS Code extension. Modern API, AI integration, marketplace flow.","keywords":["build vscode extension 2026","vscode extension tutorial","vscode language model api","publish vscode extension","vscode webview","vscode extension typescript","yo code generator","vscode extension testing","vscode marketplace","extension development guide"],"tldr":["**The yo code generator is still the fastest start** — TypeScript template, working test runner, ready to launch.","**Use the language model API for AI features** — VS Code now exposes Copilot models to extensions.","**Test in a fresh extension host every time** — saved state masks bugs you will hit in production.","**Skip:** building a full webview when a tree view will do. Webviews are the source of most extension performance complaints."],"readTime":"3 min read","wordCount":661},"related":[{"slug":"mcp-servers-guide-2026","title":"MCP servers explained: how to build and use Model Context Protocol in 2026","excerpt":"Model Context Protocol (MCP) became the standard for connecting AI models to external tools in 2026. Here is what it is, why it matters, and how to build your first MCP server in under an hour.","category":"code","date":"January 31, 2026","author":"ByteLedger Team","readTime":"4 min read","hue":308},{"slug":"how-to-make-a-website-from-scratch-2026","title":"How to Make a Website From Scratch in 2026: full guide","excerpt":"To make a website from scratch in 2026, write HTML and CSS, add a little JavaScript, then host it. Here is the full beginner path and what to skip.","category":"code","date":"May 7, 2026","author":"ByteLedger Team","readTime":"3 min read","hue":212},{"slug":"how-to-write-e2e-tests-2026","title":"How to write e2e tests in 2026","excerpt":"End-to-end tests catch what unit tests miss — broken flows, real browser quirks, and integration failures. This guide covers Playwright setup, writing reliable tests, and running them in CI.","category":"code","date":"March 18, 2026","author":"ByteLedger Team","readTime":"4 min read","hue":316}],"sameCategory":[{"slug":"bazel-build-explained-2026","title":"Bazel Explained: What Hermetic Builds Actually Cost","excerpt":"Bazel delivers reproducible, precisely cached builds and demands that you describe everything. Here is what you get, what it costs, and who should say no.","category":"code","date":"August 19, 2026","author":"ByteLedger Team","readTime":"3 min read","hue":145},{"slug":"graphql-federation-2026","title":"GraphQL Federation: One Graph, Many Teams","excerpt":"Federation composes independently-owned subgraphs into a single API. Here is what it solves, the operational cost it adds, and when a simpler gateway is enough.","category":"code","date":"August 19, 2026","author":"ByteLedger Team","readTime":"3 min read","hue":300},{"slug":"hermetic-builds-explained-2026","title":"Hermetic Builds Explained: Same Inputs, Same Output","excerpt":"A hermetic build depends only on declared inputs. Here is what that property gives you, the common leaks that break it, and how to move toward it incrementally.","category":"code","date":"August 19, 2026","author":"ByteLedger Team","readTime":"3 min read","hue":130},{"slug":"monorepo-tooling-compared-2026","title":"Monorepo Tooling Compared: What You Actually Need","excerpt":"Monorepo tools solve task orchestration and caching, not repository layout. Here is what each tier provides and how to tell when you have outgrown the simple option.","category":"code","date":"August 19, 2026","author":"ByteLedger Team","readTime":"3 min read","hue":150}],"newer":{"slug":"how-to-build-cli-tool-2026","title":"How to build a CLI tool in 2026 (Node, Go, Rust, Bun compared)","excerpt":"A practical guide to building a CLI tool in 2026. Which runtime to pick, which libraries to use, and how to ship a single binary.","category":"code","date":"January 28, 2026","author":"ByteLedger Team","readTime":"3 min read","hue":310},"older":{"slug":"how-to-deal-with-irs-audit-2026","title":"How to deal with an IRS audit in 2026: the calm-down playbook","excerpt":"A step-by-step playbook for handling an IRS audit in 2026 without panic — what each notice means, what to send, and when to hire a pro.","category":"finance","date":"January 28, 2026","author":"ByteLedger Team","readTime":"3 min read","hue":280}}