github / github/copilot-cli

Repository-level custom agents resolved relative to git root, but skills and .mcp.json relative to cwd

Open
#3,688 3 comments 3 reactions 0 assignees View on GitHub
area:agents area:configuration
Dominant language
Shell
Stars
11.2k
Forks
1.9k
Avg merge
14h 16m
Merged PRs (30d)
6

Description

### Describe the bug

The three repository-scoped customization sources are discovered using two
*different* base directories:

| Source | Discovered at | Base directory |
|-------------------|------------------------------|----------------|
| Custom agents | `/.github/agents/` | **git root** |
| Skills | `/.github/skills/` | **cwd** |
| MCP servers | `/.mcp.json` | **cwd** |

Because agents are bound to the git root while skills and MCP are bound to the
current working directory, it is impossible to keep all three together in a
subdirectory of a repository. In a monorepo (or any repo where you want to keep
Copilot config in a subfolder, e.g. `agent/`), you must either:

- put `.github/agents/` at the git root (so the agent loads) — but then skills
and `.mcp.json` must ALSO be at the git root, forcing you to run from the git
root and scattering config across the tree; or
- copy the agent into the user-level `~/.copilot/agents/` directory, which is
machine-global and not committed to the repo.

There is no cwd from which a subdirectory-local agent + skills + MCP all load
together.

### Affected version

GitHub Copilot CLI 1.0.60-0 (Windows)

### Steps to reproduce the behavior

1. In a git repo, create a subdirectory `sub/` and place all three there:
- `sub/.github/agents/myagent.agent.md`
- `sub/.github/skills/myskill/SKILL.md`
- `sub/.mcp.json`
2. `cd sub` and run `copilot --agent myagent -p "..."`.
- Skills and MCP from `sub/` **do** load (cwd-relative).
- The agent does **not** load: `No such agent: myagent, available:` (empty).
3. Run the same command from the git root — the agent still does not load,
because `/.github/agents/` does not exist.
4. Move `.github/` and `.mcp.json` up to the git root and run from the git root —
now all three load. This is the only working layout, and it forces config to
the git root.

A sharper probe: with an agent at `/.github/agents/A.agent.md` AND a
different agent at `/sub/.github/agents/B.agent.md`, running from
`cwd=/sub` lists only `A` (the git-root one), never `B`. This shows the
loader goes straight to the git root rather than searching upward from cwd the
way skills do.

### Expected behavior

Custom agents should be discoverable using the same base directory as skills and
MCP (cwd, ideally searching upward toward the git root), OR there should be a
configurable `agentDirectories` setting analogous to `skillDirectories`, so that
agents + skills + MCP can be co-located in a subdirectory and loaded together.

### Additional context

- Related: #3505 (asymmetry — skills support multiple directories via
`skillDirectories`, agents do not) and #3572 (agent discovery tied to the
working directory's git remote). This report is specifically about the
**git-root vs cwd base-directory inconsistency** between agents and
skills/MCP, which neither of those covers directly.
- Our repo uses Azure DevOps for source control with config kept under a
`agent/` subfolder, which is what surfaced this.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.