This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Visual Studio Code is a cross-platform code editor built with TypeScript, Electron, and web technologies. This is the "Code - OSS" repository where the open-source core is developed.
Primary development workflow:
- Run the
VS Code - Buildtask from VS Code's task runner to start incremental compilation- This runs both
Core - Build(forsrc/) andExt - Build(forextensions/) - Uses
npm run watch-clientdandnpm run watch-extensionsdunder the hood - Watch tasks run in the background using
deemon
- This runs both
- CRITICAL: Always check the
VS Code - Buildtask output for TypeScript compilation errors before running tests or scripts - Kill watch tasks:
Kill VS Code - Buildtask
Manual compilation:
npm run compile- One-time compilation of all TypeScriptnpm run compile-web- Compile for webnpm run watch-web- Watch mode for web extensions
./scripts/code.sh(or.\scripts\code.baton Windows) - Launch VS Code from source./scripts/code-web.sh(or.\scripts\code-web.bat) - Launch web version./scripts/code-server.sh(or.\scripts\code-server.bat) - Launch remote server
Unit tests:
./scripts/test.sh(or.\scripts\test.baton Windows) - Run unit tests- Add
--grep <pattern>to filter tests - Single test:
./scripts/test.sh --grep "test name pattern"
Integration tests:
./scripts/test-integration.sh(or.\scripts\test-integration.bat) - Run all integration tests- Tests API, extensions (TypeScript, Markdown, Git, Emmet, etc.)
Browser tests:
npm run test-browser- Run unit tests in browser (installs Playwright)npm run test-browser-no-install- Skip Playwright installation
Web integration:
./scripts/test-web-integration.sh- Web-specific integration tests
Extension tests:
npm run test-extension -- -l <extension-name>- Test specific extension
npm run eslint- Run ESLint on the codebasenpm run hygiene- Run hygiene checks (formatting, headers, etc.)npm run valid-layers-check- Verify architectural layering rulesnpm run tsec-compile-check- Run Trusted Types security checkernpm run monaco-compile-check- Check Monaco editor compilationnpm run vscode-dts-compile-check- Validate VS Code API definitions
npm installornpm i- Install dependencies (has pre/post install hooks)npm run download-builtin-extensions- Download built-in extensionsnpm run electron- Download Electron binary
VS Code follows a strict layered architecture:
-
src/vs/base/- Foundation layer- Platform-agnostic utilities, data structures, and abstractions
- No dependencies on other VS Code layers
- Common patterns: async utilities, collections, events, lifecycle management
-
src/vs/platform/- Platform services layer- Cross-platform service abstractions
- Dependency injection infrastructure
- Services: configuration, files, telemetry, storage, etc.
- Platform-specific implementations for Electron, web, and server
-
src/vs/editor/- Text editor layer- Monaco Editor implementation
- Standalone editor that can be used outside VS Code
- Language services, syntax highlighting, completions, etc.
- No dependencies on workbench
-
src/vs/workbench/- Application layer- Main VS Code application UI and features
- Sub-structure:
workbench/browser/- Core workbench UI (parts, layout, actions)workbench/services/- Workbench-level service implementationsworkbench/contrib/- Feature contributions (git, debug, search, terminal, chat, etc.)workbench/api/- Extension host and VS Code Extension API implementation
-
src/vs/code/- Electron main process- Desktop-specific entry points and main process code
-
src/vs/server/- Remote server implementation- Code for running VS Code as a remote server
Dependency Injection:
- Services are injected via constructor parameters
- Use decorators like
@IServiceNamefor injection - Services are registered in service collections
Contribution Points:
- Features register themselves in contribution registries
- Examples: commands, menu items, views, languages, themes
- Enables modular feature development
Cross-Platform Abstractions:
- Platform-specific code is isolated behind interfaces
- Check
src/vs/base/common/vssrc/vs/base/browser/vssrc/vs/base/node/
Built-in extensions live in extensions/:
- Language features:
typescript-language-features/,html-language-features/,css-language-features/,json-language-features/, etc. - Core features:
git/,emmet/,markdown-language-features/,debug-auto-launch/ - Themes:
theme-*folders - Each extension has standard structure:
package.json,src/, contribution points
- Gulp - Main build orchestration (
gulpfile.js→build/gulpfile.js) - TypeScript - Custom incremental builder in
build/lib/tsb/ - Webpack - Used for bundling extensions
- Entry points:
src/main.ts(Electron main),src/bootstrap-*.tsfiles
test/unit/- Unit tests (browser and Node.js)test/integration/- Integration teststest/smoke/- End-to-end smoke teststest/automation/- Automation library for UI tests- Unit tests are co-located with source:
src/vs/*/test/
- Indentation: Tabs, not spaces
- Naming:
PascalCasefor types and enum valuescamelCasefor functions, methods, properties, variables
- Strings:
- "double quotes" for user-facing strings (need localization)
- 'single quotes' for internal strings
- Functions: Prefer
export function name() {}overexport const name = () => {}in top-level scopes (better stack traces) - Arrow functions: Only use parens when necessary:
x => x + xnot(x) => x + x - Braces: Always use for loops/conditionals, open on same line
- Async: Prefer
async/awaitover.then()chains
- Copyright header: All files must include Microsoft copyright header
- Localization: All user-facing strings must be localized using
nls.localize() - Comments: Use JSDoc for functions, interfaces, enums, and classes
- Layering: Respect architectural layers - use
npm run valid-layers-checkto verify - Test placement: Add tests to appropriate suites, not end of files
- Use title-style capitalization for commands, buttons, menu items
- Don't capitalize prepositions of 4 or fewer letters unless first/last word
- Run
npm installto get dependencies - Start
VS Code - Buildtask for incremental compilation - Monitor the task output for compilation errors
CRITICAL RULE: Never proceed with tests or scripts if there are TypeScript compilation errors.
- Always check
VS Code - Buildtask output for errors - Never run tests with compilation errors
- Fix all errors before moving forward
- The build task runs incrementally as you edit files
- Make code changes in
src/orextensions/ - Watch task automatically recompiles
- Check task output for errors
- Run relevant tests:
./scripts/test.sh --grep "pattern" - Run hygiene/layering checks before committing
- Semantic search: Use file search for concepts/feature areas
- Exact matches: Use grep for error messages, function names, strings
- Follow imports: Check what files import a module to understand usage
- Tests: Look at test files (
*/test/) to understand behavior - Contributions: Search for registry calls to find where features are registered
constructor(
@IConfigurationService private readonly configurationService: IConfigurationService,
@IFileService private readonly fileService: IFileService
) {}// Register command
CommandsRegistry.registerCommand(id, handler);
// Register view
registerSingleton(IViewsService, ViewsService);import * as nls from "vs/nls";
const message = nls.localize("key", "Default message");src/vs/base/common/- Platform-agnostic codesrc/vs/base/browser/- Browser/renderer processsrc/vs/base/node/- Node.js/main processsrc/vs/base/electron-main/- Electron main process
- Version: 1.104.x (check
package.json) - License: MIT
- Node version: Check
.nvmrcorpackage.jsonengines - Main branch:
main - Release branches:
release/1.x