Skills (SKILL.md) vs. MCP vs. Subagents vs. Hooks: The 4 AI Agent Primitives Explained
Why connecting 5 MCP servers burns 58,000 tokens before you type a word—and how Skills, MCP, Subagents, and Hooks divide the work in a modern AI coding agent.
Modern AI coding agents like Claude Code give you a 200,000-token context window. Yet developers routinely burn 58,000+ tokens on startup before typing a single prompt—because they use MCP for everything instead of separating Skills (SKILL.md), MCP, Subagents, and Hooks.
📥 Download the 1-Page Printable Cheat Sheet:
1. The 4-Primitive Comparison Matrix
| Primitive | Config File | Startup Context Cost | Who Triggers It? | What It Actually Does |
|---|---|---|---|---|
| 1. MCP | .mcp.json | High (~10K–58K tok) — dumps every JSON tool schema at boot | The Model (tools/call) | Live external API & DB execution (GitHub, Postgres, Sentry, Slack) |
| 2. Skills | .claude/skills/<name>/SKILL.md | Tiny (~100 tok/skill) — only YAML name + description loaded at boot | The Model (reads body on-demand) | Reusable playbooks, conventions, and multi-step SOPs via Progressive Disclosure |
| 3. Subagents | .claude/agents/<name>.md | 0 tokens in parent window until spawned | Parent Agent (Task delegation) | Spawns an isolated 200K context worker to scan 50+ files and return a 500-token summary |
| 4. Hooks | .claude/settings.json | 0 tokens (runs outside LLM in OS shell) | Lifecycle Events (PreToolUse, PostToolUse) | Deterministic exit 0 / exit 2 security firewalls (rm -rf blocker) & auto-formatters (prettier) |
2. Copy-Paste Templates for All 4 Primitives
Primitive #1: Skills (SKILL.md — Progressive Disclosure)
At startup, the agent only loads the 2-line YAML frontmatter (~40 tokens). The full markdown playbook (4,000+ tokens) stays on disk until your task actually matches description:
---
name: prisma-zero-downtime-migration
description: Use when modifying schema.prisma or creating production PostgreSQL migrations.
---
# Zero-Downtime Prisma Migration Playbook
1. Never rename or drop a column in a single migration step.
2. Always use the Expand -> Backfill -> Contract pattern.
3. Run `npx prisma migrate diff` and verify no `DROP COLUMN` or `ALTER COLUMN TYPE` locks the table.
Primitive #2: MCP (.mcp.json — Live External Pipe)
Keep .mcp.json lean—only attach servers that require live network or database I/O:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"]
},
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost:5432/app"]
}
}
}
Primitive #3: Subagents (.claude/agents/security-reviewer.md)
When an agent reads 40 files in your main session, those raw file contents stay in your context forever. Delegating to a Subagent runs the search in a separate 200K sandbox and returns only the distilled report:
---
name: security-reviewer
description: Delegate PR diff security audits and secret scanning to this isolated worker.
tools: Read, Grep, Glob
---
You are an isolated Principal Security Auditor.
Scan the modified files for SQL injection, IDOR, missing auth middleware, and hardcoded secrets.
Return a concise markdown table of findings (max 400 tokens) to the parent agent.
Primitive #4: Hooks (.claude/settings.json — 0-Token Guardrails)
Never beg an LLM in a prompt to “please remember to run Prettier” or “please never drop production tables.” Hooks run deterministic shell scripts outside the model:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.command' | grep -qE '(DROP TABLE|rm -rf /)' && exit 2 || exit 0"
}
]
}
],
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "npx prettier --write \"$CLAUDE_FILE_PATHS\""
}
]
}
]
}
}
exit 0: Tool call proceeds normally.exit 2: Deterministic hard block—stderr is fed back to the agent so it corrects course immediately.
Test Your Understanding
Quick architectural scenario challenge based on this breakdown.
A 3rd-party payment gateway starts timing out with 504 errors during peak traffic.
Q1.How should a downstream dependency failure be handled to protect upstream service availability?
Comments –
Sign in to share your thoughts
Nothing yet. Be the first.