Copilot CLI: Hooks, MCP Servers, Skills, and Customization

JSON snippets and commands for extending GitHub Copilot CLI with hooks, MCP servers, skills, and repository initialization.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Hooks basics

Run custom commands at key agent lifecycle moments.

Store hooks in the repository

Hooks are loaded from a repository folder.

textANYcopilothookspath
text
.github/hooks/hooks.json

Copilot CLI loads hook configuration files from `.github/hooks/*.json` in the current working directory.

Minimal command hook template

Start with a JSON hook file.

jsonANYcopilothooksjson
json
{
  "version": 1,
  "hooks": {
    "preToolUse": [
      {
        "type": "command",
        "bash": "./scripts/pre-tool.sh",
        "powershell": "./scripts/pre-tool.ps1",
        "cwd": "scripts",
        "timeoutSec": 30
      }
    ]
  }
}

The command-hook schema supports `bash`, `powershell`, `cwd`, `env`, and `timeoutSec`.

Run a session-start hook script

Trigger repo automation when a session begins.

jsonANYcopilothookssession-start
json
{
  "type": "command",
  "bash": "./scripts/session-start.sh",
  "powershell": "./scripts/session-start.ps1",
  "cwd": "scripts",
  "timeoutSec": 30
}

Session start hooks can log, bootstrap, or validate repo state before the agent proceeds.

Log prompts for auditing

Call a script that records prompt activity.

jsonANYcopilothooksaudit
json
{
  "version": 1,
  "hooks": {
    "sessionStart": [
      {
        "type": "command",
        "bash": "./scripts/audit-log.sh"
      }
    ]
  }
}

A common enterprise pattern is logging sessions for compliance or internal review.

MCP servers and built-ins

Add external tools and services to Copilot CLI.

Add an MCP server for one session from a file

Load additional MCP server config at runtime.

bashANYcopilotmcpconfig
bash
copilot --additional-mcp-config=@./mcp-extra.json

This augments the persistent config in `~/.copilot/mcp-config.json`.

Disable all built-in MCP servers

Run without the default built-in servers.

bashANYcopilotmcpsecurity
bash
copilot --disable-builtin-mcps

Useful for locked-down or deterministic runs.

Disable a specific MCP server

Turn off one named server.

bashANYcopilotmcpgithub
bash
copilot --disable-mcp-server=github-mcp-server

Helpful when you want local code assistance without GitHub API access.

Enable a specific GitHub MCP tool

Grant access to one GitHub MCP capability.

bashANYcopilotmcpgithubtools
bash
copilot --add-github-mcp-tool=search_issues

Use narrow tool grants to keep sessions focused and lower risk.

Enable a GitHub MCP toolset

Grant a named toolset instead of individual tools.

bashANYcopilotmcpgithubtoolset
bash
copilot --add-github-mcp-toolset=all

Use `all` when you truly need the full GitHub MCP toolset.

Persistent MCP config location

Store servers in the user MCP config file.

jsonANYcopilotmcpconfigpath
json
~/.copilot/mcp-config.json

Persistent MCP server definitions belong here, while session-only additions can use `--additional-mcp-config`.

Local MCP server template

Define a local stdio MCP server.

jsonANYcopilotmcplocal-server
json
{
  "my-local-server": {
    "type": "local",
    "command": "node",
    "args": ["./tools/mcp-server.js"],
    "tools": ["*"]
  }
}

Local or stdio transport requires `command` and `args`, with `tools` defining what the server exposes.

Skills and custom agents

Extend Copilot with reusable instructions and task-specific behavior.

Project skill directory

Store project skills in the standard directory.

textANYcopilotskillspath
text
.github/skills/

Skills can also live in `.agents/skills/`, with first match winning on duplicate names.

Minimal skill frontmatter

Define a reusable skill.

markdownANYcopilotskillsmarkdown
markdown
---
name: repo-audit
description: Review a repository for risky shell scripts, weak CI defaults, and missing docs.
allowed-tools:
  - shell(git:*)
user-invocable: true
---

Focus on reproducible, low-risk recommendations.

A skill lives in its own directory and includes a `SKILL.md` file.

List installed skills

Inspect active skills from the session.

textANYcopilotskillsslash-command
text
/skills list

Use `/skills info NAME`, `/skills add`, `/skills remove`, or `/skills reload` as needed.

Initialize Copilot repo features

Set up custom instructions and agentic repo features.

textANYcopilotinitrepo
text
/init

A fast way to scaffold Copilot instructions and related project-level features.

Initialize Copilot instructions from the command line

Run init without first entering a full session.

bashANYcopilotinitcommand
bash
copilot init

This initializes Copilot custom instructions for the repository.

Recommended next

No recommendations yet.