Guide for improving GitHub Copilot Agent performance through skills, custom instructions, AGENTS.md, or other configuration. Use this when asked to improve agent behavior, create/update skills, modify custom instructions, update AGENTS.md, or customize GitHub Copilot performance in repositories.
Guide for improving GitHub Copilot Agent performance through skills, custom instructions, AGENTS.md, or other methods.
What this skill covers: Improving GitHub Copilot Agent performance through multiple approaches including Skills, Custom Instructions, AGENTS.md, and path-specific instructions. Learn when to use each method and how to implement them.
Instruction types:
.github/instructions/NAME.instructions.mdAGENTS.md wins) → DetailsDecision: Need it for 80%+ of tasks? → Custom Instructions. Specific workflows only? → Skill. Different rules per directory? → Path-specific or AGENTS.md.
→ See detailed decision guide
Key principles:
Improvement process: 0. Identify what needs improvement (agent understanding, task execution, domain knowledge, etc.). Ask the user questions if you aren't sure. → See Step 0
.github/copilot-instructions.md → Setup guideAGENTS.md in relevant directory → AGENTS.md guideWriting best practices: → Effective instructions, What NOT to include, Testing approach, Troubleshooting
Naming: lowercase-with-hyphens, under 64 chars, verb-led (e.g., rotate-pdf, debug-github-actions)
Agent improvement methods overview: → See all methods
SKILL.md structure:
name: Unique identifier, lowercase with hyphensdescription: What it does AND when Copilot should use it (this is how Copilot decides to load the skill)license (optional): License informationHow Copilot uses skills: When performing tasks, Copilot decides when to use skills based on your prompt and the skill's description. When Copilot chooses a skill, the SKILL.md file is injected into the agent's context. → Content tips
Skills provide:
Custom instructions provide:
AGENTS.md provides:
Path-specific instructions provide:
First 50 lines are critical: Copilot often only reads the beginning of files. Structure skills with essential content and navigation first, detailed sections below. Expect Copilot to read the first 50 lines, then jump to specific sections as needed.
Quick Reference with navigation is REQUIRED: Every skill must have a comprehensive Quick Reference section with:
Be iterative: Don't aim for comprehensive coverage in first draft. Skills improve over time through real usage. Start concise and focused, add details as patterns emerge.
Keep it focused: If a skill becomes too large, consider splitting into multiple focused skills rather than one comprehensive skill.
Description is key: The description field in YAML frontmatter is how Copilot decides whether to use your skill. Be comprehensive and specific about what the skill does and when it should be used.
CRITICAL: Before creating a skill, determine if custom instructions are more appropriate.
.github/copilot-instructions.md)Use custom instructions when:
Examples of custom instructions:
Benefits:
How to create: → See Custom Instructions Setup
.github/skills/)Use skills when:
Examples of skills:
Benefits:
.github/instructions/*.instructions.md)Use path-specific instructions when:
Examples of path-specific instructions:
Benefits:
How to create: → See Path-Specific Instructions
Use AGENTS.md when:
Examples of AGENTS.md usage:
AGENTS.md)Benefits:
How to create: → See Agent Instructions
Decision matrix:
| Need | Custom Instructions | Skill | Path-Specific | AGENTS.md |
|---|---|---|---|---|
| "How do I run tests?" | ✅ Yes | ❌ No | ❌ No | ❌ No |
| "How to debug GitHub Actions?" | ❌ No | ✅ Yes | ❌ No | ❌ No |
| "What's the project structure?" | ✅ Yes | ❌ No | ❌ No | ❌ No |
| "API routes need special error handling" | ❌ No | ❌ No | ✅ Yes | ✅ Possible |
| "Code style preferences" | ✅ Yes | ❌ No | ❌ No | ❌ No |
| "Frontend uses React, backend uses Express" | ❌ No | ❌ No | ✅ Yes | ✅ Yes |
| "Adding filters to Trend Analysis" | ❌ No | ✅ Yes | ❌ No | ❌ No |
Rules of thumb:
Create .github/copilot-instructions.md with general guidance for the entire repository:
# If .github directory doesn't exist:
mkdir .github
New-Item .github/copilot-instructions.md
What to include:
Example structure:
# Project Overview
This is a Next.js claims analytics app with TypeScript, Tailwind CSS, and Highcharts.
# Build & Test Commands
- Install: `npm install`
- Dev server: `npm run dev`
- Tests: `npm test` (runs Jest)
- Coverage: `npm run test:coverage`
# Project Structure
- `app/` - Next.js app directory (pages, components, API routes)
- `__tests__/` - Jest test files
- `.github/skills/` - Copilot agent skills
# Coding Standards
- Use TypeScript strict mode
- Test coverage requirement: >80%
- Always add test command comment to new test files
Pro tip: Ask Copilot to generate it for you by using the prompt from GitHub's docs.
Recommended template structure:
# [Technology or Domain Name] Guidelines
## Purpose
Brief statement of what this file covers and when these instructions apply.
## Naming Conventions
- Rule 1
- Rule 2
## Code Style
- Style rule 1
```javascript
// Example showing correct pattern
const activeUsers = users.filter(user => user.isActive);
Adapt this structure to your needs while maintaining clear sectioning and bullet-point format.
#### Path-Specific Instructions
**When to use:** Instructions that apply only to specific files, directories, or file types (not the entire repository).
**Use path-specific instructions when:**
- Different parts of your codebase have different rules (e.g., API routes vs frontend components)
- Specific directories require unique validation or patterns
- You want to avoid cluttering repository-wide instructions with niche guidance
**Examples:**
- API routes must follow specific error handling patterns
- Test files have different coding standards than production code
- Database migration files require special naming conventions
- Legacy code sections have different rules than new code
Create `.github/instructions/NAME.instructions.md` (where NAME describes the purpose):
```bash
mkdir .github/instructions
New-Item .github/instructions/api-routes.instructions.md
Add YAML frontmatter with glob pattern:
---
applyTo: "app/api/**/*.ts"
---
API routes must:
- Use Next.js App Router patterns
- Include proper error handling
- Return typed responses
Glob pattern examples:
**/*.ts - All TypeScript filesapp/components/**/*.tsx - All components__tests__/**/*.test.tsx - All test files**/database/**/* - All files in any database directoryExclude from specific agents (optional):
---
applyTo: "**/*.py"
excludeAgent: "code-review" # Only for coding-agent, not code-review
---
When combined: If a file matches both repository-wide and path-specific instructions, both sets are combined and used together.
Length limits: Keep instruction files under ~1,000 lines maximum. Beyond this, Copilot may overlook some instructions due to context limits.
Structure best practices:
Example - Before (vague):
When you're reviewing code, it would be good if you could try to look for
situations where developers might have accidentally left in sensitive
information like passwords or API keys, and also check for security issues.
Example - After (clear):
## Security Critical Issues
- Check for hardcoded secrets, API keys, or credentials
- Look for SQL injection and XSS vulnerabilities
- Verify proper input validation and sanitization
Show correct and incorrect examples:
## Naming Conventions
Use descriptive, intention-revealing names.
```javascript
// Avoid
const d = new Date();
const x = users.filter(u => u.active);
// Prefer
const currentDate = new Date();
const activeUsers = users.filter(user => user.isActive);
**Understanding Copilot's limitations:**
- **Non-deterministic behavior** - Copilot may not follow every instruction perfectly every time
- **Context limits** - Very long instruction files may result in some instructions being overlooked
- **Specificity matters** - Clear, specific instructions work better than vague directives
#### What NOT to Include in Instructions
Copilot currently **does not support** instructions that attempt to:
**Change user experience or formatting:**
- ❌ "Use bold text for critical issues"
- ❌ "Change the format of review comments"
- ❌ "Add emoji to comments"
**Modify pull request overview comments:**
- ❌ "Include a summary of security issues in the PR overview"
- ❌ "Add a testing checklist to the overview comment"
**Change Copilot's core function:**
- ❌ "Block a PR from merging unless all comments are addressed"
- ❌ "Generate a changelog entry for every PR"
**Follow external links:**
- ❌ "Review this code according to https://example.com/standards"
- ✅ **Workaround:** Copy the relevant content directly into your instruction file
**Vague quality improvements:**
- ❌ "Be more accurate"
- ❌ "Don't miss any issues"
- ❌ "Be consistent in your feedback"
These types of instructions add noise without improving effectiveness.
#### Testing and Iterating
**Start small:** Begin with 10-20 specific instructions addressing your most common needs, then iterate based on results.
**Test with real work:**
1. Save your instruction files
2. Use Copilot on real tasks or PRs
3. Observe which instructions it follows effectively
4. Note instructions that are consistently missed or misinterpreted
**Iterate based on results:**
1. Identify a pattern that Copilot could handle better
2. Add a specific instruction for that pattern
3. Test with new work
4. Refine the instruction based on results
This iterative approach helps you understand what works and keeps files focused.
#### Troubleshooting
**Issue: Instructions are ignored**
Possible causes:
- Instruction file is too long (over 1,000 lines)
- Instructions are vague or ambiguous
- Instructions conflict with each other
Solutions:
- Shorten the file by removing less important instructions
- Rewrite vague instructions to be more specific and actionable
- Review for conflicting instructions and prioritize the most important ones
**Issue: Language-specific rules applied to wrong files**
Possible causes:
- Missing or incorrect `applyTo` frontmatter
- Rules in repository-wide file instead of path-specific file
Solutions:
- Add `applyTo` frontmatter to path-specific instruction files
- Move language-specific rules from `copilot-instructions.md` to appropriate `*.instructions.md` files
**Issue: Inconsistent behavior across sessions**
Possible causes:
- Instructions are too numerous
- Instructions lack specificity
- Natural variability in AI responses
Solutions:
- Focus on your highest-priority instructions
- Add concrete examples to clarify intent
- Accept that some variability is normal for AI systems
**Additional resources:**
- See [example custom instructions](https://github.com/github/awesome-copilot/tree/main/instructions) in the Awesome GitHub Copilot repository for inspiration
- Read [Configure custom instructions for GitHub Copilot](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions) for technical details
#### Agent Instructions (AGENTS.md)
**When to use:** Instructions specifically for AI agents, with hierarchical directory-based precedence.
**Use AGENTS.md when:**
- You want instructions that follow your directory structure (nearest file takes precedence)
- Different subdirectories need different agent behaviors
- You're building a multi-module project where each module has unique patterns
- You want agent-specific instructions separate from general custom instructions
**How AGENTS.md works:**
- Place `AGENTS.md` files anywhere in your repository
- When Copilot is working on a file, it uses the **nearest** `AGENTS.md` in the directory tree
- Closer `AGENTS.md` files override instructions from parent directories
**Example structure:**
project-root/ ├── AGENTS.md # General project-wide agent instructions ├── src/ │ ├── frontend/ │ │ ├── AGENTS.md # Frontend-specific instructions (overrides root) │ │ └── components/ │ └── backend/ │ ├── AGENTS.md # Backend-specific instructions (overrides root) │ └── api/ └── tests/ └── AGENTS.md # Test-specific instructions (overrides root)
**Use case example:**
```markdown
# Root AGENTS.md
Use TypeScript strict mode. Always write tests for new features.
# src/frontend/AGENTS.md
Frontend code must:
- Use React hooks, not class components
- Implement responsive design with Tailwind CSS
- Test with React Testing Library
# src/backend/AGENTS.md
Backend code must:
- Use Express.js patterns
- Validate all inputs with Zod
- Test with Supertest
When working on src/frontend/App.tsx, Copilot uses src/frontend/AGENTS.md (not root).
When working on src/backend/routes.ts, Copilot uses src/backend/AGENTS.md (not root).
Alternative: Agent-specific files in root
Instead of multiple AGENTS.md files, you can use a single agent-specific file in your repository root:
CLAUDE.md - Instructions for Claude-based agentsGEMINI.md - Instructions for Gemini-based agentsThese root-level files are simpler but don't support directory-based precedence.
AGENTS.md vs copilot-instructions.md:
Recommendation: For GitHub Copilot projects, prefer copilot-instructions.md and path-specific instructions unless you need directory-based precedence.
Verify usage: In Copilot Chat, check the "References" section of responses to see if .github/copilot-instructions.md is listed.
.github/copilot-instructions.md)Avoid conflicts: Try not to provide contradictory guidance across different instruction types.
Match specificity to task fragility:
What NOT to include in skills: README.md, INSTALLATION_GUIDE.md, CHANGELOG.md, etc. Only include essential information for task execution.
Remember: Build commands, project structure, and coding standards belong in custom instructions, not skills!
Note: Use this section when you've determined that creating or updating a skill is the best approach for improving agent performance.
Clarify concrete examples of skill usage. For a workflow debugging skill, ask:
Avoid overwhelming with too many questions at once. Conclude when functionality is clear.
Create the skill directory and SKILL.md file in .github/skills/:
mkdir .github/skills/<skill-name>
New-Item .github/skills/<skill-name>/SKILL.md
Note: Skill files must be named SKILL.md (case-sensitive).
Write YAML frontmatter:
---