GitHub Copilot CLI permissions are not one switch. Trusting a repository, approving a tool, granting another path, allowing a URL, and isolating a process are different decisions. Understanding those differences lets you give an agent useful work without casually giving it everything your account can reach.
My starting point is simple: use the smallest workspace and permissions that fit the task. Expand them deliberately. If executing project code is too risky on your workstation, change the execution environment rather than trying to solve everything with prompt wording.
Version scope: This guide uses Copilot CLI 1.0.114, the latest stable release checked on November 18, 2026, and the corresponding build help alongside GitHub's documentation. Examples use PowerShell syntax. They illustrate configuration; they are not reports of end-to-end execution on every platform.
Understand the Permission Layers
The configuration guide separates several controls that are easy to blur together:
| Control | The question it answers | What it does not establish |
|---|---|---|
| Workspace trust | Do I trust this directory and its configuration? | Blanket approval for every operation |
| Tool approval | May this requested operation run without another approval? | A complete list of tools visible to the model |
| Tool availability | Which tools can the model request? | Operating-system isolation |
| Path permissions | Which file locations pass the CLI's path checks? | Perfect detection of paths hidden inside shell commands |
| URL permissions | Which detected destinations may be accessed? | A firewall for every possible network operation |
| Sandboxing | What restrictions apply to execution in this environment? | Identical protection across platforms and every tool |
These controls work together. An allowed tool may still need a path or URL grant. A trusted repository does not make an unsafe script safe. A deny rule for one command does not identify every other way to perform the same operation.
For the wider context, agentic terminal work still needs the same review and operational discipline as any other engineering workflow.
Start With the Directory You Trust
When you launch Copilot CLI, start from the smallest repository that contains the task. Not your home directory. Not a parent folder containing unrelated repositories, exports, and credentials.
The trust prompt is a decision about the files and configuration in that location. GitHub documents session-only and persistent directory trust. With the default Copilot home, the managed trust state is in $HOME\.copilot\config.json on Windows. The COPILOT_HOME environment variable can relocate that directory.
Do not confuse config.json with settings.json. The CLI manages state such as trusted folders in the former; user settings belong in the latter. The configuration-directory reference describes the distinction.
If a task needs a separate documentation directory, add that location explicitly:
copilot -p "Summarize the shared API documentation without editing files." --add-dir="C:\work\shared-docs" --allow-tool="read" --deny-tool="write" --deny-tool="shell"
C:\work\shared-docs is an example of an existing directory you would substitute. There is an important trust implication: --add-dir also loads configuration such as skills and agents from the added directory. It is not merely a way to make another folder readable. Review that directory before adding it.
The example denies matching built-in write requests and shell commands. It does not make every configured MCP or external-service capability read-only. Those tools need their own review and permissions.
Know Whether an Approval Lasts
In manual mode, Copilot asks about requests that are not already approved. Requests recognized as read-only can run without asking, and existing permissions affect what prompts appear.
The 1.0.114 build help distinguishes approving once from saving an approval for the repository or directory. It also documents session-only approval when there is no location in which to save it. Do not assume every repeated-tool approval disappears when you close the terminal.
A one-off approval and an approval for a command family are different commitments. If you approve a destructive command broadly, you may not be asked about its next use with different arguments.
I would review deletion, publishing, production changes, credential operations, and remote pushes individually unless a separately controlled workflow justifies more authority. Convenience is a real benefit of remembered approvals. The tradeoff is that later requests can run with less human inspection.
Use /permissions manual to select manual approval mode. In this build, /reset-allowed-tools clears session tool and exact-path approvals, turns off allow-all, and clears saved approvals for the current location. Review other persistent settings separately; resetting tool approvals is not a promise to erase every configuration or URL grant.
Match Tool Rules to the Actual Operation
The core flags are --allow-tool, --deny-tool, and --allow-all-tools. A deny rule takes precedence over an allow rule, including --allow-all-tools.
An allow rule pre-approves matching requests. It is not an exclusive allowlist by itself. Other requests may still be allowed by existing approvals, recognized read-only behavior, or another applicable policy.
| Rule | Intended scope |
|---|---|
--allow-tool="read" |
Built-in file-read requests |
--deny-tool="write" |
Matching file-write requests |
--deny-tool="shell" |
Shell-command requests |
--allow-tool="shell(git status)" |
The recognized git status command family |
--deny-tool="shell(git push)" |
The recognized git push command family |
--allow-tool="shell(git:*)" |
Git and its subcommands, including operations you may not want |
--deny-tool="My-MCP-Server(tool_name)" |
A tool registered under that configured MCP server name |
Names and matching matter. The build's copilot help permissions explains that only the first subcommand participates in command naming for tools such as git and gh. For example, shell(gh pr) covers gh pr create, but also gh pr merge and gh pr close. Writing shell(gh pr create) is not a way to approve only creation. Do not build a publication boundary on that assumption.
PowerShell command names are matched as typed. A rule for Get-ChildItem does not automatically cover all of its aliases.
A simple repository-reading task can start with:
copilot -p "Read this repository and explain its structure without editing files." --allow-tool="read" --deny-tool="write" --deny-tool="shell"
This is a narrower starting point than approving all tools. It is not a security guarantee for integrations you have configured. An MCP tool that publishes a document or changes a database is not made harmless by denying the built-in write category.
For background on those separate capabilities, building MCP servers and clients in C# is a useful companion.
Keep Tool Visibility Separate From Approval
Use --available-tools and --excluded-tools to control which tools are exposed to the model. Use permission rules to control whether a request is approved. The command reference documents both.
This distinction also matters when designing custom agents and skills. A profile's tool configuration, a skill's instructions, and command-line approval flags are not interchangeable.
If you want a genuinely constrained review workflow, inspect the effective tool set, remove unnecessary integrations, and verify the permissions that remain. A prompt saying "do not edit" is useful guidance, not an operating-system restriction.
Path Checks Are Not a Filesystem Sandbox
GitHub documents default path access to the working directory, its subdirectories, and the system temporary directory. Add specific trusted locations with --add-dir or /add-dir. --allow-all-paths removes path verification; --disallow-temp-dir removes the automatic temporary-directory grant.
Those options do not all mean the same thing. Adding one reviewed folder is a narrower expansion than disabling path checks altogether.
The configuration guide explicitly describes limitations in shell path detection. Paths in complex shell constructs may be missed. Custom environment variables may not be expanded for checking. Symlink handling differs for existing files and files being created.
Path-scoped tool rules need the same care. In this build, write(README.md) matches by trailing path components, so it is not limited to the README in the repository root. Use an appropriately scoped path when location matters.
Also, a path-scoped write(...) rule does not govern shell commands that modify the same file. Shell authorization and path checks are separate. An unscoped write approval can also affect shell-output redirection, without approving the command itself.
The practical question is not just "did I deny editing this file?" It is "which remaining capabilities can reach or change it?"
URL Approval Is Not Complete Network Isolation
The documented URL controls include --allow-url, --deny-url, and --allow-all-urls. They apply to web fetching and detected URLs in supported network-capable shell commands.
An HTTPS grant does not also approve HTTP. A rule for https://docs.github.com is therefore different from a rule for http://docs.github.com.
GitHub warns that URL extraction cannot see every destination hidden in configuration files, environment variables, or obfuscated command text. Do not describe a short domain allowlist as a firewall around arbitrary executable code.
For documentation research, approving a small set of official destinations can reduce repeated prompts without disabling URL checks globally. For confidential code, also consider what content a tool sends to that destination. Permission to contact a host is not permission to upload everything in the repository.
Headless Runs Need Decisions in Advance
With -p, there is no person available to answer a normal tool-approval prompt. Requests needing approval are denied unless an applicable approval mechanism resolves them. A narrow command may therefore return an incomplete result rather than pause for permission.
GitHub documents assisted approval as another option: --assisted-approval lets a model assess eligible requests. Requests still requiring human approval are denied in a non-interactive run. Existing deny rules and managed requirements still apply.
When successfully enabled, assisted approval takes precedence over --allow-all-tools. It does not undo path or URL grants from --allow-all or --yolo. If assisted approval cannot be enabled, the CLI warns and continues; a separate --allow-all-tools grant can still approve tools without that review.
That is a tradeoff between manual inspection and blanket pre-approval, not a deterministic safety boundary. The build help explicitly describes the judge as probabilistic.
For your first investigation, an interactive session with deliberate mode selection is often easier to inspect than unattended automation.
--allow-all and --yolo combine all-tools, all-paths, and all-URLs permission. They are broader than --allow-all-tools alone. Explicit deny rules and organization requirements can still apply; "allow all" is not a way to override an administrator. A request to run outside the sandbox still prompts in an interactive allow-all session and is denied in a -p run.
Hooks Run Policy Code, Not Just Instructions
Hooks execute commands at defined lifecycle points. A preToolUse hook can inspect a proposed tool call and return an approval or denial.
That can be useful for rules that are more specific than a simple tool pattern. But the script itself must be trustworthy. Validate its input, avoid constructing unsafe shell commands, protect its logs, and handle failures explicitly.
Hooks run synchronously, so a slow policy script can also slow every operation it intercepts. Keep the work small and deterministic.
A hook is an enforcement point within the agent workflow, not an independent operating-system boundary. Do not give an agent broad authority and assume an unreviewed script will compensate for it.
Verify the Sandbox That Is Actually Running
The local-sandboxing documentation describes /sandbox enable for enabling local sandboxing. Check /sandbox status and the effective policy rather than assuming a saved preference proves the current session is isolated.
There are several important limits:
- Local sandboxing is OS-level containment, not a separate virtual machine or container.
- Supported operating systems and prerequisites differ. Windows support depends on compatible Windows 11 updates; Linux has additional tooling requirements.
- On an unsupported host, an unmanaged session relying on a saved enable preference can start with sandboxing disabled and a warning.
- Built-in file tools run inside the CLI process and check sandbox policy themselves on a best-effort basis; their file operations do not pass through the OS sandbox.
- Remote MCP servers are not placed inside your local sandbox. On Windows, proxying and host rules require a supported Windows version and Allow local network enabled. Enforcement also relies on programs honoring proxy settings, unlike the direct-connection restrictions documented for macOS and Linux.
Those are reasons to verify the environment, not reasons to abandon isolation.
GitHub also documents cloud sandboxes for remote execution. Check current client support, organization policy, and data-handling requirements before choosing one. I am not treating a cloud launch command as verified for this CLI build.
Keep Secrets Out Before Relying on Masking
In 1.0.114, --secret-env-vars="API_KEY,DATABASE_URL" names variables to remove from shell and MCP-server environments. The build help also describes masking their values in some output, such as JSON output.
This is not complete redaction of every route by which a value might appear. The same help warns that a secret reaching a tool result another way can still reach the model and be saved in session history.
Do not paste credentials into prompts. Do not expose unnecessary environment values. Review transcripts and exported artifacts before sharing them.
Treat secret handling as its own responsibility. A script running with a credential can change a remote system even if you have carefully scoped local file editing.
Choose the Smallest Useful Workflow
For an initial review, I would use a narrow repository, manual approvals, and no unnecessary integrations. Let the agent explain what it needs before approving execution.
If running a test command is justified, remember that tests, build targets, and package scripts execute project-controlled code. "It only runs tests" is not a description of a security boundary.
These are the same separation-of-concerns questions that come up when designing agents with Microsoft Agent Framework or building an AI CLI with the Copilot SDK. Tools supply capabilities. Approvals authorize operations. The environment limits consequences.
Then evaluate the agent's behavior with representative tasks. Check what it actually requests, what runs without asking, and what happens when permission is denied.
FAQ
Does trusting a directory approve every tool?
No. Directory trust, tool approvals, path checks, and URL permissions are separate controls. Review repository configuration as well as the files you want the agent to read.
Should I approve a tool for the whole session?
Only when the matching scope is appropriate. The current build can also offer approvals remembered for the repository or directory. Read the actual prompt rather than assuming every approval is session-only.
Does denying shell(git push) stop every way of publishing code?
No. It denies that recognized command family. Other shell commands, scripts, APIs, or MCP tools can provide different publication routes.
Is --allow-all-tools the same as --yolo?
No. --yolo aliases --allow-all, which also disables path and URL verification. Explicit deny rules and managed restrictions can still apply.
Are path and URL permissions a complete security boundary?
No. GitHub documents limitations in detecting shell paths and network destinations. Use appropriate isolation and credential controls when the consequences require more protection.
When should I use a sandbox?
When execution should not have your normal workstation's reach. Verify host support, active status, effective policy, and any integrations outside that boundary before relying on it.
Does --secret-env-vars guarantee a secret never reaches the model?
No. It removes named variables from specified tool environments and masks some output paths. It does not prevent every possible tool result or pasted value from exposing a secret.




