{"meta":{"title":"Configuring GitHub Copilot CLI","intro":"Configure trusted directories, tool access, and path and URL permissions for Copilot CLI","product":"GitHub Copilot","breadcrumbs":[{"href":"/en/copilot","title":"GitHub Copilot"},{"href":"/en/copilot/how-tos","title":"How-tos"},{"href":"/en/copilot/how-tos/copilot-cli","title":"Copilot CLI"},{"href":"/en/copilot/how-tos/copilot-cli/set-up-copilot-cli","title":"Set up Copilot CLI"},{"href":"/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/configure-copilot-cli","title":"Configure Copilot CLI"}],"documentType":"article"},"body":"# Configuring GitHub Copilot CLI\n\nConfigure trusted directories, tool access, and path and URL permissions for Copilot CLI\n\n## Introduction\n\nCopilot CLI has several configuration options that control what it can access and do on your behalf.\n\nThis article shows you how to set trusted directories, configure access for tools, and grant permissions to file paths and URLs.\n\n### Prerequisites\n\n* Install the Copilot CLI. See [Installing GitHub Copilot CLI](/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli).\n\n## Setting trusted directories\n\nTrusted directories control where Copilot CLI can read, modify, and execute files. Trusting a directory has security implications, see [Security considerations](/en/copilot/concepts/agents/copilot-cli/about-copilot-cli#security-considerations).\n\n### Choosing to trust a directory\n\nWhen you start a GitHub Copilot CLI session, you'll be asked to confirm that you trust the files in, and below, the directory from which you launched the CLI.\n\nYou can choose to trust the current directory for:\n\n* The currently running session only\n* This and future sessions\n\nIf you choose to trust the directory for future sessions, the trusted directory prompt will not be displayed again. You should only choose this second option if you are sure that this location will always be a safe place for Copilot to operate.\n\n### Editing trusted directories\n\nYou can edit the list of permanently trusted directories. Trusted directories are stored in the automatically managed `config.json` file.\n\n1. Open the CLI's `config.json` file. By default, it's stored in a `.copilot` folder under your home directory:\n\n   * **macOS/Linux**: `~/.copilot/config.json`\n   * **Windows**: `$HOME\\.copilot\\config.json`\n\nYou can change the config location by setting the `COPILOT_HOME` environment variable. This would change `~/.copilot/` and `$HOME\\.copilot\\` in the above paths.\n\n1. Edit the contents of the `trustedFolders` array.\n\n## Setting allowed tools\n\nYou can control which tools Copilot CLI can use, either by responding to approval prompts when Copilot attempts to use a tool, or by specifying permissions via command-line flags.\n\nBe aware that allowing tool access has security implications, see [Security considerations](/en/copilot/concepts/agents/copilot-cli/about-copilot-cli#security-considerations).\n\nIn this section, you can learn how to:\n\n* [Allow a tool for the first time](#allowing-a-tool-for-the-first-time)\n* [Allow tools to be used without manual approval](#allowing-tools-to-be-used-without-manual-approval)\n* [Specify which tool you want to allow or deny](#specifying-which-tool-you-want-to-allow-or-deny)\n* [Allow some tools while denying others](#allowing-some-tools-while-denying-others)\n* [Limit available tools](#limiting-available-tools)\n\n### Allowing a tool for the first time\n\nThe first time that Copilot needs to use a tool that may require approval—for example, `touch`, `chmod`, `node`, or `sed`—it will ask you whether you want to allow it to run. Whether you’re prompted can depend on the tool and how it’s being used (such as the arguments provided or whether the tool has been previously approved).\n\n1. Prompt Copilot to perform a task that requires a tool. For example:\n\n   ```shell\n   copilot -p \"Create a new file called README.md with a project description\"\n   ```\n\n2. Choose from one of the three options:\n\n   * `1. Yes`\n\n     Choose this option to allow Copilot to run this particular command, this time only. The next time it needs to use this tool, it will ask you again.\n\n   * `2. Yes, and approve TOOL for the rest of the running session`\n\n     Choose this option to allow Copilot to use this tool for the duration of the currently running session. It will ask for your approval again in new sessions, or if you resume the current session in the future. If you choose this option, you are allowing Copilot to use this tool in any way it thinks is appropriate.\n\n     For example, if Copilot asks you to allow it to run the command `rm ./this-file.txt`, and you choose option 2, then Copilot can run any `rm` command (for example, `rm -rf ./*`) during the current run of this session, without asking for your approval.\n\n   * `3. No, and tell Copilot what to do differently (Esc)`\n\n     Choose this option to cancel the proposed command and instruct Copilot to try a different approach.\n\n### Allowing tools to be used without manual approval\n\nYou can use command-line flags to designate tools that Copilot can use without asking for your approval.\n\n#### Allowing all tools\n\nUse the `--allow-all-tools` to allow Copilot to use any tool without asking for your approval.\n\n* For example:\n\n  ```shell\n  copilot -p \"Revert the last commit\" --allow-all-tools\n  ```\n\n#### Denying a tool\n\nUse `--deny-tool` to prevent Copilot from using a specific tool.\n\n* For example:\n\n  ```shell\n  copilot --deny-tool='shell(git push)'\n  ```\n\nThis option takes precedence over the `--allow-all-tools` and `--allow-tool` options.\n\n#### Allowing a tool\n\nUse `--allow-tool` to allow Copilot to use a specific tool without asking for your approval.\n\n* For example:\n\n  ```shell\n  copilot --allow-tool='shell'\n  ```\n\n### Specifying which tool you want to allow or deny\n\nTo use the `--deny-tool` and `--allow-tool` options, you must specify what type of tool you want to allow or deny:\n\n* [Shell commands](#allowing-or-denying-shell-commands)\n* ['Write' tools](#allowing-or-denying-write-tools)\n* [MCP server tools](#allowing-or-denying-mcp-server-tools)\n\n#### Allowing or denying shell commands\n\nUse `shell(COMMAND)` to allow or deny a specific shell command.\n\n* For example, to prevent Copilot from using any `rm` command, use:\n\n  ```shell\n  copilot --deny-tool='shell(rm)'\n  ```\n\nFor `git` and `gh` commands, specify a particular first-level subcommand to allow or deny.\n\n* For example, to prevent Copilot from using `git push`, use:\n\n  ```shell\n  copilot --deny-tool='shell(git push)'\n  ```\n\nThe tool specification is optional. For example, `copilot --allow-tool='shell'` allows Copilot to use any shell command without individual approval.\n\n#### Allowing or denying `'write'` tools\n\nUse `'write'` to allow or deny tools—other than shell commands—permission to modify files.\n\n* For example, to allow Copilot to edit files without your individual approval, use:\n\n  ```shell\n  copilot --allow-tool='write'\n  ```\n\n#### Allowing or denying MCP server tools\n\nUse `'MCP_SERVER_NAME'` to allow or deny a specific tool from the specified MCP server.\n\n* For example, to prevent Copilot from using the tool called `tool_name` from the MCP server called `My-MCP-Server`, use:\n\n  ```shell\n  copilot --deny-tool='My-MCP-Server(tool_name)'\n  ```\n\n`MCP_SERVER_NAME` is the name of an MCP server that you have configured.\n\nTools from the server are specified in parentheses, using the tool name that is registered with the MCP server.\n\nUsing the server name without specifying a tool allows or denies all tools from that server.\n\nYou can find an MCP server's name by entering `/mcp` in the interactive mode of Copilot CLI and selecting the server from the list that's displayed.\n\n### Allowing some tools while denying others\n\nTo determine exactly which tools Copilot can use without asking for your approval, you can use a combination of approval options. For example:\n\n* To prevent Copilot from using the `rm` and `git push` commands, but automatically allow all other tools, use:\n\n  ```shell\n  copilot --allow-all-tools --deny-tool='shell(rm)' --deny-tool='shell(git push)'\n  ```\n\n* To prevent Copilot from using the tool `tool_name` from the MCP server named `My-MCP-Server`, but allow all other tools from that server to be used without individual approval, use:\n\n  ```shell\n  copilot --allow-tool='My-MCP-Server' --deny-tool='My-MCP-Server(tool_name)'\n  ```\n\n### Limiting available tools\n\nTo restrict Copilot to a specific set of tools, use `--available-tools`.\n\nTools not included in this list will not be available to Copilot.\n\n## Setting path permissions\n\nPath permissions control which directories and files Copilot can access.\n\nBy default, Copilot CLI can access the current working directory, its subdirectories, and the system temp directory.\n\nPath permissions apply to shell commands, file operations (create, edit, view), and search tools (such as `grep` and glob patterns). For shell commands, paths are heuristically extracted by tokenizing command text and identifying tokens that look like paths.\n\n> \\[!WARNING]\n> Path detection for shell commands has limitations:\n>\n> * Paths embedded in complex shell constructs may not be detected.\n> * Only a specific set of environment variables are expanded (`HOME`, `TMPDIR`, `PWD`, and similar). Custom variables like `$MY_PROJECT_DIR` are not expanded and may not be validated correctly.\n> * Symlinks are resolved for existing files, but not for files being created.\n\n### Allowing access to all paths\n\nTo disable path verification and allow access to any path, use the `--allow-all-paths` flag when starting Copilot CLI.\n\n### Disallowing access to the temp directory\n\nTo disallow access to the temp directory, use `--disallow-temp-dir`.\n\n## Setting URL permissions\n\nURL permissions control which external URLs Copilot can access. By default, all URLs require approval before access is granted.\n\nURL permissions apply to the `web_fetch` tool and a curated list of shell commands that access the network (such as `curl`, `wget`, and `fetch`). For shell commands, URLs are extracted using regex patterns.\n\n> \\[!WARNING]\n> URL detection for shell commands has limitations:\n>\n> * URLs in file contents, config files, or environment variables read by commands are not detected.\n> * Obfuscated URLs (such as split strings or escape sequences) may not be detected.\n> * HTTP and HTTPS are treated as different protocols and require separate approval.\n\nURL permissions can be persisted for the session or permanently.\n\n### Disabling URL verification\n\nTo disable URL verification, use the `--allow-all-urls` flag.\n\n### Pre-approving specific domains\n\nTo pre-approve specific domains, use `--allow-url=DOMAIN`.\n\n* For example, `--allow-url=github.com`.\n\n### Denying specific domains\n\nTo deny specific domains, use `--deny-url=DOMAIN`.\n\n* For example, `--deny-url=github.com`.\n\n## Allowing all tools, paths, and URLs\n\nTo allow all tools, paths and URLs, use `--allow-all`, or its alias, `--yolo`.\n\nThis flag combines:\n\n* `--allow-all-tools` (skip tool approval).\n* `--allow-all-paths` (disable path verification).\n* `--allow-all-urls` (disables URL verification).\n\nDuring an interactive session, you can also enable all permissions with the `/allow-all` or `/yolo` slash commands.\n\n> \\[!NOTE] If you have a Copilot Business or Copilot Enterprise license, these commands may be blocked by an enterprise administrator.\n\n## Restrict access to files\n\nThe various `--allow-all...` options save you from having to decide whether to allow Copilot to access individual tools, files, and URLs. However, using them widens the scope for Copilot to perform actions that you might not want it to—for example, altering files outside of the repository you are working in.\n\nTo mitigate this risk, you can instruct the CLI to sandbox its commands (local sandboxing), or you can run the entire Copilot CLI session within a remote, sandboxed environment (cloud sandboxing). For more information, see [About cloud and local sandboxes for GitHub Copilot](/en/copilot/concepts/about-cloud-and-local-sandboxes).\n\n## Further reading\n\n* [Customize GitHub Copilot CLI](/en/copilot/how-tos/copilot-cli/customize-copilot)\n* [GitHub Copilot CLI configuration directory](/en/copilot/reference/copilot-cli-reference/cli-config-dir-reference)"}