
Add Policy
Ship or review VS Code configuration policies when you add, change, or audit a `policy:` field in the editor codebase.
Install
npx skills add https://github.com/microsoft/vscode --skill add-policyWhat is this skill?
- End-to-end lifecycle: register a policy, export it, and produce platform-specific admin artifacts.
- Layered sources: OS policy (Windows registry, macOS prefs), Linux `/etc/vscode/policy.json`, and account/GitHub via IPol
- MultiplexPolicyService combines OS-level and account services with last-writer-wins semantics.
- Trigger on ANY change that adds or modifies a `policy:` field on a configuration property.
- Covers PR review for policy registration and account-based policy via IDefaultAccountService.policyData.
Adoption & trust: 164 installs on skills.sh; 186k GitHub stars; 2/3 security scanners passed (skills.sh audits).
Recommended Skills
Journey fit
Policy work happens while extending the VS Code product and its enterprise configuration surface, before release artifacts and admin exports exist. Policies wire product settings into OS-level and account-level enforcement—integration work across NativePolicyService, file policy, and IPolicyData.
Common Questions / FAQ
Is Add Policy safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Add Policy
# Adding a Configuration Policy Policies allow enterprise administrators to lock configuration settings via OS-level mechanisms (Windows Group Policy, macOS managed preferences, Linux config files) or via Copilot account-level policy data. This skill covers the complete procedure. ## When to Use - Adding a new `policy:` field to any configuration property - Modifying an existing policy (rename, category change, etc.) - Reviewing a PR that touches policy registration - Adding account-based policy support via `IPolicyData` ## Architecture Overview ### Policy Sources (layered, last writer wins) | Source | Implementation | How it reads policies | |--------|---------------|----------------------| | **OS-level** (Windows registry, macOS plist) | `NativePolicyService` via `@vscode/policy-watcher` | Watches `Software\Policies\Microsoft\{productName}` (Windows) or bundle identifier prefs (macOS) | | **Linux file** | `FilePolicyService` | Reads `/etc/vscode/policy.json` | | **Account/GitHub** | `AccountPolicyService` | Reads `IPolicyData` from `IDefaultAccountService.policyData`, applies `value()` function | | **Multiplex** | `MultiplexPolicyService` | Combines OS-level + account policy services; used in desktop main | ### Key Files | File | Purpose | |------|---------| | `src/vs/base/common/policy.ts` | `PolicyCategory` enum, `IPolicy` interface | | `src/vs/platform/policy/common/policy.ts` | `IPolicyService`, `AbstractPolicyService`, `PolicyDefinition` | | `src/vs/platform/configuration/common/configurations.ts` | `PolicyConfiguration` — bridges policies to configuration values | | `src/vs/workbench/services/policies/common/accountPolicyService.ts` | Account/GitHub-based policy evaluation | | `src/vs/workbench/services/policies/common/multiplexPolicyService.ts` | Combines multiple policy services | | `src/vs/workbench/contrib/policyExport/electron-browser/policyExport.contribution.ts` | `--export-policy-data` CLI handler | | `src/vs/base/common/defaultAccount.ts` | `IPolicyData` interface for account-level policy fields | | `build/lib/policies/policyData.jsonc` | Auto-generated policy catalog (DO NOT edit manually) | | `build/lib/policies/policyGenerator.ts` | Generates ADMX/ADML (Windows), plist (macOS), JSON (Linux) | | `build/lib/test/policyConversion.test.ts` | Tests for policy artifact generation | ## Procedure ### Step 1 — Add the `policy` field to the configuration property Find the configuration registration (typically in a `*.contribution.ts` file) and add a `policy` object to the property schema. **Required fields:** **Determining `minimumVersion`:** Always read `version` from the root `package.json` and use the `major.minor` portion. For example, if `package.json` has `"version": "1.112.0"`, use `minimumVersion: '1.112'`. Never hardcode an old version like `'1.99'`. ```typescript policy: { name: 'MyPolicyName', // PascalCase, unique across all policies category: PolicyCategory.InteractiveSession, // From PolicyCategory enum minimumVersion: '1.112', // Use major.minor from package.json version localization: { description: { key: 'my.config.key', // NLS key for the description value: nls.localize('my.config.key', "Human-readable description."), } } } ``` **Optional: `value` function for account-based policy:** If this policy should also be controllable via Copilot account policy data (from `IPolicyData`), add a `value` function: ```typescript policy: { name: 'MyPolicyName', category: PolicyCategory.InteractiveSession, minimumVersion: '1.112', // Use major.minor from package