Productivity

GitHub Copilot + Custom Instructions: Turn It Into Your Coding Clone

📅 Updated: December 2025 ⏱️ 8 min read 💻 VS Code, JetBrains

Out of the box, GitHub Copilot gives generic suggestions based on your current file context. But with custom instructions, you can train it to write code exactly the way YOU write code—using your preferred style, patterns, and project conventions.

This turns Copilot from a helpful autocomplete into a true coding partner that understands your preferences.

Setting Up Custom Instructions

In VS Code

  1. Open Copilot Settings

    Press Ctrl+, (or Cmd+, on Mac) to open Settings. Search for "Copilot".

  2. Find Custom Instructions

    Look for "GitHub Copilot: Custom Instructions" or similar. This may be under the Copilot Chat settings.

  3. Add Your Instructions

    Enter your coding preferences, style guidelines, and conventions. Copilot will follow these when generating suggestions.

Using .github/copilot-instructions.md

For project-specific instructions, create a file at .github/copilot-instructions.md in your repository. Copilot will automatically read this file when working in that project.

Example Custom Instructions

JavaScript/TypeScript Developer

- Always use functional programming style over OOP
- Prefer const over let, never use var
- Use arrow functions for callbacks
- Always include TypeScript types, avoid 'any'
- Use async/await over .then() chains
- Prefer named exports over default exports
- Include JSDoc comments for public functions
- Use early returns to reduce nesting
- Error messages should be user-friendly

Python Developer

- Follow PEP 8 style guidelines
- Use type hints for all function parameters and returns
- Prefer list comprehensions over map/filter when readable
- Use f-strings for string formatting
- Write docstrings in Google style format
- Use pathlib instead of os.path
- Prefer dataclasses for data containers
- Handle exceptions with specific types, not bare except

React Developer

- Use functional components with hooks, never class components
- Prefer custom hooks for reusable logic
- Use TypeScript interfaces for props
- Follow the component/styles/test file structure
- Use React Query for data fetching
- Avoid inline styles, use CSS modules or styled-components
- Memoize expensive computations with useMemo
- Always include PropTypes or TypeScript types

💡 Pro Tip: Be Specific About Your Stack

Include the specific libraries and frameworks you use: "Use Zod for validation", "Use Prisma for database queries", "Use TanStack Table for data grids". Copilot will generate code using those tools.

Project-Specific Instructions

Create a .github/copilot-instructions.md file in your project root:

# Project: E-Commerce Platform

## Tech Stack
- Next.js 14 with App Router
- TypeScript strict mode
- Prisma with PostgreSQL
- TailwindCSS for styling
- React Hook Form + Zod for forms

## Coding Conventions
- All API routes in /app/api following REST conventions
- Server components by default, 'use client' only when needed
- Use server actions for form submissions
- Database queries only in server components/actions
- Validate all user input with Zod schemas

## File Naming
- Components: PascalCase (ProductCard.tsx)
- Hooks: camelCase with 'use' prefix (useCart.ts)
- Utils: camelCase (formatCurrency.ts)
- Types: PascalCase in types/ folder

## Error Handling
- Wrap database calls in try-catch
- Return typed error objects, not thrown exceptions
- Log errors to Sentry in production

Advanced Instruction Patterns

Security-First Instructions

- Always sanitize user input before database queries
- Use parameterized queries, never string concatenation
- Validate authentication on every protected route
- Never log sensitive data (passwords, tokens, PII)
- Use environment variables for secrets
- Implement rate limiting on public endpoints

Performance Instructions

- Lazy load components that aren't immediately visible
- Use pagination for lists over 50 items
- Memoize expensive calculations
- Debounce user input handlers (300ms)
- Use connection pooling for database
- Implement caching for repeated queries

Testing Instructions

- Write unit tests for all utility functions
- Use React Testing Library for component tests
- Follow AAA pattern: Arrange, Act, Assert
- Mock external dependencies
- Test error states, not just happy paths
- Include integration tests for critical flows

Copilot Workflow Tips

  1. Write Descriptive Function Names

    Copilot uses your function name to understand intent. calculateTotalWithTaxAndDiscount() gets better suggestions than calc().

  2. Write Comments First

    Type a comment describing what you want, then let Copilot generate the implementation. Example: // Sort users by last login date, most recent first

  3. Use Copilot Chat for Explanations

    Highlight code and ask Copilot Chat to explain it, suggest improvements, or write tests for it.

  4. Iterate on Suggestions

    Press Alt+] to cycle through alternative suggestions. The first suggestion isn't always best.

⚠️ Always Review Generated Code

Copilot can generate code with bugs, security issues, or outdated patterns. Never blindly accept suggestions—review them like you would a junior developer's pull request.

Conclusion

Custom instructions transform Copilot from a generic tool into your personalized coding assistant. Take 30 minutes to write thorough instructions for your projects, and you'll save hours of correcting generated code that doesn't match your style.

The best custom instructions evolve over time—update them whenever you notice Copilot consistently generating code you have to fix.