# Extension gating

```
// agent.json
{
  "tools":  {"mode": "automatic", "disabled": ["bash", "*_dangerous"]},
  "skills": {"disabled": ["devops/*"], "allowed": [], "categories": ["research", "writing"]},
  "mcp":    {"disabled": ["slack"], "allowed": [], "required": ["drawio*"]}
}
```

## Fields

| Field | `tools` | `skills` | `mcp` | Effect |
| --- | --- | --- | --- | --- |
| `disabled` | Yes | Yes | Yes | Matching names are rejected |
| `allowed` | Yes | Yes | Yes | When non-empty, only matches pass |
| `categories` | No | Yes | No | When non-empty, a skill that declares a category must match |
| `required` | No | No | Yes | Any pattern matching no remaining server stops the turn |
| `mode` | Yes | No | No | `automatic` (default), `selected`, `none` |

Patterns use `fnmatch.fnmatchcase`: `*`, `?`, `[abc]`; an exact name is the trivial case. `mcp` patterns match the server name, the part of `<server>__<tool>` before `__`. With `mode: selected`, `tools.allowed` holds exact names. Plugins are not gated: a plugin is a host-level contributor, and gating applies to the skills, tools and MCP it contributes.

### Resolution order

1. `disabled`: a match rejects.
2. `allowed`, if non-empty: no match rejects.
3. `categories`: a non-empty list rejects a categorized skill outside it.
4. `required`, MCP only, checked after filtering: an unmatched pattern fails the whole turn.

## Why this shape

Claude Code's per-type fields with opencode's wildcard expressiveness. Each field says what it gates; one pattern replaces five names; a new extension type is a new block of the same shape. Comparison: [Reference comparison](https://fzkuji.github.io/OpenProgram/docs/reference/design/extension-gating/reference-comparison.html).

## Examples

| Agent | Profile | Model sees |
| --- | --- | --- |
| Customer service | `tools: {disabled: [write, edit, execute_*, apply_patch]} skills: {categories: [customer-service, writing]} mcp: {disabled: ["*"]}` | No edit tools, only those skill categories, no MCP |
| DevOps | `skills: {disabled: [prod-deploy, drop-database]} mcp: {required: ["github*", "k8s*"]}` | Everything but two skills. Without GitHub and k8s MCP the turn fails before the provider runs |
| Research | `tools: {allowed: [read, grep, glob, web_fetch], web_search: true} skills: {categories: [research]} mcp: {allowed: ["arxiv*", "scholar*"]}` | Those tools plus web search, research skills, those MCP servers |

`web_search` is outside the default tool list, so `allowed` alone does not add it.

## When not to use gating

Default: install skills globally, configure no gates, let the model choose from each skill's `description`. Add a gate after observing specific bad behaviour, when:

- a skill needs a hard wall (`prod-deploy` never in customer service);
- the permitted set is shorter to list than to tune descriptions for;
- an agent makes no sense without a given MCP server.

[Implementation map](https://fzkuji.github.io/OpenProgram/docs/reference/design/extension-gating/implementation.html) · [Not built](https://fzkuji.github.io/OpenProgram/docs/reference/design/extension-gating/future-work.html) · [Calling unification](https://fzkuji.github.io/OpenProgram/docs/reference/design/function/calling-unification.html) (six-layer gating for function calling) · [Skills and plugins](https://fzkuji.github.io/OpenProgram/docs/reference/design/integrations/extensions/skills-and-plugins.html) (catalogues, discovery, hot reload)
