Skip to main content

Chapter 5: Copilot Policies & Content Controls

Part II: Licensing, Policies & Governance Prerequisites: Chapter 4: Copilot Licensing & Plan Management GH-100 Exam Mapping: Domain 1 (Support GitHub Enterprise for users and stakeholders — 9%) Verified: 2026-02-01 against official documentation

1. Introduction​

Learning Objectives​

After completing this chapter, you will be able to:

  • Configure enterprise-level Copilot policies that govern code suggestions, chat, CLI, and coding agent features across multiple organizations
  • Enable or disable the public code filter (duplication detection) and explain its impact on code suggestion matching
  • Define content exclusion rules at the repository and organization levels to prevent Copilot from accessing sensitive files
  • Control which organizations and individual members can use specific Copilot features
  • Create and manage custom instructions at the organization level using .github/copilot-instructions.md files
  • Articulate the policy inheritance model from enterprise to organization to individual developer

Exam Domain Coverage​

DomainTopics in This Chapter
D1: Support GitHub Enterprise (9%)Copilot policy management, content exclusion configuration, public code filtering, feature governance, custom instructions

Chapter Overview​

In Chapter 4: Copilot Licensing & Plan Management, you enabled Copilot and assigned seats to your organization's developers. Seats grant access, but access without governance is a liability. This chapter answers the question every enterprise administrator faces after enablement: what controls exist to ensure Copilot operates within the organization's compliance, security, and intellectual property boundaries?

GitHub Copilot policies operate at three levels: enterprise, organization, and repository. Enterprise owners define the ceiling -- the maximum set of features and behaviors available. Organization owners can further restrict (but never expand beyond) what the enterprise allows. Repository administrators can add content exclusion rules that prevent Copilot from reading specific files. This layered model gives enterprises the centralized control they need while allowing individual organizations to tailor Copilot behavior to their specific regulatory and operational requirements.

This chapter covers five critical policy areas:

  1. Feature policies -- controlling which Copilot capabilities (code completions, chat, CLI, coding agent) are available
  2. Public code filtering -- the duplication detection filter that blocks suggestions matching publicly available code
  3. Content exclusions -- rules that prevent Copilot from accessing sensitive or restricted files
  4. Access controls -- determining which organizations and members can use Copilot
  5. Custom instructions -- organization-level configuration that shapes how Copilot generates responses

By the end of this chapter, you will have a fully configured Copilot policy framework suitable for an enterprise with 50 or more developers, balancing developer productivity with compliance and security requirements.


2. Theory & Deep Dive​

The Policy Inheritance Model​

Copilot policies follow a strict top-down inheritance model within the GitHub enterprise hierarchy. Understanding this model is essential for effective governance.

Enterprise level: The enterprise owner sets policies that act as a ceiling for all organizations. Enterprise policies have three possible states for each feature:

  • Enabled -- the feature is available, and organizations can choose to enable or disable it
  • Disabled -- the feature is blocked across all organizations; organization owners cannot override this
  • No policy -- the enterprise defers the decision to each organization (equivalent to "enabled" in practice, since organizations can then choose)

Organization level: Organization owners configure policies within the boundaries set by the enterprise. If the enterprise disables a feature, the organization cannot enable it. If the enterprise enables a feature or sets no policy, the organization can choose to enable or disable it for its members.

Individual level: Developers with Copilot seats operate under the combined effect of enterprise and organization policies. On Copilot Business and Enterprise plans, individual users cannot override organization-level policies. This is a key difference from Copilot Individual (Pro), where users manage their own settings.

Enterprise Scenario: A 150-developer financial services company has three organizations: corp-banking, corp-trading, and corp-internal-tools. The enterprise owner enables all Copilot features but disables the coding agent at the enterprise level because the security team has not yet completed their review of agent capabilities. The corp-banking organization further disables Copilot in the CLI because their compliance framework prohibits AI-assisted commands in terminal environments. The corp-internal-tools organization enables all remaining features. No organization can enable the coding agent because the enterprise has disabled it.

Feature Policies in Detail​

Enterprise and organization administrators can control the following Copilot features independently:

Code completions (also called suggestions): The core Copilot experience -- inline code suggestions as developers type. Disabling this effectively removes Copilot's primary value proposition.

Copilot Chat: The conversational AI assistant available in the IDE, on GitHub.com, and in GitHub Mobile. Chat can be enabled or disabled independently of code completions.

Copilot in the CLI (Command Line Interface): Allows developers to use Copilot from the terminal via the gh copilot command for shell command suggestions and explanations. Some organizations disable this due to concerns about AI-suggested commands being executed in production environments.

Coding agent (Copilot coding agent): The autonomous agent that can be assigned issues and creates pull requests with code changes. This is the most powerful -- and most governance-sensitive -- Copilot feature. Many enterprises disable this initially and enable it after establishing review processes. See Chapter 13: Coding Agent for detailed coverage.

Copilot pull request summaries (Enterprise plan only): Automatic generation of pull request descriptions and summaries. Some organizations disable this to ensure developers write their own PR descriptions.

Copilot knowledge bases (Enterprise plan only): The ability for Copilot to reference your organization's repositories as context when answering questions. See Chapter 4: Copilot Licensing & Plan Management for the distinction between Business and Enterprise features.

Each feature can be set to "Enabled", "Disabled", or "No policy" (defer to enterprise/organization) at the enterprise level. At the organization level, each feature can be "Enabled" or "Disabled" within the bounds set by the enterprise.

Public Code Filtering (Duplication Detection)​

One of the most important policy controls for enterprises concerned about intellectual property (IP) risk is the public code filter, also known as the duplication detection filter.

What it does: When enabled, this filter compares Copilot's code suggestions against a database of publicly available code on GitHub. If a suggestion matches or closely resembles public code (approximately 150 characters of matching code), the suggestion is blocked and not shown to the developer.

Why it matters: Enterprises use this filter to reduce the risk of inadvertently incorporating copyleft-licensed code (such as code under the GNU General Public License, or GPL) into proprietary codebases. Without the filter, Copilot might suggest code that is functionally identical to publicly available code, which could create licensing obligations.

How to configure it: The public code filter is controlled at the organization level under Settings > Copilot > Policies. It can be set to:

  • Blocked -- suggestions matching public code are suppressed (recommended for enterprises with strict IP policies)
  • Allowed -- suggestions matching public code are shown, with optional code referencing that displays the source repository and license information

Code referencing: When suggestions matching public code are allowed, GitHub provides code referencing information. This includes links to the matching public repository and the associated license, enabling developers to make informed decisions about whether to use the suggested code.

Limitations of the filter:

  • The filter checks for near-exact matches, not semantic similarity. Paraphrased or structurally modified code will not be caught.
  • The filter only applies to code completions, not to Copilot Chat responses.
  • The matching database covers public repositories on GitHub; it does not cover code published on other platforms.

Enterprise Scenario: A 200-developer enterprise building proprietary software enables the public code filter across all organizations. Their legal team requires this as a condition of Copilot adoption. After six months of usage, they find that approximately 1-2% of suggestions are blocked by the filter. The legal team considers this an acceptable trade-off, as the blocked suggestions would have required manual license review otherwise.

Prompt and Suggestion Collection​

A related policy control governs whether GitHub retains prompts and suggestions -- the code context sent to Copilot (prompts) and the suggestions Copilot returns.

On Copilot Business and Enterprise plans, GitHub does not retain prompts and suggestions by default, and this data is not used to train GitHub's AI models. This is a contractual guarantee included in the Copilot Business and Enterprise terms of service.

Organization owners can optionally enable prompt and suggestion collection if they want GitHub to use their data to improve the Copilot model. Most enterprises leave this disabled.

This setting is found at Organization Settings > Copilot > Policies > Suggestions matching public code and Organization Settings > Copilot > Policies > Copilot can use prompts and suggestions for product improvements.

Content Exclusion Rules​

Content exclusions are the most granular policy control available. They allow administrators to specify files and paths that Copilot must not read, reference, or use as context for generating suggestions.

What content exclusions do:

  • Code completions are not available when editing an excluded file
  • Excluded files cannot be referenced in Copilot Chat (neither in the chat window nor inline chat)
  • Excluded file content is not included in context sent to the Copilot model
  • Excluded content is not used to inform suggestions in other (non-excluded) files

Where to configure content exclusions:

Content exclusions can be configured at two levels:

  1. Repository level: Repository administrators add exclusion rules in the repository settings. These rules apply only to that repository.
  2. Organization level: Organization owners add exclusion rules in the organization Copilot settings. These rules apply to all repositories in the organization, plus any additional repositories specified by name (including repositories in other organizations).

Exclusion rule syntax: Content exclusion rules use fnmatch-style glob patterns. Each rule specifies a repository (or all repositories) and a set of file path patterns to exclude.

Example organization-level content exclusion configuration:

# Organization-level content exclusion (configured in org settings)
# These rules apply to all repositories in the organization

"*":
- "**/.env"
- "**/*.pem"
- "**/*.key"
- "**/secrets/**"
- "**/config/production/**"

"my-org/sensitive-repo":
- "**"

"my-org/api-service":
- "internal/auth/**"
- "database/migrations/**"

In this example:

  • The "*" rule applies to all repositories and excludes environment files, cryptographic key files, secrets directories, and production configuration directories
  • The "my-org/sensitive-repo" rule excludes all files in the entire repository from Copilot
  • The "my-org/api-service" rule excludes the authentication internals and database migration files from a specific repository

Limitations of content exclusions:

  • Content exclusions are not retroactive. If Copilot has already processed content before an exclusion rule was added, the exclusion does not remove that content from any cached context.
  • Exclusion rules apply to the repository where the content lives. If a developer copies excluded content into a non-excluded file, the copied content is no longer protected.
  • Content exclusions are enforced by the IDE extensions (VS Code, Visual Studio, JetBrains IDEs, Neovim). The IDE checks exclusion rules when opening files and when assembling context for Copilot requests. If an IDE extension does not support content exclusions, the rules may not be enforced.
  • Content exclusions do not apply to Copilot on GitHub.com (e.g., Copilot Chat on the github.com website) unless explicitly stated in the documentation for that feature.
  • Exclusion rules from git submodules are not applied in some IDE implementations. Rules are evaluated from the root repository of the current workspace.
  • There is a practical limit to the number of exclusion rules. GitHub recommends keeping the total number of exclusion paths reasonable (under 1,000 rules per organization) to avoid performance impacts during IDE rule evaluation.

Enterprise Scenario: A healthcare company with 75 developers uses content exclusions to protect files containing Protected Health Information (PHI) processing logic. They configure organization-wide exclusions for **/phi/**, **/hipaa/**, and all .env files. Their patient-data-service repository is excluded entirely because it handles raw patient records. This ensures that Copilot never uses PHI-related code as context, supporting their Health Insurance Portability and Accountability Act (HIPAA) compliance posture.

Managing Organization and Member Access​

Beyond feature-level policies, enterprise owners control which organizations within the enterprise can use Copilot at all. This is separate from seat assignment (covered in Chapter 4: Copilot Licensing & Plan Management).

Enterprise-level organization access: Enterprise owners can configure Copilot to be available to:

  • All organizations -- every organization in the enterprise can use Copilot (subject to seat assignment)
  • Selected organizations -- only explicitly chosen organizations can use Copilot
  • No organizations -- Copilot is disabled enterprise-wide

Organization-level member access: Within an enabled organization, organization owners can configure who gets Copilot access:

  • All members -- every organization member automatically receives a Copilot seat
  • Selected teams/members -- only members of specific teams or individually selected members receive seats
  • Disabled -- no members in this organization receive Copilot seats (even if the enterprise allows it)

This two-level access model allows enterprises to roll out Copilot progressively. A common pattern for large enterprises is:

  1. Start with Copilot enabled for a single pilot organization
  2. Within that organization, assign seats to selected teams
  3. After a successful pilot, enable additional organizations
  4. Gradually expand seat assignment within each organization

Controlling access via the API (Application Programming Interface):

# List organizations with Copilot access in the enterprise
gh api /enterprises/YOUR-ENTERPRISE/copilot/billing \
--jq '.organizations'
# View Copilot access settings for a specific organization
gh api /orgs/YOUR-ORG/copilot/billing \
--jq '{seat_management: .seat_management_setting, public_code_suggestions: .public_code_suggestions}'

Custom Instructions​

Custom instructions allow organizations to shape how Copilot generates responses. They provide persistent context that is automatically included in every Copilot interaction, ensuring suggestions align with the organization's coding standards, architectural patterns, and best practices.

Repository-level custom instructions: Created as a .github/copilot-instructions.md file in the root of a repository. When a developer works in that repository, the instructions are automatically included as context for Copilot Chat interactions.

Example .github/copilot-instructions.md:

# Copilot Instructions for api-service

## Coding Standards
- Use TypeScript strict mode for all new files
- Follow the repository's ESLint configuration without exceptions
- All public functions must have JSDoc comments
- Error handling must use the custom `AppError` class from `src/errors/`

## Architecture
- This is a hexagonal architecture project
- Business logic lives in `src/domain/` and must not import from `src/infrastructure/`
- Database access goes through repository interfaces defined in `src/domain/ports/`
- All API endpoints must validate input using Zod schemas in `src/api/schemas/`

## Testing
- Unit tests use Vitest and live alongside source files as `*.test.ts`
- Integration tests live in `tests/integration/` and use Testcontainers
- Minimum 80% code coverage for new code

Targeted instruction files: In addition to the single copilot-instructions.md file, organizations can create multiple targeted instruction files in .github/instructions/. Each file uses the .instructions.md extension and can include YAML (YAML Ain't Markup Language) frontmatter with an applyTo glob pattern to specify which files the instructions apply to.

Example .github/instructions/python-standards.instructions.md:

---
description: Python coding standards for data engineering team
applyTo: "**/*.py"
---

- Use type hints for all function parameters and return values
- Follow PEP 8 style guidelines
- Use `pathlib.Path` instead of `os.path` for file system operations
- Prefer `dataclasses` over plain dictionaries for structured data
- All database queries must use parameterized statements

Organization-level custom instructions: Enterprise and organization administrators can also define custom instructions that apply across all repositories in the organization. These are configured in the organization Copilot settings and are merged with any repository-level instructions. Organization instructions take precedence when there are conflicts.

Prompt files: Organizations can create reusable prompt templates as .prompt.md files in the .github/prompts/ directory. Developers reference these in Copilot Chat using the #prompt: prefix. This standardizes common workflows like code reviews, test generation, and documentation writing.

Example .github/prompts/review-security.prompt.md:

---
description: Security-focused code review checklist
---

Review the selected code for security vulnerabilities. Check for:
1. SQL injection via string concatenation
2. Cross-site scripting (XSS) via unescaped user input
3. Insecure deserialization
4. Hardcoded secrets or credentials
5. Missing input validation
6. Insecure cryptographic implementations

For each finding, explain the risk and provide a remediation code example.

Enterprise Scenario: A 100-developer enterprise standardizes Copilot behavior across 12 repositories by creating organization-level custom instructions that enforce their coding standards (naming conventions, error handling patterns, logging requirements). Each team adds repository-specific instructions for their architectural patterns. The platform team creates shared prompt files for common tasks like generating database migration scripts and writing API documentation. New developers onboarding to any team get consistent, standards-compliant suggestions from day one.

Policy Configuration via the REST API​

While the GitHub web UI (User Interface) is the primary interface for managing Copilot policies, the REST API enables automation and infrastructure-as-code approaches.

Viewing enterprise Copilot policies:

# Get enterprise-level Copilot configuration
gh api /enterprises/YOUR-ENTERPRISE/copilot/billing \
--jq '{plan: .plan_type, seat_management: .seat_management_setting}'

Viewing organization Copilot policies:

# Get organization-level Copilot policy settings
gh api /orgs/YOUR-ORG/copilot/billing \
--jq '{
plan: .plan_type,
seat_management: .seat_management_setting,
public_code_suggestions: .public_code_suggestions
}'

Updating organization Copilot policies:

# Disable public code suggestions for the organization
gh api --method PATCH /orgs/YOUR-ORG/copilot/billing \
-f public_code_suggestions="block"

Managing content exclusions via API:

Content exclusions are managed through the organization settings API. The exclusion rules are specified as a nested structure of repository patterns and file path patterns.

# View current content exclusion rules
gh api /orgs/YOUR-ORG/copilot/content_exclusions \
--jq '.[]'

Policy Audit and Compliance​

Every policy change in Copilot is recorded in the enterprise and organization audit logs. Key audit events include:

EventDescription
copilot.cfb_seat_management_changedSeat management setting changed
copilot.content_exclusion_changedContent exclusion rules updated
copilot.ide_chat_policy_changedChat feature policy changed
copilot.ide_completions_policy_changedCode completions policy changed
copilot.cli_policy_changedCLI feature policy changed
copilot.public_code_suggestions_changedPublic code filter setting changed

These events can be streamed to a Security Information and Event Management (SIEM) system for centralized monitoring. See Chapter 6: Security, Audit & Compliance for detailed coverage of audit log streaming.

# Query audit log for Copilot policy changes in the last 30 days
gh api /orgs/YOUR-ORG/audit-log \
--jq '[.[] | select(.action | startswith("copilot."))] | length'

3. Diagrams​

Policy Inheritance Flow​

graph TD
ENT["Enterprise Account<br/>Enterprise Owner"] --> EP["Enterprise Policies<br/>(Ceiling)"]

EP --> |"Feature: Enabled"| ORG_CHOOSE["Organization<br/>Can Enable or Disable"]
EP --> |"Feature: Disabled"| ORG_BLOCKED["Organization<br/>Cannot Enable<br/>(Blocked)"]
EP --> |"Feature: No Policy"| ORG_DEFAULT["Organization<br/>Can Enable or Disable<br/>(Defaults to Enabled)"]

ORG_CHOOSE --> |"Org Enables"| DEV_ON["Developer<br/>Feature Available"]
ORG_CHOOSE --> |"Org Disables"| DEV_OFF["Developer<br/>Feature Blocked"]
ORG_BLOCKED --> DEV_OFF
ORG_DEFAULT --> |"Org Enables"| DEV_ON
ORG_DEFAULT --> |"Org Disables"| DEV_OFF

style ENT fill:#2d333b,stroke:#539bf5,color:#adbac7
style EP fill:#2d333b,stroke:#539bf5,color:#adbac7
style ORG_CHOOSE fill:#2d333b,stroke:#57ab5a,color:#adbac7
style ORG_BLOCKED fill:#2d333b,stroke:#e06c75,color:#adbac7
style ORG_DEFAULT fill:#2d333b,stroke:#e5c07b,color:#adbac7
style DEV_ON fill:#2d333b,stroke:#57ab5a,color:#adbac7
style DEV_OFF fill:#2d333b,stroke:#e06c75,color:#adbac7

Figure 5.1: Copilot policy inheritance model. Enterprise policies set the ceiling. Organizations can further restrict but never expand beyond what the enterprise allows. Developers operate under the combined effect of both levels.

Content Exclusion Processing Flow​

flowchart TD
DEV["Developer Opens File<br/>in IDE"] --> CHECK{"Is file path<br/>matched by any<br/>exclusion rule?"}
CHECK --> |"Yes"| BLOCKED["Copilot Disabled<br/>for This File"]
CHECK --> |"No"| CONTEXT{"Is file referenced<br/>as context by<br/>another file?"}

BLOCKED --> NO_COMPLETE["No Code<br/>Completions"]
BLOCKED --> NO_CHAT["Cannot Reference<br/>in Chat"]
BLOCKED --> NO_CONTEXT["Not Used as<br/>Context"]

CONTEXT --> |"Excluded file<br/>referenced"| SKIP["Excluded Content<br/>Stripped from Context"]
CONTEXT --> |"Non-excluded file<br/>referenced"| INCLUDE["Content Included<br/>in Context"]

SKIP --> SUGGEST["Copilot Generates<br/>Suggestion"]
INCLUDE --> SUGGEST

style BLOCKED fill:#2d333b,stroke:#e06c75,color:#adbac7
style NO_COMPLETE fill:#2d333b,stroke:#e06c75,color:#adbac7
style NO_CHAT fill:#2d333b,stroke:#e06c75,color:#adbac7
style NO_CONTEXT fill:#2d333b,stroke:#e06c75,color:#adbac7
style DEV fill:#2d333b,stroke:#539bf5,color:#adbac7
style SUGGEST fill:#2d333b,stroke:#57ab5a,color:#adbac7

Figure 5.2: How content exclusion rules are evaluated when a developer works in the IDE. Excluded files receive no Copilot functionality, and their content is stripped from context when other files are processed.

Enterprise Policy Configuration Map​

graph LR
subgraph Enterprise ["Enterprise Level"]
E_CODE["Code Completions: Enabled"]
E_CHAT["Copilot Chat: Enabled"]
E_CLI["Copilot CLI: Enabled"]
E_AGENT["Coding Agent: Disabled"]
end

subgraph OrgA ["Org: Engineering"]
A_CODE["Code Completions: Enabled"]
A_CHAT["Copilot Chat: Enabled"]
A_CLI["Copilot CLI: Enabled"]
A_AGENT["Coding Agent: Blocked by Enterprise"]
end

subgraph OrgB ["Org: Finance"]
B_CODE["Code Completions: Enabled"]
B_CHAT["Copilot Chat: Disabled"]
B_CLI["Copilot CLI: Disabled"]
B_AGENT["Coding Agent: Blocked by Enterprise"]
end

E_CODE --> A_CODE
E_CHAT --> A_CHAT
E_CLI --> A_CLI
E_AGENT --> A_AGENT

E_CODE --> B_CODE
E_CHAT --> B_CHAT
E_CLI --> B_CLI
E_AGENT --> B_AGENT

style E_AGENT fill:#2d333b,stroke:#e06c75,color:#adbac7
style A_AGENT fill:#2d333b,stroke:#e06c75,color:#adbac7
style B_AGENT fill:#2d333b,stroke:#e06c75,color:#adbac7
style B_CHAT fill:#2d333b,stroke:#e06c75,color:#adbac7
style B_CLI fill:#2d333b,stroke:#e06c75,color:#adbac7

Figure 5.3: A realistic enterprise policy configuration. The enterprise disables the coding agent globally. The Finance organization further disables Chat and CLI while keeping code completions. The Engineering organization enables everything the enterprise allows.


4. Summary​

Key Takeaways:

  • Copilot policies follow a strict inheritance model: enterprise sets the ceiling, organizations can further restrict, and developers operate under the combined effect of both levels
  • The public code filter (duplication detection) blocks code suggestions that match publicly available code on GitHub -- enterprise legal and compliance teams typically require this to be enabled
  • Content exclusion rules prevent Copilot from reading, referencing, or using specific files as context, and can be configured at both the repository and organization levels using glob patterns
  • Content exclusions have limitations: they are not retroactive, they depend on IDE extension support, and they do not apply to content copied into non-excluded files
  • Feature policies allow independent control of code completions, chat, CLI, coding agent, PR summaries, and knowledge bases
  • On Copilot Business and Enterprise plans, prompts and suggestions are not retained by GitHub and are not used for model training by default -- this is a contractual guarantee
  • Custom instructions via .github/copilot-instructions.md and targeted .instructions.md files standardize Copilot behavior across teams and repositories
  • All policy changes are recorded in the audit log and can be streamed to a SIEM for compliance monitoring (see Chapter 6: Security, Audit & Compliance)
  • The REST API enables programmatic policy management for infrastructure-as-code workflows

What's Next: See Chapter 6: Security, Audit & Compliance for configuring audit log streaming, managing security alerts, and building a compliance framework around your Copilot deployment.


5. Hands-On Assignment​

Prerequisites Check: Before starting this lab, ensure you have completed:

  • A working GitHub Enterprise Cloud environment (Chapter 1: Enterprise Subscription & Environment Setup)
  • Copilot enabled with seats assigned to at least 2 members (Chapter 4: Copilot Licensing & Plan Management)
  • GitHub CLI (gh) installed and authenticated with enterprise owner permissions
  • A test repository with at least 5 files of different types

Lab: Configure Copilot Policies and Content Exclusions​

Objective: Configure a complete Copilot policy framework for an enterprise with multiple organizations, including feature policies, public code filtering, content exclusion rules, and custom instructions.

Prerequisites:

  • A GitHub Enterprise Cloud trial (from Chapter 1: Enterprise Subscription & Environment Setup)
  • At least one organization with Copilot enabled and 2+ members with seats (from Chapter 4: Copilot Licensing & Plan Management)
  • GitHub CLI (gh) installed and authenticated with enterprise owner permissions
  • A test repository with at least 5 files of different types (e.g., .ts, .py, .env, .pem, .md)

Assignment:

  1. Configure enterprise-level Copilot feature policies: enable code completions and chat, disable the coding agent
  2. Configure organization-level policies: enable the public code filter (block suggestions matching public code)
  3. Create content exclusion rules at the organization level that exclude .env files, .pem files, and a secrets/ directory
  4. Verify that content exclusions are working by opening an excluded file in VS Code and confirming that Copilot is disabled for that file
  5. Create a .github/copilot-instructions.md file in your test repository with at least three coding standard instructions
  6. Verify that Copilot Chat references the custom instructions when generating code in that repository
  7. Review the audit log to confirm that your policy changes were recorded

Expected Outcome: Your enterprise has a layered policy framework where the enterprise controls feature availability, the organization controls public code filtering and content exclusions, and each repository can add custom instructions. Excluded files receive no Copilot suggestions, and Copilot Chat follows your custom instructions.

Validation Checklist:

  • Enterprise policies show coding agent as disabled
  • Organization policies show public code suggestions as "Blocked"
  • Content exclusion rules are listed in organization Copilot settings
  • Opening a .env file in VS Code shows no Copilot completions
  • Copilot Chat refuses to reference an excluded file when asked
  • Copilot Chat responses in the test repository reflect the custom instructions
  • Audit log contains entries for each policy change made

6. Step-by-Step Walkthrough​

This section provides a guided solution for the hands-on assignment above. If you completed the assignment independently, you can skip this section or use it to verify your approach.

Step 1: Configure Enterprise-Level Feature Policies​

Navigate to your enterprise Copilot settings in the browser:

  1. Go to https://github.com/enterprises/YOUR-ENTERPRISE
  2. Click Settings in the sidebar
  3. Under "Policies", click Copilot
  4. For each feature, set the policy:
    • Code completions: Enabled (or "No policy" to let organizations decide)
    • Copilot Chat: Enabled
    • Copilot in the CLI: Enabled
    • Coding agent: Disabled
    • Pull request summaries: Enabled (if on Enterprise plan)

Verify your configuration via the CLI:

# Verify enterprise Copilot configuration
gh api /enterprises/YOUR-ENTERPRISE/copilot/billing \
--jq '{plan: .plan_type, seat_management: .seat_management_setting}'

Expected output:

{
"plan": "enterprise",
"seat_management": "assign_selected"
}

Step 2: Configure Organization-Level Public Code Filter​

  1. Navigate to https://github.com/organizations/YOUR-ORG/settings/copilot
  2. Under "Policies", find "Suggestions matching public code"
  3. Select Blocked to enable the public code filter

Via the CLI:

# Block suggestions matching public code
gh api --method PATCH /orgs/YOUR-ORG/copilot/billing \
-f public_code_suggestions="block"

Verify the setting:

# Confirm public code filter is active
gh api /orgs/YOUR-ORG/copilot/billing \
--jq '{public_code_suggestions: .public_code_suggestions}'

Expected output:

{
"public_code_suggestions": "block"
}

Step 3: Create Content Exclusion Rules​

  1. Navigate to https://github.com/organizations/YOUR-ORG/settings/copilot
  2. Under "Content exclusion", click Add exclusion
  3. Add the following rules:

Rule 1 -- Exclude sensitive files in all repositories:

  • Repository: * (all repositories)
  • Paths:
    • **/.env
    • **/*.pem
    • **/*.key
    • **/secrets/**

Rule 2 -- Exclude an entire sensitive repository (if applicable):

  • Repository: YOUR-ORG/sensitive-repo
  • Paths: **
  1. Click Save

Verify via the CLI:

# List content exclusion rules
gh api /orgs/YOUR-ORG/copilot/content_exclusions

Step 4: Verify Content Exclusions in the IDE​

  1. Open your test repository in VS Code
  2. Ensure the GitHub Copilot extension is installed and authenticated
  3. Create or open a file named .env with the following content:
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
API_SECRET_KEY=sk-1234567890abcdef
  1. Place your cursor at the end of the file and press Enter. No Copilot suggestion should appear. You should see an indicator in the VS Code status bar showing that Copilot is disabled for this file.

  2. Open a non-excluded file (e.g., app.ts) and start a Copilot Chat session. Ask Copilot to "explain the database configuration in .env". Copilot should refuse to reference the excluded file or indicate that the content is not available.

  3. Open a .pem file and confirm that Copilot completions do not appear.

Step 5: Create Custom Instructions​

Create the .github/copilot-instructions.md file in your test repository:

# Navigate to your test repository
cd /path/to/your-test-repo

# Create the .github directory if it does not exist
mkdir -p .github

Create the file with the following content:

# Copilot Instructions

## Coding Standards
- Use TypeScript with strict mode enabled (`"strict": true` in tsconfig.json)
- All functions must include explicit return type annotations
- Use `const` by default; use `let` only when reassignment is necessary
- Never use `any` type; use `unknown` and type narrowing instead

## Error Handling
- All async functions must have try/catch blocks
- Use the custom `AppError` class from `src/errors/app-error.ts` for application errors
- Log errors using the structured logger from `src/utils/logger.ts`

## Testing
- Write unit tests for all new functions using Vitest
- Test files must be colocated with source files as `*.test.ts`
- Include at least one test for the happy path and one for error handling

Commit and push the file:

git add .github/copilot-instructions.md
git commit -m "Add Copilot custom instructions for coding standards"
git push

Step 6: Verify Custom Instructions​

  1. Open your test repository in VS Code

  2. Open a TypeScript file (e.g., app.ts)

  3. Open Copilot Chat and ask: "Write a function to fetch user data from the API"

  4. Verify that Copilot's response follows your custom instructions:

    • Uses TypeScript strict mode patterns
    • Includes explicit return type annotations
    • Uses const declarations
    • Includes try/catch error handling
    • References the custom AppError class if generating error handling code
  5. Check that the .github/copilot-instructions.md file appears in the References list of the Copilot Chat response (in supported IDEs).

Step 7: Review the Audit Log​

Verify that your policy changes were recorded:

# Query the audit log for recent Copilot-related events
gh api "/orgs/YOUR-ORG/audit-log?phrase=action:copilot" \
--jq '.[] | {action: .action, actor: .actor, created_at: .created_at}'

Expected output (entries will vary):

{
"action": "copilot.content_exclusion_changed",
"actor": "your-username",
"created_at": "2026-02-01T12:00:00Z"
}
{
"action": "copilot.public_code_suggestions_changed",
"actor": "your-username",
"created_at": "2026-02-01T11:55:00Z"
}

In the browser, you can also view the audit log at: https://github.com/organizations/YOUR-ORG/settings/audit-log?q=action%3Acopilot

Verification​

Confirm your complete policy setup:

# Final verification: summarize Copilot configuration
gh api /orgs/YOUR-ORG/copilot/billing \
--jq '{
plan: .plan_type,
seat_management: .seat_management_setting,
public_code_suggestions: .public_code_suggestions,
seats_assigned: .seats
}'

Your output should confirm:

  • Plan type is "business" or "enterprise"
  • Public code suggestions are set to "block"
  • Seats are assigned to your test members

Navigate to Organization Settings > Copilot > Content exclusion to visually confirm your exclusion rules are active.


7. Q&A -- Chapter Review​

Instructions: Select the best answer for each question. Answers and explanations follow after all questions.

Question 1​

An enterprise owner sets the Copilot coding agent policy to "Disabled" at the enterprise level. An organization owner within that enterprise wants to enable the coding agent for their engineering team. What is the result?

  • A) The organization owner can enable the coding agent because organization policies override enterprise policies
  • B) The coding agent remains disabled because enterprise policies set the ceiling and organizations cannot exceed it
  • C) The coding agent is enabled only for enterprise owners, not regular organization members
  • D) The organization owner must request an exception through the enterprise billing settings

Question 2​

Which policy setting should an enterprise enable to prevent Copilot from suggesting code that closely matches publicly available repositories?

  • A) Content exclusion rules
  • B) The public code filter (duplication detection)
  • C) Prompt and suggestion collection
  • D) Custom instructions

Question 3​

A repository administrator adds a content exclusion rule for **/secrets/**. A developer opens src/secrets/api-keys.ts in VS Code. What happens?

  • A) Copilot provides suggestions but flags them with a warning
  • B) Copilot provides suggestions only in Copilot Chat, not as code completions
  • C) Copilot is disabled for this file -- no completions or chat references are available
  • D) Copilot provides suggestions but does not use the file as context for other files

Question 4​

On Copilot Business and Enterprise plans, what happens to prompts and suggestions (the code context sent to and returned from Copilot) by default?

  • A) They are retained by GitHub for 30 days and then deleted
  • B) They are used to train GitHub's AI models to improve suggestions
  • C) They are not retained by GitHub and are not used for model training
  • D) They are retained only if the organization enables audit logging

Question 5​

An organization configures content exclusion rules for **/.env files. A developer copies the contents of .env into a new file called config.local.ts. Does the content exclusion protect the copied content?

  • A) Yes -- content exclusion tracks content regardless of the file it resides in
  • B) Yes -- the IDE detects content similarity and applies the exclusion
  • C) No -- content exclusion applies to file paths, not to file content; the copied content is not excluded
  • D) No -- but Copilot's built-in security filter will detect and block secret values

Question 6​

Where are content exclusion rules for an organization configured?

  • A) In each repository's .github/copilot-exclusions.yml file
  • B) In the organization's Copilot settings under "Content exclusion"
  • C) In the enterprise billing dashboard
  • D) In the .github/copilot-instructions.md file in each repository

Question 7​

What is the purpose of the .github/copilot-instructions.md file?

  • A) It defines which files Copilot is excluded from accessing
  • B) It provides persistent context and coding standards that Copilot Chat uses when generating responses
  • C) It configures the public code filter for the repository
  • D) It assigns Copilot seats to repository contributors

Question 8​

An enterprise has three organizations. The enterprise owner enables Copilot for "Selected organizations" and chooses only two of the three. What happens to members of the third organization?

  • A) They can use Copilot with their personal Copilot Individual subscriptions
  • B) They cannot use Copilot through the enterprise, even if they have assigned seats
  • C) They can use Copilot but only for code completions, not for chat
  • D) They are automatically moved to one of the enabled organizations

Question 9​

Which of the following is a known limitation of content exclusion rules?

  • A) They can only be configured at the enterprise level, not the organization level
  • B) They apply only to code completions and have no effect on Copilot Chat
  • C) They depend on IDE extension support and may not be enforced if an extension does not implement them
  • D) They are limited to a maximum of 10 file path patterns per organization

Question 10​

An organization creates targeted instruction files in .github/instructions/ with an applyTo glob pattern. When does Copilot use these instruction files?

  • A) Only when the developer explicitly references them with #prompt:
  • B) Automatically, when the developer is working on files that match the applyTo pattern
  • C) Only during Copilot Chat sessions, not during code completions
  • D) Only when the enterprise owner enables the "Custom instructions" policy

Answer Key​

QAnswerExplanation
1BEnterprise policies set the ceiling for all organizations. When the enterprise disables a feature, no organization within that enterprise can enable it. The organization owner must request that the enterprise owner change the enterprise-level policy.
2BThe public code filter (also called duplication detection) compares Copilot's suggestions against publicly available code on GitHub and blocks matches. Content exclusion rules protect specific files from being read by Copilot, which is a different concern.
3CContent exclusion rules completely disable Copilot for matched files. The developer will not receive code completions, cannot reference the file in Copilot Chat, and the file's content will not be used as context for suggestions in other files.
4COn Copilot Business and Enterprise plans, GitHub provides a contractual guarantee that prompts and suggestions are not retained and are not used for model training. This is a key differentiator from the consumer-tier plans.
5CContent exclusion rules are path-based, not content-based. They match file paths using glob patterns. If a developer copies excluded content into a file that does not match any exclusion rule, Copilot can access that copied content. This is an important limitation to communicate to developers.
6BOrganization-level content exclusion rules are configured in the organization's Copilot settings (Settings > Copilot > Content exclusion). Repository-level exclusions are configured in the repository settings. There is no file-based configuration for exclusion rules.
7BThe .github/copilot-instructions.md file provides persistent context (coding standards, architectural patterns, best practices) that is automatically included in Copilot Chat interactions. It does not control file exclusions, public code filtering, or seat assignment.
8BWhen an enterprise enables Copilot for "Selected organizations" only, members of non-selected organizations cannot use Copilot through the enterprise. Their personal Copilot Individual subscriptions (if any) are separate from the enterprise and would not be managed by enterprise policies.
9CContent exclusion rules are enforced by the IDE extensions (VS Code, Visual Studio, JetBrains, etc.). If an IDE extension has not implemented content exclusion support, the rules may not be enforced in that environment. This is why organizations should verify exclusion behavior in each supported IDE.
10BTargeted instruction files with an applyTo glob pattern are automatically detected by Copilot when the developer works on files matching the pattern. The instructions are attached as context without the developer needing to explicitly reference them. This differs from prompt files, which require explicit #prompt: references.