Scaffolds a VS Code extension from scratch in a blank repository — creates all config, build, unit test, integration test infrastructure, telemetry, and AI agent skills
Scaffold a new VS Code extension from scratch. This prompt is self-contained and works in any repository.
Ask the user for any that are missing before proceeding:
| Argument | Description | Example |
|---|---|---|
extensionName | PascalCase folder name | MyTool |
commandPrefix | camelCase prefix for all command IDs | myTool |
displayName | Human-readable name shown in VS Code | My Tool |
description | One-sentence description for package.json | Does something useful. |
publisher | VS Code marketplace publisher ID | myPublisher |
commands | List of { id, title } objects |
[{ id: "doThing", title: "Do Thing" }]If commands is empty or not provided, scaffold with zero commands (empty arrays).
external: ["vscode"], platform: "node", target: "node20"@vscode/extension-telemetry with local console fallback (no AppInsights key required for development). The telemetry module uses dependency injection — see the Testability section below.tests/unit-tests/, v8 coverage provider@vscode/test-cli + @vscode/test-electron — runs from tests/e2e-tests/^1.100.0onStartupFinished.cline/skills/ folder for both Cline and Copilot agents├── .memory-bank/ ← Persistent context for Cline/Copilot dual-agent workflows
├── .cline/ ← Agent configuration root
│ └── skills/ ← AI agent skills (shared by Cline and Copilot via settings.json)
│ ├── build/ ← How to build the extension
│ │ └── SKILL.md
│ ├── publish/ ← How to create VSIX publish artifacts
│ │ └── SKILL.md
│ ├── test/ ← How to run unit and integration tests
│ │ └── SKILL.md
│ └── security-review/ ← AI-powered codebase security scanner
│ ├── SKILL.md
│ └── references/ ← Detection patterns and report templates for security scanner
│ ├── language-patterns.md
│ ├── report-format.md
│ ├── secret-patterns.md
│ ├── vuln-categories.md
│ └── vulnerable-packages.md
├── .vscode/ ← VS Code workspace configuration
│ ├── launch.json ← Debug/run configurations (Run Extension, Integration Tests)
│ ├── tasks.json ← Build and test tasks (aligned with npm scripts and skills)
│ └── settings.json ← Workspace settings (chat.skillsLocations → .cline/skills)
├── src/ ← Extension source code and build config
│ ├── extension.ts ← Entry point (activate/deactivate)
│ ├── telemetry.ts ← Telemetry module (AppInsights or local console fallback)
│ ├── package.json ← Extension manifest, dependencies, and npm scripts
│ ├── tsconfig.json ← TypeScript compiler configuration
│ ├── esbuild.config.mjs ← esbuild bundler configuration (CJS, node20)
│ ├── vitest.config.ts ← Unit test runner configuration
│ ├── .vscodeignore ← Files excluded from VSIX package
│ └── .vscode-test.mjs ← @vscode/test-cli integration test configuration
├── tests/ ← All test suites
│ ├── unit-tests/ ← Vitest unit tests (run outside VS Code, mock vscode API)
│ │ ├── extension.test.ts
│ │ └── telemetry.test.ts
│ └── e2e-tests/ ← Mocha integration tests (run inside VS Code Extension Host)
│ ├── tsconfig.json ← TypeScript config for e2e test compilation
│ ├── helpers.ts ← Shared test utilities (workspace, file operations)
│ ├── extension.test.ts ← Extension lifecycle tests (activation, commands)
│ └── fixtures/ ← Test workspace fixtures
│ └── empty-workspace/
│ └── .gitkeep
├── docs/ ← Project documentation
│ ├── adrs/ ← Architectural Decision Records
│ │ ├── adr-0001-use-vitest-for-unit-tests.md
│ │ └── adr-0002-vs-code-extension-integration-test-runner.md
│ └── dev/ ← Developer documentation
│ ├── info/ ← Architecture diagrams and extension information
│ │ └── vscode-extension-lifecycle.md
│ └── tsg/ ← Troubleshooting guides and dev how-tos
│ └── .gitkeep
├── publish/ ← VSIX package output (keeps current + 2 previous versions)
│ └── .gitkeep
├── .gitignore
├── CHANGELOG.md
└── README.md
The .cline/skills/ directory contains AI agent skills that are deployed verbatim from the
skills/ folder in this scaffold template. Copy each skill folder into the target
project's .cline/skills/ directory, preserving the directory structure exactly. The security-review
skill includes a references/ subdirectory with 5 reference files that must also be copied.
@vscode/extension-telemetry is a CJS package that calls require("vscode") at load time.
This breaks Vitest unit tests because vscode is a virtual module provided only by the Extension Host.
vi.mock("vscode") cannot intercept a CJS require() inside node_modules.
Solution: telemetry.ts never imports @vscode/extension-telemetry directly. Instead it
accepts a TelemetryReporterFactory function via its options object. extension.ts provides
that factory using a lazy require() inside an arrow function body, so the CJS package is
only loaded when activate() runs (inside the real Extension Host). Unit tests that mock
../../src/telemetry never trigger the require() at all.
This pattern applies to any CJS dependency that calls require("vscode") at the top level.
Always wrap such dependencies behind an injected factory rather than importing them in modules
that need to be unit-tested.
Deploy files in this exact order so that coding standards and architectural decisions are available before code generation begins. The agent MUST read the existing repo instruction files and deploy bundled agent skills BEFORE scaffolding any source code.
.cline/skills/) — deploy bundled AI agent workflows.github/instructions/) — read all pre-existing coding standards, commenting policy, testing guidelines, and design principles so they are loaded before writing any codedocs/adrs/) — rationale for tech choices.gitignore, .vscode/, package.json, tsconfig.json, build config)src/) — extension entry point, modulestests/) — unit and e2e testsdocs/, publish/, CHANGELOG.md, README.md)Substitute all <placeholder> values with the provided arguments.
The repository already contains AI coding instructions in .github/instructions/.
Do not create or overwrite these files — they are pre-existing.
.cline/skills/ folders into the target project
(see the Agent Skills section above for details)..github/instructions/ (including focusedInstructions/) so that
coding standards, commenting policy, design principles, and testing guidelines are loaded
before writing any code.After reading and deploying, proceed to Phase 2.
docs/adrs/adr-0001-use-vitest-for-unit-tests.md---