Copilot Custom Instructions Guide
Complete guide to GitHub Copilot custom instructions and copilot-instructions.md
GitHub Copilot custom instructions are a game-changer for getting consistently relevant code suggestions. Instead of Copilot guessing your preferences — which framework version, which patterns, which coding style — you tell it explicitly through a simple markdown file. The result is fewer corrections, faster coding, and suggestions that actually match your project.
This guide covers everything about Copilot custom instructions: the file format, best practices, language-specific examples, and how they compare to similar features in Cursor and Claude Code.
What You'll Learn
- What Copilot custom instructions are and how they work
- The .github/copilot-instructions.md file format
- Best practices for writing effective instructions
- Custom instructions for Python, JavaScript, Java, and more
- Comparison with .cursorrules and CLAUDE.md
- Free Copilot access for Indian students
What Are Copilot Custom Instructions?
Custom instructions are project-level rules that Copilot applies to every interaction — completions, chat, and code review. You define them in a markdown file at .github/copilot-instructions.md, and Copilot reads them automatically.
Before custom instructions, Copilot relied entirely on the open file and nearby files for context. It had no way to know your project conventions, preferred patterns, or coding standards unless it could infer them from surrounding code. Custom instructions fill that gap.
How it works:
- Create
.github/copilot-instructions.mdin your project root - Write your project conventions, preferred patterns, and rules
- Copilot reads the file and applies instructions to all interactions
- Commit the file to your repo — your entire team benefits
Custom instructions work across all editors that support Copilot: VS Code, JetBrains IDEs, Neovim, and Visual Studio.
The copilot-instructions.md File Format
The file uses standard markdown. There is no special syntax — just clear, concise instructions written in natural language. Here is the recommended structure:
# Project Instructions for GitHub Copilot
## Project Overview
E-commerce platform for Indian market. Next.js 15 frontend, Express backend.
## Tech Stack
- Frontend: Next.js 15, React 19, TypeScript 5, Tailwind CSS 4
- Backend: Express 5, TypeScript, Prisma 6
- Database: PostgreSQL 16
- Auth: NextAuth.js v5
## Coding Conventions
- TypeScript strict mode — never use `any` type
- Functional components only (no class components)
- Server Components by default in Next.js
- Async/await everywhere — no .then() chains
- Named exports for components, functions, and types
## Naming Conventions
- Components: PascalCase (UserCard.tsx)
- Functions: camelCase (getUserData)
- Constants: SCREAMING_SNAKE_CASE (MAX_RETRIES)
- Types/Interfaces: PascalCase with prefix (IUserProps, TApiResponse)
## Patterns to Follow
- Error handling: try/catch with custom error classes
- API responses: { success: boolean, data?: T, error?: string }
- Form validation: Zod schemas
- State management: React Context + useReducer for complex state
## Do Not
- Never use var — always const or let
- Never use default exports (except Next.js pages)
- Never inline styles — use Tailwind classes
- Never store sensitive data in localStorage
Best Practices for Effective Instructions
Be specific and prescriptive. "Write clean code" tells Copilot nothing. "Use TypeScript strict mode with explicit return types on all exported functions" changes behavior.
Keep instructions concise. Copilot works best with focused, scannable instructions. Aim for 50-200 lines. Avoid long prose paragraphs.
Use negative instructions. "Do Not" sections are surprisingly effective. Copilot respects explicit prohibitions and avoids generating patterns you have banned.
Include code examples when patterns are complex. For non-obvious patterns, show a brief example:
## API Route Pattern
Always structure API routes like this:
export async function GET(req: Request) {
try {
const data = await fetchData();
return Response.json({ success: true, data });
} catch (error) {
return Response.json({ success: false, error: "message" }, { status: 500 });
}
}
Update instructions after repeated corrections. When you find yourself fixing the same Copilot suggestion pattern more than twice, add a rule for it.
Custom Instructions by Language
Python
## Python Conventions
- Python 3.12+, type hints on ALL functions
- Use | for union types (not Union[])
- f-strings for formatting (not .format() or %)
- pathlib.Path instead of os.path
- Use logging, never print() in production code
- Pydantic v2 for data validation
- pytest for tests, not unittest
JavaScript / TypeScript
## JavaScript/TypeScript Conventions
- TypeScript strict: true everywhere
- ES modules (import/export), never CommonJS (require)
- const by default, let only when reassignment is needed
- Arrow functions for callbacks, named functions for declarations
- Destructuring for objects and arrays
- Optional chaining (?.) and nullish coalescing (??) for null safety
Java
## Java Conventions
- Java 21, Spring Boot 3.4
- Records for DTOs and value objects
- Constructor injection only (no @Autowired on fields)
- Optional: never call .get() without .isPresent() check
- Streams for collection transformations
- var for local variables with obvious types only
Go
## Go Conventions
- Go 1.23+, standard library preferred
- Always handle errors explicitly — no _ for error returns
- Context as first parameter for functions that do I/O
- Table-driven tests
- Interfaces: small (1-3 methods), defined by consumer
- Naming: exported PascalCase, unexported camelCase
Copilot vs .cursorrules vs CLAUDE.md
All three tools solve the same problem — giving AI coding assistants project context — but they work differently:
| Feature | Copilot Instructions | .cursorrules | CLAUDE.md | |---------|---------------------|-------------|-----------| | Tool | GitHub Copilot | Cursor | Claude Code | | File location | .github/copilot-instructions.md | .cursorrules (root) | CLAUDE.md (root) | | Format | Markdown | Plain text | Markdown | | Scope | Project-wide | Project-wide | Project + subdirectory | | IDE support | VS Code, JetBrains, Neovim | Cursor only | Terminal (any IDE) | | Custom commands | No | No | Yes | | Agent teams | No | No | Yes | | Free tier | Yes (2,000 completions/mo) | Yes (limited) | No (API or Max plan) |
If you use multiple tools, maintain all instruction files. Many developers keep a base set of conventions and copy them across all three files, then add tool-specific sections to each.
India-Specific: Free Copilot for Students
Indian students have access to GitHub Copilot for free through the GitHub Student Developer Pack:
- Go to education.github.com
- Sign up with your university email (.edu, .ac.in, .edu.in)
- Verify your student status with an ID card or enrollment letter
- Once approved, Copilot Pro is activated on your GitHub account
Accepted Indian institutions: IIT, NIT, IIIT, IISc, central and state universities, and most private universities with .ac.in domains.
Copilot pricing in India (March 2026):
- Free: 2,000 completions/month + 50 chat messages
- Pro: $10/month (~₹830/month) — unlimited completions
- Pro (Student): Free for 1 year (renewable while enrolled)
- Enterprise: $19/user/month — admin controls, policy management
The free tier combined with custom instructions gives you excellent results for individual projects. For heavy daily use, the Pro plan at ~₹830/month is one of the most affordable AI coding tools available.
Internal Resources
Explore more Copilot and AI coding guides:
- GitHub Copilot Free Setup — Get started with Copilot in VS Code
- GitHub Copilot Agents & Skills — Coding agents, Extensions marketplace, Copilot Workspace
- GitHub Copilot Prompts — Ready-to-use prompt templates for Copilot
Official Resources
- GitHub Copilot Documentation — Official Copilot setup and features guide
- Custom Instructions Reference — Official copilot-instructions.md documentation
- GitHub Student Developer Pack — Free developer tools for students
- Copilot in VS Code — VS Code integration guide
Community Questions
0No questions yet. Be the first to ask!