skip to content

In a Claude Code subagent definition, what do the `skills`, `mcpServers` and `memory` fields load, and what does each one not restrict?

level: middleimportance: nice to knowfreq 5%

answer

  1. preload, not permission
  2. full skill content at startup
  3. inline servers live and die with it
  4. three memory scopes
  5. memory adds write tools

basics

~20 s

skills injects listed skills' full content at startup, mcpServers gives the subagent servers of its own, and memory adds a persistent directory. None limits access: unlisted skills stay invocable, and memory switches on Read, Write and Edit.

solid answer

~40 s

`skills` preloads the full content of each listed skill into the subagent's context at startup, not just its description; it does not restrict skills, since the subagent can still invoke unlisted ones through the Skill tool unless `Skill` is removed from its tools. `mcpServers` takes either names of servers already configured, which share the parent's connection, or inline definitions that connect when the subagent starts and disconnect when it finishes, keeping their tool descriptions out of the main conversation. `memory` (`user`, `project` or `local`) gives the subagent its own persistent directory, puts the start of its `MEMORY.md` in the system prompt, and automatically enables Read, Write and Edit. It does nothing when auto memory is turned off.

code

yaml · 12 lines
yaml
---
name: migration-writer
description: Writes reversible database migrations. Use when a schema change is requested.
skills:
  - db-migration-conventions
mcpServers:
  - schema-inspector:
      type: stdio
      command: npx
      args: ["-y", "schema-inspector-mcp"]
memory: project
---

go deeper

for a junior

Recall that skills preloads skill content, mcpServers gives the subagent its own servers, and memory gives it a directory that survives sessions.

for a middle

Explain reference versus inline MCP entries, the three memory scopes and their directories, and why skills is not an allowlist.

for a senior

Catch the side effects: memory turning on write tools in a read-only agent, inline servers blocked by folder trust or policy, and plugin agents dropping mcpServers.

for a principal

Decide what knowledge and reach each team agent carries, keeping heavy servers out of the main context and memory shared only where review is acceptable.

## Three fields that add, not subtract Most subagent frontmatter narrows what a subagent can do. These three **add** something to its starting context or its reach, and each has a limit people misread as a restriction. | Field | Adds | Does not | |---|---|---| | `skills` | Full content of named skills, injected at startup | Restrict which skills the subagent may invoke | | `mcpServers` | MCP servers for this subagent, by reference or inline | Expose inline servers to the main conversation | | `memory` | A persistent directory and its `MEMORY.md` in the prompt | Share the main session's auto memory, or keep the agent read-only | ## `skills`: preloading knowledge A **skill** is a reusable instruction package (a `SKILL.md` and supporting files). Normally Claude sees only skill descriptions and loads a skill's body when it decides to use it. Listing skills in a subagent's `skills` field changes that for the subagent: - The **full content** of each listed skill is injected into the subagent's context when it starts, so a `migration-writer` can begin with the team's migration conventions already in hand. - It is a **preload list, not an allowlist**. Without the field, or alongside it, the subagent can still discover and invoke project, user and plugin skills through the `Skill` tool. To stop it invoking skills at all, omit `Skill` from `tools` or add it to `disallowedTools`. - You cannot preload a skill that sets `disable-model-invocation: true`, because preloading draws from the skills Claude may invoke. - A missing or policy-disabled skill is skipped with a warning in the debug log, not an error. This is the inverse of a skill that runs itself in a subagent with `context: fork`: there the skill supplies the task and an agent type supplies the prompt. Skill frontmatter belongs to the skill-authoring material. ## `mcpServers`: servers scoped to one agent Each entry is one of two things: 1. **A name** of a server already configured in the session, such as `github`. The subagent shares the parent session's connection. 2. **An inline definition**, keyed by server name, with the same schema as an `.mcp.json` entry (types `stdio`, `http`, `sse`, `ws`). It **connects when the subagent starts and disconnects when it finishes**. Inline servers are the way to keep a heavy server out of the main conversation entirely: the subagent gets its tools, and the parent never pays for their descriptions in context. Limits that still apply: - An inline server in a **project** agent file loads only after you trust the folder the file came from; user-level files, `--agents` definitions and managed definitions skip that check. - Organisation MCP policies, `--strict-mcp-config` and `--bare` filter these servers too. - **Plugin** subagents ignore `mcpServers` entirely. How to configure a server itself is the MCP-setup material. ## `memory`: knowledge that survives sessions `memory` gives the subagent a directory it reads and writes across conversations, such as recurring review findings or codebase patterns. | Scope | Directory | Use when | |---|---|---| | `user` | `~/.claude/agent-memory/<name>/` | Learnings apply across all projects | | `project` | `.claude/agent-memory/<name>/` | Project-specific and shared through version control (the recommended default) | | `local` | `.claude/agent-memory-local/<name>/` | Project-specific but kept out of version control | When it is on, the subagent's system prompt gains instructions for maintaining the directory plus the first 200 lines or 25KB of its `MEMORY.md`, whichever comes first. **Read, Write and Edit are enabled automatically** so it can manage those files. Two consequences: - A reviewer you scoped to `tools: Read, Grep, Glob` regains file-writing tools once you add `memory`. Decide whether that trade is acceptable. - Subagent memory is part of **auto memory**: turn auto memory off and the field has no effect. It is also separate from the main conversation's auto memory, which never reaches a non-fork subagent. ## Related field in one line `isolation: worktree` runs the subagent in a temporary git worktree; how worktree sessions work belongs to the parallel-work material. ## Reading the three together Use `skills` to **front-load knowledge**, `mcpServers` to **give one agent a tool the session should not carry**, and `memory` to **let an agent learn**. Use `tools` and `disallowedTools`, not these, to decide what it may not do.

  • How do you stop a subagent from invoking any skill, not just preload some?
    Remove the `Skill` tool: omit it from the `tools` allowlist or add it to `disallowedTools`. The `skills` field only decides which skills are preloaded at startup; it never limits which ones the subagent can invoke.
  • Why might an inline MCP server in a project subagent never connect?
    Claude Code loads inline servers from a project's `.claude/agents/` only after you trust the folder the file came from; a parent folder's trust does not count. It can also be blocked by organisation MCP policies, `--strict-mcp-config` or `--bare`, and plugin subagents ignore `mcpServers` altogether.

  • The skills field limits the subagent to invoking only the listed skills.
  • Preloading a skill injects only its description, as in the main session.
  • An inline mcpServers entry also exposes that server's tools to the main conversation.
  • memory: project gives the subagent the main session's auto memory.
  • Adding memory to a read-only reviewer leaves its tool list unchanged.