Why GitHub Copilot Ignores My Project Conventions in Suggestions
🔍 WiseChecker

Why GitHub Copilot Ignores My Project Conventions in Suggestions

You write code that follows a strict style guide and naming convention, but GitHub Copilot suggests code that does not match. This happens because Copilot generates suggestions based on patterns from millions of public repositories, not your project-specific rules. The tool does not automatically read your linter configuration, editor settings, or team standards. This article explains why Copilot ignores your conventions and how to configure it to align with your project.

Key Takeaways: Aligning Copilot Suggestions With Your Project Conventions

  • Copilot settings > Editor > Enable project-level settings: Forces Copilot to respect per-project configuration files like .editorconfig or .github/copilot-instructions.md.
  • .github/copilot-instructions.md file: Define project-specific coding rules that Copilot reads before generating suggestions.
  • EditorConfig (.editorconfig) file: Set indentation, spacing, and naming rules that Copilot partially respects during inline completions.

Why Copilot Does Not Follow Your Project Conventions

GitHub Copilot uses a large language model trained on public code from GitHub repositories. The model learns statistical patterns — for example, how most Python projects name variables or how JavaScript projects structure functions. When you type code, Copilot predicts the next tokens based on this global training data, not your local configuration files.

Copilot does not natively read ESLint rules, Prettier configs, or Ruby style guides. It does not parse your .editorconfig file during suggestion generation. The tool treats each suggestion as a statistical prediction based on the surrounding code context, but the context window is limited to the current file and a few adjacent files. If your project conventions are not reflected in the immediate code context, Copilot defaults to general patterns.

The Context Window Limitation

Copilot sees around 2000 characters of context from your open file and any files you have recently opened. If your project uses a mix of camelCase and snake_case, Copilot may not detect the correct pattern until you have typed enough consistent examples. The model does not scan your entire codebase to infer a global style.

No Built-In Linter Integration

Copilot does not call your linter or formatter before displaying a suggestion. It generates completions first, and your editor may apply formatting after the suggestion is accepted. This means Copilot can suggest code that violates your ESLint rules or Prettier formatting, even if your editor would correct it later.

Steps to Configure Copilot to Follow Your Project Conventions

You can improve Copilot adherence to your conventions by providing explicit instructions and structured configuration files. Follow these steps in order for best results.

Step 1: Create a copilot-instructions.md File

  1. Open your project root folder
    Navigate to the root of your repository in your file system or terminal.
  2. Create a .github directory if it does not exist
    Run mkdir .github from the project root.
  3. Create the copilot-instructions.md file
    Inside the .github folder, create a file named copilot-instructions.md.
  4. Write your conventions using plain English
    Use bullet points or numbered lists. For example:
# Coding Conventions for This Project

- Use camelCase for variable names, never snake_case
- Use 2 spaces for indentation, never tabs
- End all statements with semicolons
- Use single quotes for strings in JavaScript
- Prefer const over let and never use var
- Use async/await instead of .then() chains

Copilot reads this file automatically when generating suggestions. Place the file at the root of your repository. The instructions apply to all files in the repository.

Step 2: Configure Editor-Level Settings to Reinforce Conventions

  1. Open your editor settings
    In VS Code, go to File > Preferences > Settings. Search for github.copilot.
  2. Enable project-level settings
    Set github.copilot.enableProjectSettings to true. This tells Copilot to prioritize instructions from the .github/copilot-instructions.md file over global defaults.
  3. Set an editor-specific configuration
    In VS Code, create a .vscode/settings.json file in your project root. Add entries for formatting and linting:
{
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "eslint.validate": ["javascript", "typescript"],
  "github.copilot.enable": {
    "": true
  }
}

This does not change Copilot suggestions directly, but it ensures that after you accept a suggestion, the editor reformats it to match your linter rules. Over time, Copilot learns from your accepted-and-reformatted code.

Step 3: Provide Consistent Context in Your Code

  1. Write a few lines of code manually before accepting Copilot suggestions
    Type 5 to 10 lines that follow your exact conventions. Copilot uses this as a pattern for subsequent suggestions in the same file.
  2. Use meaningful function and variable names
    Copilot uses the names you define to infer naming styles. If you type userProfile, Copilot will suggest userSettings (camelCase) instead of user_settings.
  3. Avoid mixing styles in the same file
    If you switch between camelCase and snake_case, Copilot may pick either pattern. Stick to one style per file.

Step 4: Use a .editorconfig File for Basic Formatting

  1. Create a .editorconfig file in your project root
    This file is read by many editors and some Copilot versions. Add rules for indentation and charset:
root = true

[]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[py]
indent_size = 4

Copilot respects some EditorConfig rules during suggestion generation, especially indentation. This is a lightweight way to enforce spacing without creating a copilot-instructions.md file.

If Copilot Still Ignores Your Conventions

Copilot Suggests Wrong Naming Case Despite Instructions

The copilot-instructions.md file is read by Copilot but does not override the model completely. If your instructions are vague, Copilot may still default to training data patterns. Rewrite your instructions as short, imperative commands. For example, write Use camelCase for all variable names instead of Variables should be camelCase.

Copilot Suggests Tabs When Your Project Uses Spaces

This is the most common formatting mismatch. Add an explicit rule to your copilot-instructions.md: Use 2 spaces for indentation, never tabs. Also set indent_style = space in your .editorconfig. If the problem persists, manually type two spaces at the start of a line, then press Enter. Copilot will match the indentation of the line above.

Copilot Uses async/await When Your Project Uses Promises

Copilot defaults to modern JavaScript patterns. Add a rule to your instructions: Use .then() and .catch() for asynchronous operations, not async/await. Then type a few lines of promise-based code before accepting suggestions. Copilot will shift to the pattern you provide in context.

Copilot Pro vs Copilot Enterprise: Convention Support Differences

Item Copilot Pro Copilot Enterprise
Project-level instructions Supports .github/copilot-instructions.md Supports .github/copilot-instructions.md plus organization-wide policies
Linter integration None None
EditorConfig support Partial (indentation only) Partial (indentation only)
Custom knowledge bases Not available Available via GitHub Copilot Enterprise knowledge bases
Admin-enforced rules Not available Admins can set organization-wide coding guidelines

Enterprise users can enforce conventions across all repositories in an organization. Pro users must rely on per-repository instructions and manual configuration.

You now know why Copilot ignores your project conventions and how to fix it. Start by creating a .github/copilot-instructions.md file with explicit rules for naming, indentation, and syntax. Combine this with a .editorconfig file and consistent manual typing in each file. For teams, consider upgrading to Copilot Enterprise to enforce organization-wide policies. The key is to treat Copilot as a suggestion engine that needs clear, repeated guidance rather than assuming it will infer your rules from the codebase alone.