|
| 1 | +--- |
| 2 | +title: Repository configuration for the GitHub Copilot app |
| 3 | +shortTitle: Repository configuration |
| 4 | +allowTitleToDifferFromFilename: true |
| 5 | +intro: 'Define repository-specific instructions, scripts, and automation behavior for the {% data variables.copilot.github_copilot_app %}.' |
| 6 | +product: '{% data reusables.gated-features.github-app %}<br><a href="https://github.com/features/ai/github-app" target="_blank" class="btn btn-primary mt-3 mr-3 no-underline"><span>Download {% data variables.copilot.github_copilot_app %}</span> {% octicon "link-external" height:16 %}</a>' |
| 7 | +versions: |
| 8 | + feature: copilot |
| 9 | +contentType: reference |
| 10 | +category: |
| 11 | + - Author and optimize with Copilot |
| 12 | + - Configure Copilot |
| 13 | +--- |
| 14 | + |
| 15 | +Use `.github/github-app.yml` in your repository to define how the {% data variables.copilot.github_copilot_app %} should behave for that project. |
| 16 | + |
| 17 | +You can also edit these project settings in the app UI. If `.github/github-app.yml` already exists, UI changes are written back to that file. If it does not exist yet, you can create it from current project settings in the app. |
| 18 | + |
| 19 | +## About the config file location |
| 20 | + |
| 21 | +Create the file at: |
| 22 | + |
| 23 | +```text copy |
| 24 | +.github/github-app.yml |
| 25 | +``` |
| 26 | + |
| 27 | +The app also supports the legacy filename `.github/copilot-desktop.yml` for backward compatibility. |
| 28 | + |
| 29 | +For UI-based customization steps, see [AUTOTITLE](/copilot/how-tos/github-copilot-app/customize-github-copilot-app). |
| 30 | + |
| 31 | +## Review and trust the configuration |
| 32 | + |
| 33 | +When the app detects a configuration from the repository, it does not apply repository instructions, scripts, or other settings from the file until you review and accept the configuration. This protects you from running commands or applying settings that were added by another contributor. Configurations that you create or update through the app UI are trusted automatically. |
| 34 | + |
| 35 | +> [!WARNING] |
| 36 | +> Before accepting a repository configuration, review every configured command and the dependencies it runs. Scripts and their child processes receive the {% data variables.product.github %} credentials described later in this article, so never configure them to log or persist these environment variables. |
| 37 | +
|
| 38 | +If the file changes outside the app, including changes to whitespace or comments, you must review and accept the updated configuration before the app applies it. Until you accept the current version, the app continues to use the project settings that were previously configured in the app. |
| 39 | + |
| 40 | +## Example configuration |
| 41 | + |
| 42 | +```yaml copy |
| 43 | +instructions: | |
| 44 | + Use bun instead of npm. |
| 45 | +
|
| 46 | +scripts: |
| 47 | + - name: Setup |
| 48 | + command: bun install |
| 49 | + triggers: |
| 50 | + - session.create |
| 51 | + - name: Run |
| 52 | + command: bun run dev |
| 53 | + - name: Archive cleanup |
| 54 | + command: rm -rf node_modules |
| 55 | + triggers: |
| 56 | + - session.archive |
| 57 | + |
| 58 | +server_ready_pattern: '(?i)Local:\s+(https?://\S+)' |
| 59 | +auto_open_in_browser: true |
| 60 | + |
| 61 | +automation: |
| 62 | + auto_issue_session: true |
| 63 | + remote_control: false |
| 64 | +``` |
| 65 | +
|
| 66 | +## Configure instructions and scripts |
| 67 | +
|
| 68 | +### `instructions` |
| 69 | + |
| 70 | +Use `instructions` to add repository-specific guidance to the system prompt for sessions in the project. If you also configure global instructions in the app, the global instructions are applied first, followed by the project instructions. |
| 71 | + |
| 72 | +### `scripts` |
| 73 | + |
| 74 | +Use `scripts` to define commands that appear in the app and can run manually or on specific triggers. |
| 75 | + |
| 76 | +Each script item supports: |
| 77 | + |
| 78 | +* `name` (`string`): Display name in the UI. |
| 79 | +* `command` (`string`): Command to run. |
| 80 | +* `triggers` (`string[]`, optional): Events that auto-run the script. |
| 81 | + |
| 82 | +Scripts without `triggers` are manual. |
| 83 | + |
| 84 | +### Trigger values |
| 85 | + |
| 86 | +Use canonical trigger values in your file: |
| 87 | + |
| 88 | +* `session.create` |
| 89 | +* `session.archive` |
| 90 | + |
| 91 | +The app also accepts these legacy aliases when parsing existing files: |
| 92 | + |
| 93 | +* `workspace.create` (alias for `session.create`) |
| 94 | +* `workspace.archive` (alias for `session.archive`) |
| 95 | + |
| 96 | +When a triggered script runs, `COPILOT_SCRIPT_TRIGGER` is set to the canonical value: |
| 97 | + |
| 98 | +* `session.create` |
| 99 | +* `session.archive` |
| 100 | + |
| 101 | +## Configure server detection and browser behavior |
| 102 | + |
| 103 | +### `server_ready_pattern` |
| 104 | + |
| 105 | +`server_ready_pattern` is a regular expression used to detect when a run script has started a server. |
| 106 | + |
| 107 | +Patterns use the syntax supported by Rust's `regex` crate. For syntax details, see [Syntax](https://docs.rs/regex/1/regex/#syntax) in the crate documentation. If the pattern is invalid, the app uses its default server detection pattern. |
| 108 | + |
| 109 | +Use a first capture group for the detected URL or port. The app reads capture group `1`: |
| 110 | + |
| 111 | +* If the capture is a URL (`http://...` or `https://...`), the URL is used. |
| 112 | +* If the capture is only a port number (for example `3000`), the app converts it to `http://localhost:3000`. |
| 113 | + |
| 114 | +### `auto_open_in_browser` |
| 115 | + |
| 116 | +If `auto_open_in_browser` is `true`, the app opens the detected run URL in the integrated browser. If this field is omitted, the effective default is `true`. |
| 117 | + |
| 118 | +## Configure automation behavior |
| 119 | + |
| 120 | +Set automation options under `automation`: |
| 121 | + |
| 122 | +* `automation.auto_issue_session` (`boolean`) controls whether the app automatically starts a session with issue context. If omitted, the effective default is `true`. |
| 123 | +* `automation.remote_control` (`boolean`) controls whether sessions can be accessed from the {% data variables.product.github %} web interface or {% data variables.product.prodname_mobile %}. If omitted, the effective default is `false`. |
| 124 | + |
| 125 | +If your {% data variables.product.prodname_copilot_short %} seat comes from an organization, the applicable "Store local sessions in the Cloud" policy must be set to "View and control" for remote control to be available. Enterprise-managed `remoteControl` settings can further restrict remote control even when `automation.remote_control` is `true`. For more information, see [AUTOTITLE](/copilot/concepts/agents/copilot-cli/about-remote-control) and [AUTOTITLE](/copilot/reference/enterprise-administrators/enterprise-managed-settings). |
| 126 | + |
| 127 | +## Runtime environment variables for scripts |
| 128 | + |
| 129 | +Scripts run with these app-provided environment variables: |
| 130 | + |
| 131 | +| Variable | Description | |
| 132 | +| --- | --- | |
| 133 | +| `COPILOT_WORKSPACE_NAME` | Current workspace name. | |
| 134 | +| `COPILOT_WORKSPACE_PATH` | Absolute path to the workspace. | |
| 135 | +| `COPILOT_ROOT_PATH` | Absolute path to the project root checkout. | |
| 136 | +| `COPILOT_DEFAULT_BRANCH` | Project default branch. | |
| 137 | +| `COPILOT_PORT` | App WebSocket port for the current workspace context. | |
| 138 | +| `COPILOT_SCRIPT_TRIGGER` | Trigger that launched the script (only set for triggered scripts). | |
| 139 | +| `GH_TOKEN` | Token for the selected {% data variables.product.github %} account. | |
| 140 | +| `GH_HOST` | Host for the selected {% data variables.product.github %} account. | |
| 141 | +| `COPILOT_GH_ACCOUNT_*` | Host- and account-specific tokens for every signed-in account, including the selected account. | |
| 142 | + |
| 143 | +For each `COPILOT_GH_ACCOUNT_*` variable, the app lowercases the host and login, leaves ASCII letters and digits unchanged, and replaces every other UTF-8 byte with its uppercase hexadecimal value surrounded by underscores. The variable name uses the format `COPILOT_GH_ACCOUNT_<HOST>_<LOGIN>`. For example, the token for `alice` on `github.com` is `COPILOT_GH_ACCOUNT_github_2E_com_alice`, and the token for `user` on `ghe-example.com` is `COPILOT_GH_ACCOUNT_ghe_2D_example_2E_com_user`. |
| 144 | + |
| 145 | +## Legacy compatibility |
| 146 | + |
| 147 | +For backward compatibility, the app can still parse the older object-based `scripts` shape: |
| 148 | + |
| 149 | +```yaml copy |
| 150 | +scripts: |
| 151 | + setup: bun install |
| 152 | + run: bun run dev |
| 153 | + archive: rm -rf node_modules |
| 154 | +``` |
| 155 | + |
| 156 | +In this legacy shape: |
| 157 | + |
| 158 | +* `setup` maps to a script with the create trigger. |
| 159 | +* `archive` maps to a script with the archive trigger. |
| 160 | +* `run` maps to manual script entries and can be either a single command string or a list of `{ name, command }` objects. |
0 commit comments