Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/sessions/copilot-customizations-spec.md
13383 views

Copilot Agent Runtime — Customization Surface Spec

Purpose: Definitive reference for every customization mechanism that affects agent behavior when a user sends a message. Intended for building a UI that collects all customizations into a single view.

Source: github/copilot-agent-runtime codebase as of 2026-02-25.

Some information has been removed by the human compiling this spec, scoping to what is deemed most relevant for the agent sessions window implementation. For the full details, see the source code (for maintainers likely checked out side-by-side).


Overview

When a user sends a message, the agent assembles its behavior from 10 customization categories, each discovered from well-known file paths, environment variables, or runtime APIs. This document enumerates every source, file pattern, and merge rule.


1. Instructions

System-prompt additions that shape how the agent responds. Multiple sources are discovered and merged in priority order.

1.1 Repo-Level Instruction Files

Each pattern is defined in src/helpers/repo-helpers.tsinstructionPatterns:

ConventionFile PatternNotes
Copilot{repo}/.github/copilot-instructions.mdPrimary repo instructions
Codex / OpenAI{repo}/AGENTS.mdOpenAI model convention
Claude / Anthropic{repo}/CLAUDE.mdClaude model convention
Claude (alt){repo}/.claude/CLAUDE.mdSecondary Claude location
Gemini / Google{repo}/GEMINI.mdGemini model convention

1.2 VSCode-Style Instruction Files

Glob-matched instruction files with metadata (applyTo patterns, description).

ScopeFile PatternCode Reference
Repo{repo}/.github/instructions/**/*.instructions.mdreadVSCodeInstructions()
User~/.copilot/instructions/**/*.instructions.mdreadUserCopilotInstructions()

1.3 User-Level Instructions

ScopeFile PatternCode Reference
User global~/.copilot/copilot-instructions.mdhasHomeCopilotInstructions()

1.4 CWD-Specific Instructions

When the working directory differs from the repo root, the same instruction patterns are re-checked relative to {cwd}:

  • {cwd}/.github/copilot-instructions.md

  • {cwd}/CLAUDE.md, {cwd}/.claude/CLAUDE.md

  • {cwd}/AGENTS.md

  • {cwd}/GEMINI.md

1.5 Nested / Child Instructions

Breadth-first traversal from {cwd} up to 2 levels deep (CHILD_INSTRUCTIONS_MAX_DEPTH = 2), scanning all instruction patterns in subdirectories.

Ignored directories: node_modules, .git, vendor, dist, build, .next, .nuxt, out, coverage (plus .gitignore patterns when available).

Feature-gated via enableChildInstructions option.

1.6 Additional Sources

SourceMechanism
Env varCOPILOT_CUSTOM_INSTRUCTIONS_DIRS — comma-separated list of additional directories to scan
OrganizationRuntimeContext.organizationCustomInstructions — injected at runtime via API (not file-based)

1.7 Merge Order

Instructions are concatenated in this order (all additive):

  1. User global (~/.copilot/copilot-instructions.md)

  2. Repo-level instruction files (all patterns above)

  3. VSCode-style instruction files (repo, then user)

  4. CWD-specific overrides (when cwd ≠ repo root)

  5. Child/nested instructions

  6. Organization instructions (API-injected)

Duplicate content is deduplicated by file content hash.


2. Skills

Reusable prompt-based capabilities exposed as /skill-name slash commands.

2.1 Discovery Paths

SourceFile PatternCode Reference
Repo (Copilot){repo}/.github/skills/*/SKILL.mdloader.ts collectProjectDirs
Repo (Agents){repo}/.agents/skills/*/SKILL.mdloader.ts collectProjectDirs
Repo (Claude){repo}/.claude/skills/*/SKILL.mdloader.ts collectProjectDirs
User (Copilot)~/.copilot/skills/*/SKILL.mdloader.ts personalDirs
User (Claude)~/.claude/skills/*/SKILL.mdloader.ts personalDirs
Env varDirs listed in COPILOT_SKILLS_DIRS (comma-separated)loader.ts
Plugins{pluginRoot}/skills/*/SKILL.mdskills.ts

2.2 File Structure

Each skill is a directory containing a SKILL.md file with YAML frontmatter:

.github/skills/ my-skill/ SKILL.md markdown with frontmatter

Or a flat SKILL.md directly in the skills directory (single-skill mode).

2.3 Frontmatter Schema

--- name: skill-name # Optional; derived from folder name if absent description: "What this skill does" # Optional; derived from first 3 lines of body allowed-tools: grep,view # Comma-separated tool whitelist (optional) user-invocable: true # Whether user can invoke via slash command (default: true) disable-model-invocation: false # Whether model can invoke autonomously (default: false) --- Skill prompt content here...

3. Commands

A variant of skills, loaded from .claude/commands/ only.

SourceFile PatternCode Reference
Project{repo}/.claude/commands/*.mdloader.ts getCommandDirectories
User~/.claude/commands/*.mdloader.ts getCommandDirectories

Note: Commands use only the .claude/ convention — not .github/ or .agents/.

Any .md file in the directory is treated as a command. Same frontmatter schema as skills. Treated internally as skills with isCommand: true. Skills take priority over commands on name conflicts.


4. Custom Agents

Sub-agent definitions available via the task tool or direct user selection.

4.1 Discovery Paths

SourceFile PatternCode Reference
Repo (Copilot){repo}/.github/agents/*.md, *.agent.mduseCustomAgents.ts
Repo (Claude){repo}/.claude/agents/*.md, *.agent.mduseCustomAgents.ts
User (Copilot)~/.github/agents/*.md, *.agent.mduseCustomAgents.ts
User (Claude)~/.claude/agents/*.md, *.agent.mduseCustomAgents.ts
Plugins{pluginRoot}/agents/*.md, *.agent.mdagent-loader.ts
Builtinsrc/agents/definitions/*.agent.yamlYAML agent loader

4.2 Priority Rules

  • *.agent.md takes precedence over *.md when both exist for the same base name.

  • .github/agents/ sources have higher priority than .claude/agents/.

4.3 Frontmatter Schema

--- name: agent-name displayName: "Human-Readable Name" description: "What this agent does" tools: ["*"] # or ["tool1", "tool2"] — required model: claude-sonnet-4-20250514 # Optional model override disableModelInvocation: false # Cannot be auto-invoked as a tool userInvocable: true # User can select it mcp-servers: # Inline MCP server config (optional) server-name: command: "npx" args: ["@some/mcp-server"] --- Agent system prompt content here... Supports {{cwd}} placeholder.

5. MCP Servers

Model Context Protocol servers that expose additional tools and resources.

5.1 Config Sources (merge order, last wins)

PrioritySourceFile PatternCode Reference
1 (lowest)User~/.copilot/mcp-config.jsonmcp-config.ts
2Workspace{cwd}/.mcp.jsonmcpConfigMerger.ts
3VSCode{cwd}/.vscode/mcp.jsonvsCodeWorkspaceMcpConfig.ts
4Plugins{pluginRoot}/.mcp.json, {pluginRoot}/.github/mcp.jsonmcp-loader.ts
5Windows ODRRegistry HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\McpodrMcpRegistry.ts
6 (highest)CLI flag--additional-mcp-config <json|@filepath>mcpConfigMerger.ts

5.2 Config Schema

{ "mcpServers": { "server-name": { "type": "local | http | sse", "command": "path/to/server", "args": ["--flag"], "cwd": "/optional/working/dir", "env": { "KEY": "$ENV_VAR", "URL": "https://${HOST}:${PORT}", "WITH_DEFAULT": "${VAR:-fallback}" }, "url": "https://remote-server/endpoint", "headers": { "Authorization": "Bearer ${TOKEN}" }, "tools": ["*"], "timeout": 30000, "filterMapping": "hidden_characters | markdown | none", "displayName": "My Server", "oauthClientId": "client-id", "oauthPublicClient": false } } }

Environment variable expansion: $VAR, ${VAR}, ${VAR:-default} are all supported in env, args, url, and headers fields.


6. Hooks

Scripts that execute at specific agent lifecycle events, with the ability to approve/deny/modify behavior.

6.1 Config Sources

SourceFile PatternCode Reference
Config dirs{configDir}/**/*.jsonhookConfigLoader.ts
Plugins{pluginRoot}/hooks.jsonhooks.ts
Plugins (alt){pluginRoot}/hooks/hooks.jsonhooks.ts
Plugin manifestInline in plugin.jsonhooks field (object)hooks.ts

6.2 Hook Events

EventTriggerCan Modify?
sessionStartSession beginsNo (informational)
sessionEndSession endsNo (informational)
userPromptSubmittedUser sends a messageYes (can modify prompt)
preToolUseBefore tool executionYes (allow / deny / modify args)
postToolUseAfter tool executionYes (can modify result)
errorOccurredError happensYes (retry / skip / abort)
agentStopMain agent finishesYes (can force continuation)
subagentStopSub-agent completesYes (can force continuation)

6.3 Config Schema

{ "version": 1, "hooks": { "preToolUse": [ { "type": "command", "command": "bash", "args": ["-c", "echo checking"], "cwd": "/optional/cwd", "env": { "KEY": "value" }, "timeout": 30000 } ] } }

7. Plugins

Bundles that install combinations of skills, agents, hooks, and MCP servers.

7.1 Plugin Manifest Locations

Within a plugin repository, the manifest is searched at:

File PatternCode Reference
plugin.jsonmarketplace-loader.ts PLUGIN_JSON_PATHS
.github/plugin/plugin.jsonmarketplace-loader.ts PLUGIN_JSON_PATHS
.claude-plugin/plugin.jsonmarketplace-loader.ts PLUGIN_JSON_PATHS

Each field (skills, agents, hooks) can be a string path, array of paths, or (for hooks) an inline object.


Appendix A: XDG Base Directory Compliance

All ~/.copilot/ paths respect XDG overrides:

TypeDefaultXDG Override
Config files~/.copilot/$XDG_CONFIG_HOME/.copilot/
State/cache~/.copilot/$XDG_STATE_HOME/.copilot/

The base directory name is always .copilot (APP_DIRECTORY in path-helpers.ts).


Appendix B: Complete Discovery Summary

Message received Feature flags resolved Tier defaults config.json feature_flags.enabled Env vars (COPILOT_CLI_ENABLED_FEATURE_FLAGS, individual) System prompt assembled Base agent prompt User instructions ~/.copilot/copilot-instructions.md Repo instructions .github/copilot-instructions.md, AGENTS.md, CLAUDE.md, GEMINI.md VSCode instructions .github/instructions/**/*.instructions.md CWD instructions (when cwd repo root) Child instructions (depth=2 traversal) Org instructions (API-injected) Tools assembled Built-in tools MCP servers ~/.copilot/mcp-config.json + .mcp.json + .vscode/mcp.json + plugins Content exclusion (org API restrictions applied) Skills listed .github/skills/ + .agents/skills/ + .claude/skills/ + personal + plugins Commands listed .claude/commands/ + personal Custom agents listed .github/agents/ + .claude/agents/ + personal + plugins userPromptSubmitted hooks fire Model selected config.json model, agent override, or default For each tool call: preToolUse hooks (allow / deny / modify) Permission check Firewall policy Tool executes postToolUse hooks (modify result) Session telemetry emitted