skip to content

In GitHub Copilot CLI, how do `--available-tools` and `--allow-tool` differ, and how would a `copilot -p` run commit but never push?

level: seniorimportance: should knowfreq 6%

answer

  1. two layers of control
  2. what the model knows exists
  3. what runs without asking
  4. deny beats allow, always
  5. shell(git:*) minus one subcommand

basics

~10 s

--available-tools limits which tools the model can use at all; --allow-tool lets named tools run without prompting. For commit-but-never-push, pass --allow-tool='shell(git:*)' with --deny-tool='shell(git push)'; deny rules always win.

solid answer

~50 s

Copilot CLI has two layers. `--available-tools` and `--excluded-tools` decide which tools the model is aware of, by tool name such as `bash`, `edit` or `web_fetch`; a tool outside the available set cannot be used even if you allow it. `--allow-tool` and `--deny-tool` take permission patterns of the form `Kind(argument)` (kinds `shell`, `write`, `read`, `url`, `memory` or an MCP server name) and decide what runs without asking or never runs. Read-only operations are allowed automatically; others need approval, and in an unattended `-p` run nobody is there to give it, so you pre-approve what the task needs. So a pipeline step passes `--allow-tool='write, shell(git:*)'` plus `--deny-tool='shell(git push)'`: deny rules take precedence over allow rules, even over `--allow-all` and saved approvals. `--allow-all-tools` approves every tool, and `--allow-all` (alias `--yolo`) also allows all paths and URLs; the docs reserve those for sandboxed environments.

code

bash · 5 lines
bash
copilot -p 'Fix all ESLint errors in this project and commit the result' \
  -s --no-ask-user \
  --available-tools='bash,edit,create,view,grep,glob' \
  --allow-tool='write, shell(npx:*), shell(git:*)' \
  --deny-tool='shell(git push)'

go deeper

for a junior

Recall that copilot -p runs one prompt and exits, and that --allow-tool lets named tools run without asking.

for a middle

Explain the Kind(argument) patterns, that read-only operations are auto-allowed, and that deny rules beat allow rules, allow-all and saved approvals.

for a senior

Design a pipeline invocation with both layers, a narrow available set and allowlist plus targeted denies, and justify why allow-all belongs only in an isolated environment.

for a principal

Set the organisation's stance on Copilot CLI in automation: when to prefer GitHub Agentic Workflows, which permissive options administrators should block, and how credentials and billing are attributed.

## The scenario and programmatic mode A platform engineer wants a pipeline step that runs **GitHub Copilot CLI** (`copilot`, installed from `@github/copilot`) non-interactively: fix lint errors and commit the result, but never push. Two questions decide whether that is safe: which tools the model can even see, and which of those may run without a person approving them. `copilot -p "PROMPT"` (or `--prompt`) runs one prompt and exits; a prompt piped to `copilot` works too, but piped input is ignored when `-p` is given. Useful companions: `-s` prints only the agent's response, `--no-ask-user` stops it pausing for clarifying questions, `--output-format json` emits JSONL, and `--model` pins a model. In GitHub Actions, the docs authenticate with `COPILOT_GITHUB_TOKEN` (highest precedence over `GH_TOKEN` and `GITHUB_TOKEN`) and recommend GitHub Agentic Workflows for most automation. ## Layer 1: what the model can use | Option | Effect | |---|---| | `--available-tools` | Only the listed tools exist for the model; all others are unavailable | | `--excluded-tools` | The listed tools are removed; the rest stay | | both together | The allowlist from `--available-tools` applies and `--excluded-tools` is ignored | These take **tool names**: `bash`, `edit`, `create`, `view`, `grep`, `glob`, `web_fetch`, `task` and others. A tool outside the available set **cannot be used even if `--allow-tool` names it**, and the model does not waste turns trying. ## Layer 2: what runs without asking `--allow-tool` and `--deny-tool` take **permission patterns** `Kind(argument)`, comma-separated: - `shell(git:*)` matches every `git` subcommand (`git push`, `git status`), but not `gitea`. - `shell(npm test)` matches that exact command. - `write` allows all file writes; `write(.github/copilot-instructions.md)` narrows it to one path. - `url(github.com)` allows that site; `MyMCP(create_issue)` allows one MCP tool. Rules that matter in a pipeline: 1. **Read-only operations** (searching, reading files, read-only shell commands) are allowed automatically; modifying actions need approval. 2. **Deny rules always take precedence** over allow rules, even with `--allow-all` set or an approval saved in `permissions-config.json`. 3. Command-line allow and deny options apply **only to the current session** and are never written to `permissions-config.json`. ## Commit but never push Combine both layers: a tight available set, an allowlist for the work, and one deny rule for the step you never want. The example below is the shape the docs use, extended with `write` so the run can save its fixes. - `--available-tools='bash,edit,create,view,grep,glob'` hides web fetching and subagents, so the model never plans around them. - `--allow-tool='write, shell(npx:*), shell(git:*)'` pre-approves file writes, the linter run through `npx` and every `git` subcommand. - `--deny-tool='shell(git push)'` removes push from that git allowance; because deny wins, no later allow or saved approval can bring it back for this run. - `-s` and `--no-ask-user` keep the output clean and stop the agent pausing to ask clarifying questions. The result is a run that can edit and commit locally on the runner, while publishing the commit stays a separate, human-controlled step. ## Running it in GitHub Actions - **Install** the CLI on the runner, for example with `npm install -g @github/copilot`, and set `COPILOT_AUTO_UPDATE=false` if you want the version pinned. - **Authenticate** either with a fine-grained personal access token that has the "Copilot Requests" permission, passed as `COPILOT_GITHUB_TOKEN`, or with the workflow's built-in token, which for organization-owned repositories needs the policy "Allow use of Copilot CLI billed to the organization". - **Keep secrets out of logs**: values of `GITHUB_TOKEN` and `COPILOT_GITHUB_TOKEN` are redacted by default, and `--secret-env-vars` adds others. - **Keep a record**: `--share` writes the session transcript to a Markdown file after the run, which may itself contain sensitive information. - **Watch the trigger**: workflows that run on pull requests from forks carry a higher prompt-injection risk. ## The permissive options `--allow-all-tools` gives full access to the available tools. `--allow-all`, or its alias `--yolo`, equals `--allow-all-tools --allow-all-paths --allow-all-urls`; `COPILOT_ALLOW_ALL=true` does the same through the environment. The docs strongly recommend these only in an **isolated environment**, never as a shell alias, and Copilot Business or Enterprise administrators may block them. A denylist added to an allow-all run blocks only what you thought to list, which is why the narrow allowlist is the safer default for automation.

  • Why is `--allow-all-tools --deny-tool='shell(git push)'` weaker than an explicit allowlist?
    The deny rule does win, so `git push` is blocked. But every other tool now runs without approval: any shell command, any file write, any configured MCP tool. A denylist blocks only what you thought to name, while `--allow-tool` with a short list runs only what the task needs. The docs keep allow-all options for isolated environments.
  • Do approvals given in an interactive Copilot CLI session affect later runs in the same repository?
    Approvals chosen as 'don't ask again' for a location are saved to `permissions-config.json` (by default under `~/.copilot`) for that repository root or directory, while command-line allow and deny options apply to the current session only and are never saved. Deny rules still beat saved approvals, and `/reset-allowed-tools` clears saved approvals for the current location.

  • shell(git:*) covers only read-only git commands such as status and log.
  • An --allow-tool entry overrides a matching --deny-tool entry.
  • --excluded-tools and --deny-tool are two spellings of the same control.
  • --yolo is just another name for --allow-all-tools.
  • Flags such as --allow-tool are saved to permissions-config.json for next time.