Copilot instructions
extensions/copilot/.github/copilot-instructions.mdCopilot instructions
Quality
81/100
Scores the file, not the repository.Length
2,182 words
40 headings · 2 code blocksRepository
188k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# GitHub Copilot Chat Extension - Copilot Instructions23## Project Overview45This is the **GitHub Copilot Chat** extension for Visual Studio Code - a VS Code extension that provides conversational AI assistance, a coding agent with many tools, inline editing capabilities, and advanced AI-powered features for VS Code.67### Key Features8- **Chat Interface**: Conversational AI assistance with chat participants, variables, and slash commands9- **Inline Chat**: AI-powered editing directly in the editor with `Ctrl+I`10- **Agent Mode**: Multi-step autonomous coding tasks11- **Edit Mode**: Natural language to code12- **Inline Suggestions**: Next edit suggestions and inline completions13- **Language Model Integration**: Support for multiple AI models (GPT-4, Claude, Gemini, etc.)14- **Context-Aware**: Workspace understanding, semantic search, and code analysis1516### Tech Stack17- **TypeScript**: Primary language (follows VS Code coding standards)18- **TSX**: Prompts are built using the @vscode/prompt-tsx library19- **Node.js**: Runtime for extension host and language server features20- **WebAssembly**: For performance-critical parsing and tokenization21- **VS Code Extension API**: Extensive use of proposed APIs for chat, language models, and editing22- **ESBuild**: Bundling and compilation23- **Vitest**: Unit testing framework24- **Python**: For notebooks integration and ML evaluation scripts2526## Validating changes2728Choose validation based on the scope and risk of the change. Prefer existing diagnostics and the smallest targeted tests that cover the changed behavior. Do not start `start-watch-tasks`, run a full build, or make type checking a prerequisite for targeted tests solely as a completion ritual.2930If `start-watch-tasks` is already running, use its diagnostics. Start it or run another targeted type check or build when existing diagnostics are unavailable, the change is broad or cross-cutting, it affects build or type configuration, or another validation step reports a compilation problem. `start-watch-tasks` runs the extension, extension-web, simulation-workbench, and esbuild watchers.3132## Project Architecture3334### Top-Level Directory Structure3536#### Core Source Code (`src/`)37- **`src/extension/`**: Main extension implementation, organized by feature38- **`src/platform/`**: Shared platform services and utilities39- **`src/util/`**: Common utilities, VS Code API abstractions, and service infrastructure4041#### Build & Configuration42- **`.esbuild.mts`**: Build configuration for bundling extension, web worker, and simulation workbench43- **`tsconfig.json`**: TypeScript configuration extending base config with React JSX settings44- **`vite.config.ts`**: Test configuration for Vitest unit tests45- **`package.json`**: Extension manifest with VS Code contributions, dependencies, and scripts4647#### Testing & Simulation48- **`test/`**: Comprehensive test suite including unit, integration, and simulation tests49- **`script/simulate.sh`**: Test runner for scenario-based testing50- **`notebooks/`**: Jupyter notebooks for performance analysis and ML experiments5152#### Assets & Documentation53- **`assets/`**: Icons, fonts, and visual resources54- **`CONTRIBUTING.md`**: Architecture documentation and development guide5556### Key Source Directories5758#### `src/extension/` - Feature Implementation5960**Core Chat & Conversation Features:**61- **`conversation/`**: Chat participants, agents, and conversation flow orchestration62- **`inlineChat/`**: Inline editing features (`Ctrl+I`) and hints system63- **`inlineEdits/`**: Advanced inline editing capabilities with streaming edits6465**Context & Intelligence:**66- **`context/`**: Context resolution for code understanding and workspace analysis67- **`contextKeys/`**: VS Code context key management for UI state68- **`intents/`**: Chat participant/slash command implementations69- **`prompts/`**: Prompt engineering and template system70- **`prompt/`**: Common prompt utilities71- **`typescriptContext/`**: TypeScript-specific context and analysis7273**Search & Discovery:**74- **`search/`**: General search functionality within the extension75- **`workspaceChunkSearch/`**: Chunked workspace search for large codebases76- **`workspaceSemanticSearch/`**: Semantic search across workspace content77- **`workspaceRecorder/`**: Recording and tracking workspace interactions7879**Authentication & Configuration:**80- **`authentication/`**: GitHub authentication and token management81- **`configuration/`**: Settings and configuration management82- **`byok/`**: Bring Your Own Key (BYOK) functionality for custom API keys8384**AI Integration & Endpoints:**85- **`endpoint/`**: AI service endpoints and model selection86- **`tools/`**: Language model tools and integrations87- **`api/`**: Core API abstractions and interfaces88- **`mcp/`**: Model Context Protocol integration8990**Development & Testing:**91- **`testing/`**: Test generation and execution features92- **`test/`**: Extension-specific test utilities and helpers9394**User Interface & Experience:**95- **`commands/`**: Service for working with VS Code commands96- **`codeBlocks/`**: Streaming code block processing97- **`linkify/`**: URL and reference linkification98- **`getting-started/`**: Onboarding and setup experience99- **`onboardDebug/`**: Debug onboarding flows100- **`survey/`**: User feedback and survey collection101102**Specialized Features:**103- **`notebook/`**: Notebook integration and support104- **`review/`**: Code review and PR integration features105- **`renameSuggestions/`**: AI-powered rename suggestions106- **`ignore/`**: File and pattern ignore functionality107- **`xtab/`**: Cross-tab communication and state management108109**Infrastructure & Utilities:**110- **`extension/`**: Core extension initialization and lifecycle111- **`log/`**: Logging infrastructure and utilities112- **`telemetry/`**: Analytics and usage tracking113114**VS Code API Type Definitions:**115- Multiple `vscode.proposed.*.d.ts` files for proposed VS Code APIs including chat, language models, embeddings, and various editor integrations116117#### `src/platform/` - Platform Services118- **`chat/`**: Core chat services and conversation options119- **`openai/`**: OpenAI API protocol integration and request handling120- **`embedding/`**: Vector embeddings for semantic search121- **`parser/`**: Code parsing and AST analysis122- **`search/`**: Workspace search and indexing123- **`telemetry/`**: Analytics and usage tracking124- **`workspace/`**: Workspace understanding and file management125- **`notebook/`**: Notebook integration126- **`git/`**: Git integration and repository analysis127128#### `src/util/` - Infrastructure129- **`common/`**: Shared utilities, service infrastructure, and abstractions130- **`vs/`**: Utilities borrowed from the microsoft/vscode repo (readonly)131132### Extension Activation Flow1331341. **Base Activation** (`src/extension/extension/vscode/extension.ts`):135 - Checks VS Code version compatibility136 - Creates service instantiation infrastructure137 - Initializes contribution system1381392. **Service Registration**:140 - Platform services (search, parsing, telemetry, etc.)141 - Extension-specific services (chat, authentication, etc.)142 - VS Code integrations (commands, providers, etc.)1431443. **Contribution Loading**:145 - Chat participants146 - Language model providers147 - Command registrations148 - UI contributions (views, menus, etc.)149150### Chat System Architecture151152#### Chat Participants153- **Default Agent**: Main conversational AI assistant154- **Setup Agent**: Handles initial Copilot setup and onboarding155- **Workspace Agent**: Specialized for workspace-wide operations156- **Agent Mode**: Autonomous multi-step task execution157158#### Request Processing1591. **Input Parsing**: Parse user input for participants, variables, slash commands1602. **Context Resolution**: Gather relevant code context, diagnostics, workspace info1613. **Prompt Construction**: Build prompts with context and intent detection1624. **Model Interaction**: Send requests to appropriate language models1635. **Response Processing**: Parse and interpret AI responses1646. **Action Execution**: Apply code edits, show results, handle follow-ups165166#### Language Model Integration167- Support for multiple providers (OpenAI, Anthropic, etc.)168- Model selection and switching capabilities169- Quota management and fallback handling170- Custom instruction integration171172### Inline Chat System173- **Hint System**: Smart detection of natural language input for inline suggestions174- **Intent Detection**: Automatic detection of user intent (explain, fix, refactor, etc.)175- **Context Collection**: Gather relevant code context around cursor/selection176- **Streaming Edits**: Real-time application of AI-suggested changes177- **Version 2**: New implementation with improved UX and hide-on-request functionality178179## Coding Standards180181### TypeScript/JavaScript Guidelines182- **Indentation**: Use **tabs**, not spaces183- **Naming Conventions**:184 - `PascalCase` for types and enum values185 - `camelCase` for functions, methods, properties, and local variables186 - Use descriptive, whole words in names187- **Strings**:188 - "double quotes" for user-visible strings that need localization189 - 'single quotes' for internal strings190- **Functions**: Use arrow functions `=>` over anonymous function expressions191- **Conditionals**: Always use curly braces, opening brace on same line192- **Comments**: Use JSDoc style for functions, interfaces, enums, and classes193194### React/JSX Conventions195- Custom JSX factory: `vscpp` (instead of React.createElement)196- Fragment factory: `vscppf`197- Components follow VS Code theming and styling patterns198199### Architecture Patterns200- **Service-oriented**: Heavy use of dependency injection via `IInstantiationService`201- **Contribution-based**: Modular system where features register themselves202- **Event-driven**: Extensive use of VS Code's event system and disposables203- **Layered**: Clear separation between platform services and extension features204205### Testing Standards206- **Unit Tests**: Vitest for isolated component testing207- **Integration Tests**: VS Code extension host tests for API integration208- **Simulation Tests**: End-to-end scenario testing with `.stest.ts` files209- **Fixtures**: Comprehensive test fixtures for various scenarios210211### File Organization212- **Logical Grouping**: Features grouped by functionality, not technical layer213- **Platform Separation**: Different implementations for web vs. Node.js environments214- **Test Proximity**: Tests close to implementation (`/test/` subdirectories)215- **Clear Interfaces**: Strong interface definitions for service boundaries216217## Key Development Guidelines218219### Arrow Functions and Parameters220- Use arrow functions `=>` over anonymous function expressions221- Only surround arrow function parameters when necessary:222223```javascript224x => x + x // ✓ Correct225(x, y) => x + y // ✓ Correct226<T>(x: T, y: T) => x === y // ✓ Correct227(x) => x + x // ✗ Wrong228```229230### Code Structure231- Always surround loop and conditional bodies with curly braces232- Open curly braces always go on the same line as whatever necessitates them233 - An open curly brace MUST be followed by a newline, with the body indented on the next line234- Parenthesized constructs should have no surrounding whitespace235- Single space follows commas, colons, and semicolons236237```javascript238for (let i = 0, n = str.length; i < 10; i++) {239 if (x < 10) {240 foo();241 }242}243244function f(x: number, y: string): void { }245```246247### Type Management248- Do not export `types` or `functions` unless you need to share it across multiple components249- Do not introduce new `types` or `values` to the global namespace250- Use proper types. Do not use `any` unless absolutely necessary.251- Use `readonly` whenever possible.252- Avoid casts in TypeScript unless absolutely necessary. If you get type errors after your changes, look up the types of the variables involved and set up a proper system of types and interfaces instead of adding type casts.253- Do not use `any` or `unknown` as the type for variables, parameters, or return values unless absolutely necessary. If they need type annotations, they should have proper types or interfaces defined.254255## Key APIs and Integrations256257### VS Code Proposed APIs (Enabled)258The extension uses numerous proposed VS Code APIs for advanced functionality:259- `chatParticipantPrivate`: Private chat participant features260- `languageModelSystem`: System messages for LM API261- `chatProvider`: Custom chat provider implementation262- `mappedEditsProvider`: Advanced editing capabilities263- `inlineCompletionsAdditions`: Enhanced inline suggestions264- `aiTextSearchProvider`: AI-powered search capabilities265266### External Integrations267- **GitHub**: Authentication and API access268- **Azure**: Cloud services and experimentation269- **OpenAI**: Language model API270- **Anthropic**: Claude model integration - See **[src/extension/agents/claude/AGENTS.md](../src/extension/agents/claude/AGENTS.md)** for complete Claude Agent SDK integration documentation including architecture, components, and registries271- **Telemetry**: Usage analytics and performance monitoring272273## Development Workflow274275### Setup and Build276- `npm install`: Install dependencies277- `npm run compile`: Development build278- `npm run watch:*`: Various watch modes for development279280### Updating Dependencies281282**Anthropic SDK Packages:**283When updating `@anthropic-ai/claude-agent-sdk` or `@anthropic-ai/sdk`, you **MUST** follow the upgrade guide in **[src/extension/agents/claude/AGENTS.md](../src/extension/agents/claude/AGENTS.md#upgrading-anthropic-sdk-packages)**. This includes:2841. Reviewing changelogs for breaking changes2852. Checking compilation errors in key Claude integration files2863. Running through the testing checklist for core functionality, tools, hooks, and slash commands287288### Testing289- `npm run test:unit`: Unit tests290- `npm run test:extension`: VS Code integration tests291- `npm run simulate`: Scenario-based simulation tests292293### Key Entry Points for Edits294295**Chat & Conversation Features:**296- **Adding new chat features**: Start in `src/extension/conversation/`297- **Chat participants and agents**: Look in `src/extension/conversation/` for participant implementations298- **Conversation storage**: Modify `src/extension/conversationStore/` for persistence features299- **Inline chat improvements**: Look in `src/extension/inlineChat/` and `src/extension/inlineEdits/`300301**Context & Intelligence:**302- **Context resolution changes**: Check `src/extension/context/` and `src/extension/typescriptContext/`303- **Prompt engineering**: Update `src/extension/prompts/` and `src/extension/prompt/`304- **Intent detection**: Modify `src/extension/intents/` for user intent classification305306**Search & Discovery:**307- **Search functionality**: Update `src/extension/search/` for general search308- **Workspace search**: Modify `src/extension/workspaceChunkSearch/` for large codebase search309- **Semantic search**: Edit `src/extension/workspaceSemanticSearch/` for AI-powered search310- **Workspace tracking**: Update `src/extension/workspaceRecorder/` for interaction recording311312**Authentication & Configuration:**313- **Authentication flows**: Modify `src/extension/authentication/` for GitHub integration314- **Settings and config**: Update `src/extension/configuration/` and `src/extension/settingsSchema/`315- **BYOK features**: Edit `src/extension/byok/` for custom API key functionality316317**AI Integration:**318- **AI endpoints**: Update `src/extension/endpoint/` for model selection and routing319- **Language model tools**: Modify `src/extension/tools/` for AI tool integrations320- **API abstractions**: Edit `src/extension/api/` for core interfaces321- **MCP integration**: Update `src/extension/mcp/` for Model Context Protocol features322323**User Interface:**324- **VS Code commands**: Update `src/extension/commands/` for command implementations325- **Code block rendering**: Modify `src/extension/codeBlocks/` for code display326- **Onboarding flows**: Edit `src/extension/getting-started/` and `src/extension/onboardDebug/`327- **Cross-tab features**: Update `src/extension/xtab/` for multi-tab coordination328329**Testing & Development:**330- **Test generation**: Modify `src/extension/testing/` for AI-powered test creation331- **Extension tests**: Update `src/extension/test/` for extension-specific test utilities332333**Platform Services:**334- **Core platform services**: Extend `src/platform/` services for cross-cutting functionality335- **VS Code integration**: Update contribution files and extension activation code336- **Configuration**: Modify `package.json` contributions for VS Code integration337338This extension is a complex, multi-layered system that provides comprehensive AI assistance within VS Code. Understanding the service architecture, contribution system, and separation between platform and extension layers is crucial for making effective changes.339340## Best Practices341- Use services and dependency injection over VS Code extension APIs when possible:342 - Use `IFileSystemService` instead of Node's `fs` or `vscode.workspace.fs`343 - Use `ILogService` instead of `console.log`344 - Look for existing `I*Service` interfaces before reaching for raw APIs345 - **Why**: Enables unit testing without VS Code host, supports simulation tests, provides cross-platform abstractions (Node vs web), and adds features like caching and size limits346- Always use the URI type instead of using string file paths. There are many helpers available for working with URIs.347
Also in microsoft/vscode
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| microsoft/vscode.github/instructions/accessibility.instructions.md · 188k | Copilot instructions | styledo-not | 61/100 | 3 days ago | |
| microsoft/vscode.github/instructions/chat.instructions.md · 188k | Copilot instructions | no sections | 39/100 | 3 days ago | |
| microsoft/vscodeextensions/copilot/src/platform/authentication/common/AGENTS.md · 188k | AGENTS.md | archsecurityagent-behaviour | 58/100 | 3 days ago | |
| microsoft/vscode.github/copilot-instructions.md · 188k | Copilot instructions | stylearchtypesui+2 | 74/100 | 2 days ago | |
| microsoft/vscode.github/instructions/agentHostTesting.instructions.md · 188k | Copilot instructions | teststyletesting-strategyagent-behaviour | 55/100 | 3 days ago | |
| microsoft/vscode.github/instructions/ai-customization.instructions.md · 188k | Copilot instructions | archtypesui | 58/100 | 3 days ago | |
| microsoft/vscode.github/instructions/best-practices.instructions.md · 188k | Copilot instructions | styleui | 60/100 | 3 days ago | |
| microsoft/vscode.github/instructions/buildNext.instructions.md · 188k | Copilot instructions | setupbuildtestarch+1 | 66/100 | 3 days ago | |
| microsoft/vscode.github/instructions/coding-guidelines.instructions.md · 188k | Copilot instructions | styletypesuidocs | 60/100 | 3 days ago | |
| microsoft/vscode.github/instructions/committing.instructions.md · 188k | Copilot instructions | do-not | 23/100 | 3 days ago | |
| microsoft/vscode.github/instructions/css-best-practices.instructions.md · 188k | Copilot instructions | styleui | 29/100 | 3 days ago | |
| microsoft/vscode.github/instructions/design-philosophy.instructions.md · 188k | Copilot instructions | style | 34/100 | 3 days ago | |
| microsoft/vscode.github/instructions/design-tokens.instructions.md · 188k | Copilot instructions | styledo-not | 65/100 | 3 days ago | |
| microsoft/vscode.github/instructions/disposable.instructions.md · 188k | Copilot instructions | no sections | 16/100 | 3 days ago | |
| microsoft/vscode.github/instructions/interactive.instructions.md · 188k | Copilot instructions | ui | 43/100 | 3 days ago | |
| microsoft/vscode.github/instructions/kusto.instructions.md · 188k | Copilot instructions | agent-behaviour | 16/100 | 3 days ago | |
| microsoft/vscode.github/instructions/learnings.instructions.md · 188k | Copilot instructions | style | 40/100 | 3 days ago | |
| microsoft/vscode.github/instructions/notebook.instructions.md · 188k | Copilot instructions | no sections | 48/100 | 3 days ago | |
| microsoft/vscode.github/instructions/observables.instructions.md · 188k | Copilot instructions | no sections | 40/100 | 3 days ago | |
| microsoft/vscode.github/instructions/oss-third-party-notices.instructions.md · 188k | Copilot instructions | buildgitdependenciesdeployment+1 | 65/100 | 3 days ago |
Diff against .github/instructions/accessibility.instructions.md Diff against .github/instructions/chat.instructions.md Diff against extensions/copilot/src/platform/authentication/common/AGENTS.md Diff against .github/copilot-instructions.md Diff against .github/instructions/agentHostTesting.instructions.md Diff against .github/instructions/ai-customization.instructions.md Diff against .github/instructions/best-practices.instructions.md Diff against .github/instructions/buildNext.instructions.md Diff against .github/instructions/coding-guidelines.instructions.md Diff against .github/instructions/committing.instructions.md Diff against .github/instructions/css-best-practices.instructions.md Diff against .github/instructions/design-philosophy.instructions.md Diff against .github/instructions/design-tokens.instructions.md Diff against .github/instructions/disposable.instructions.md Diff against .github/instructions/interactive.instructions.md Diff against .github/instructions/kusto.instructions.md Diff against .github/instructions/learnings.instructions.md Diff against .github/instructions/notebook.instructions.md Diff against .github/instructions/observables.instructions.md Diff against .github/instructions/oss-third-party-notices.instructions.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| chihebnabil/lovable-boilerplate.github/instructions/global.instructions.md · 63 | Copilot instructions | buildlint-formatstylearch+4 | 100/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.github/copilot-instructions.md · 17 | Copilot instructions | setupbuildtestlint-format+7 | 100/100 | 3 days ago | |
| louislam/uptime-kuma.github/copilot-instructions.md · 90k | Copilot instructions | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| JCodesMore/ai-website-cloner-template.github/copilot-instructions.md · 31k | Copilot instructions | buildlint-formatstylearch+3 | 97/100 | 2 days ago | |
| bagisto/bagisto.github/copilot-instructions.md · 28k | Copilot instructions | setupbuildteststyle+5 | 97/100 | 3 days ago | |
| nerolis-lab/nerolis-lab.github/copilot-instructions.md · 32 | Copilot instructions | setupbuildtestlint-format+11 | 96/100 | 3 days ago | |
| thangaram611/second-brain.github/copilot-instructions.md · 0 | Copilot instructions | setupteststylearch+4 | 96/100 | 3 days ago | |
| darkmatter/nixmac.github/copilot-instructions.md · 24 | Copilot instructions | setupbuildtestlint-format+8 | 96/100 | 3 days ago |
