← Blog/VS Code Extension

How to Build Your First VS Code Extension — Commands, Status Bar & Output Channel

Learn how to build a real VS Code extension from scratch using Node.js and the Yeoman generator. Register custom commands in the Command Palette, add a clickable status bar item, and write to an Output Channel.

📅 2026-06-262 min read📚 Ebook #06

What is a VS Code Extension?

VS Code is built to be extended. Every feature you see — syntax highlighting, IntelliSense, Git integration — is an extension. The VS Code Extension API lets you add your own commands, UI elements, and functionality to the editor.

Setting Up with Yeoman

VS Code has an official generator to scaffold extension projects:

npm install -g yo generator-code
yo code

Choose New Extension (TypeScript) and fill in your project details. This creates a complete project with everything you need.

The package.json — Extension Manifest

The package.json file is where you declare what your extension contributes to VS Code:

{
  "contributes": {
    "commands": [{
      "command": "myExtension.helloWorld",
      "title": "Hello World"
    }]
  }
}

Registering a Command

In your extension.ts, register the command and connect it to a function:

import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {
  // Register the command
  const command = vscode.commands.registerCommand(
    'myExtension.helloWorld',
    () => {
      vscode.window.showInformationMessage('Hello from my extension!');
    }
  );

  context.subscriptions.push(command);
}

Now press F5 to open the Extension Development Host and try Ctrl+Shift+P → "Hello World".

Adding a Status Bar Item

const statusBarItem = vscode.window.createStatusBarItem(
  vscode.StatusBarAlignment.Right,
  100 // priority
);
statusBarItem.text    = '$(check) My Extension';
statusBarItem.tooltip = 'Click to run command';
statusBarItem.command = 'myExtension.helloWorld';
statusBarItem.show();

Packaging with vsce

npm install -g @vscode/vsce
vsce package
# Creates: my-extension-1.0.0.vsix

This is a preview. The full ebook covers the Output Channel API, reading workspace files, adding configuration settings, and publishing to the VS Code Marketplace.

Ready to Build This Yourself?

This article is a preview. The full ebook has complete code, detailed explanations, troubleshooting tips, and bonus sections — all in a downloadable PDF.

Buy Full Ebook — $1.50 in $YFIN
Pay with $YFIN on BNB Smart Chain · 30% burned permanently