Create Granular Copilot Instructions
What This Skill Does
Creates properly structured granular instruction files (.instructions.md) for GitHub Copilot in VS Code following the custom instructions documentation. These files provide targeted, file-type-specific guidance that activates only when Copilot is working with matching files.
Granular instructions are the conditional layer of Copilot customization — they complement the universal .github/copilot-instructions.md by adding context-specific conventions that would be too verbose or irrelevant in the core file.
Key Concepts: Granular Instructions vs Other Customizations
Understanding the separation of concerns is critical for effective granular instructions. Each customization mechanism has a distinct purpose:
| Component | Defines | Analogy | File Type |
|---|---|---|---|
| Core Instructions | Universal project context for ALL interactions | The company handbook | .github/copilot-instructions.md |
| Granular Instructions | Context-specific conventions for MATCHING files | Department-specific guidelines | .github/instructions/*.instructions.md |
| Custom Agent | WHO the AI is and HOW it behaves | The employee's role and personality | .agent.md |
| Agent Skill | Reusable CAPABILITY or multi-step workflow | A specialized training module | SKILL.md in a skill directory |
| Prompt File | WHAT specific task to perform | A work order or task assignment | .prompt.md |
The Layered Instruction Architecture
GitHub Copilot supports a layered approach to custom instructions:
- Core layer (
.github/copilot-instructions.md) — Attached to EVERY Copilot conversation. Contains universal project context. - Granular layer (
.github/instructions/*.instructions.md) — Applied conditionally viaapplyToglob patterns. Contains targeted, context-specific guidance.
This skill creates the granular layer files that complement (not duplicate) the core instructions.
The Golden Rule
Granular instruction files must NEVER use
**as theapplyTopattern.
If an instruction applies everywhere, it belongs in .github/copilot-instructions.md, not in a granular file. The whole point of granular files is specificity — they activate only when working with matching files.
Step-by-step Procedure
Step 1: Discovery
Before creating any instruction files, perform systematic discovery to understand the project's technologies, architecture, and existing conventions.
Use the user's request to focus discovery on the relevant scope. If the user asks for "React component instructions," focus on component files and patterns rather than scanning the entire project.
Step 2: Interview
After discovery, gather requirements from the user. Use #tool:vscode/askQuestions if available to ask all clarifying questions in a single structured prompt. Otherwise, ask in chat.
Do NOT proceed to drafting until you have a clear understanding of the target scope and any project-specific conventions.
Step 3: Plan
Based on discovery and interview, create a plan for which instruction files to create:
- Define the file name for each instruction file (pattern:
<scope>.instructions.mdor<technology>-<purpose>.instructions.md) - Define the
applyToglob pattern for each file - Verify no overlap between patterns — each file should target a distinct set of files
- Verify no overlap with existing instruction files in
.github/instructions/
Present the plan to the user for confirmation before generating.
Step 4: Generate
Once confirmed, create the instruction files.
Use the bundled instruction-template.md as the structural starting point for each file. Fill in the placeholders with the discovered conventions.
Step 5: Validate
Before reporting completion, iterate through every check below.
Glob Pattern Reference
Effective Patterns
| Pattern | Use Case |
|---|---|
**/*.test.ts |
All TypeScript test files |
**/*.test.{ts,tsx} |
All TypeScript/TSX test files |
src/components/**/*.tsx |
React components in specific folder |
apps/*/src/**/*.ts |
TypeScript files across all apps in monorepo |
**/*.stories.{ts,tsx} |
Storybook story files |
src/api/** |
All files in API layer |
packages/ui/** |
All files in UI package |
**/migrations/** |
Database migration files |
Anti-Patterns to Avoid
| Avoid | Why | Instead |
|---|---|---|
** |
Too broad, use core instructions | Specific glob for file type/folder |
**/* |
Same as above | Be specific about scope |
*.ts |
Only matches root, misses subdirs | **/*.ts |
| Overlapping patterns | Causes confusion | Ensure mutual exclusivity |
Advanced Techniques
Differential Analysis
When the user's project has similar files that follow different conventions in different locations, use differential analysis:
- Compare how similar files differ across the codebase (e.g., components in
/features/vs/shared/components/) - Create separate instruction files with folder-specific
applyTopatterns for each convention
Pattern Triangulation
Validate conventions by checking multiple sources before codifying them in instruction files:
- Actual code patterns (what the code does)
- Linter/formatter configurations (what's enforced)
- Existing documentation (what's documented)
- Git history (what patterns have been consistent)
Boundary Testing
For each potential instruction file, evaluate scope by asking:
- "If I apply this pattern more broadly, does it still make sense?"
- "If I narrow this pattern, would I lose important context?"
The goal is finding the minimum viable scope that captures meaningful conventions.
MCP Tools
Context7
Use #tool:context7/* strategically:
- Use when: Verifying framework-specific best practices for targeted files (e.g., React 19 conventions for
*.tsx), understanding library-specific patterns, confirming testing framework conventions. - Skip when: General language conventions (Copilot knows these), or when existing codebase patterns are clear and consistent.
Sequential Thinking
Use #tool:sequentialthinking/* for complex scenarios:
- Use when: Multi-technology projects where instruction file boundaries are unclear, monorepos with different conventions across packages, inconsistent patterns in the codebase.
- Skip when: Single-technology projects with clear patterns, user has specified exactly which files to create, small codebases with obvious conventions.
Source: ikcode-dev/copilot-kit — distributed by TomeVault.