Skip to content

Claude Code Extensibility Cheat Sheet

Agents, commands, hooks, plugins, MCP servers, memory, and configuration.

Six extension points, each solving a different problem.

ComponentWhat It DoesLocationTrigger
AgentAutonomous worker with tools.claude/agents/*.mdAuto or Task tool
SkillLoaded prompt (slash command).claude/commands/*.mdUser types /name
CommandAlias for skill (legacy term).claude/commands/*.mdUser types /name
HookShell script on event.claude/settings.jsonSystem event fires
PluginBundled agents+skills+hooks.claude/plugins/Install + auto
MCPExternal tool server.mcp.jsonTool call

Every component exists at two scopes:

ScopePath prefixShared via gitUse for
Project./.claude/YesRepo-specific conventions
Personal~/.claude/NoCross-project workflows

Skills in ~/.claude/commands/ appear in every project. Skills in ./.claude/commands/ appear only in that repo.

Custom autonomous workers with restricted tool access.

.claude/agents/research-analyst.md
---
name: research-analyst
description: "Deep research combining web sources and repo content"
tools:
- Read
- Glob
- Grep
- WebSearch
- WebFetch
---
You are a research analyst for a reference repository. Search the web and
existing guides, then produce structured findings. Do not create or modify
files.
FieldRequiredPurpose
nameYesDisplay name, used for subagent_type in Task
descriptionYesDrives automatic agent selection — make it precise
toolsNoRestrict available tools (default: all)

Available as subagent_type values in the Task tool:

TypeToolsUse For
general-purposeAllMulti-step implementation
ExploreRead-only (no Edit/Write)Codebase search and analysis
PlanRead-only (no Edit/Write)Architecture design
BashBash onlyCommand execution
test-runnerRead, Glob, BashDetect language and run tests
code-simplifierAllRefine code for clarity

Custom agents in .claude/agents/ appear alongside built-in types.

Claude selects agents by matching the task description against each agent’s description field. Write descriptions that state when to use the agent, not just what it does.

# Weak — doesn't say when to trigger
description: "Analyzes code"
# Strong — states the trigger condition
description: "Deep research combining web sources and existing repo content. Use when investigating a topic before writing new guides."

Prompt templates invoked via /name from the CLI.

.claude/commands/deep-research.md
---
description: Thorough parallel research with session persistence
allowed-tools: [Task, Read, Glob, Grep, Write, WebSearch, WebFetch, Bash]
---
Research a topic using parallel agents with session management.
## Input
The user's message contains the topic to investigate.
## Step 1: Decompose
Identify 3-7 independent research stages...
FieldRequiredPurpose
descriptionYesShown in / autocomplete menu
allowed-toolsNoRestrict which tools the skill can use

Skills receive the user’s message after the /command as $ARGUMENTS:

User types: /deep-research agent memory systems
Skill sees: "agent memory systems" as the input

Reference files with @path/to/file in the prompt body — Claude resolves these at invocation time.

Choose…When…
SkillUser triggers it explicitly with /name
AgentClaude should auto-select based on task context
BothWrap an agent invocation inside a skill template

Shell commands that fire on system events.

{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"command": "~/scripts/validate-bash.sh"
}
],
"PostToolUse": [
{
"matcher": "Write",
"command": "prettier --write $CLAUDE_FILE_PATH"
}
],
"PreCompact": [
{
"matcher": "",
"command": "~/scripts/save-context.sh"
}
]
}
}
EventFires WhenCommon Use
PreToolUseBefore a tool executesBlock dangerous commands
PostToolUseAfter a tool executesAuto-format, lint, log
StopAgent completes its turnNotification, cleanup
SubagentStopSubagent completesCollect results
PreCompactBefore context compressionSave state before memory loss
SessionStartNew session beginsLoad context, set env
SessionEndSession closesPersist state
UserPromptSubmitUser sends a messageInject context, validate input
NotificationSystem notification firesExternal alerts

Hooks communicate back via stdout JSON:

{
"decision": "block",
"reason": "Command contains rm -rf"
}
DecisionEffect
allowProceed (default if no output)
blockPrevent the tool call
(any text)Injected as context for Claude
VariableAvailable InContains
$CLAUDE_FILE_PATHWrite, Edit hooksPath of the file modified
$CLAUDE_TOOL_INPUTPreToolUseJSON of tool parameters
$CLAUDE_TOOL_OUTPUTPostToolUseJSON of tool result
$CLAUDE_SESSION_IDAllCurrent session identifier

Bundled packages of agents, skills, hooks, and MCP servers.

my-plugin/
├── plugin.json # Manifest
├── agents/
│ └── reviewer.md
├── commands/
│ └── review.md
├── skills/
│ └── analyze.md
└── hooks/
└── pre-commit.sh
{
"name": "my-plugin",
"version": "1.0.0",
"description": "Code review automation",
"components": {
"agents": ["agents/reviewer.md"],
"commands": ["commands/review.md"],
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/pre-commit.sh"
}
]
}
}
}

Use ${CLAUDE_PLUGIN_ROOT} for paths relative to the plugin directory.

Terminal window
# From local path
claude plugin add ./my-plugin
# From npm
claude plugin add @scope/my-plugin
# From marketplace template
claude plugin add claude-code-templates/review-plugin

External tool providers via Model Context Protocol.

{
"mcpServers": {
"linear": {
"type": "sse",
"url": "https://mcp.linear.app/sse",
"env": { "LINEAR_API_KEY": "..." }
},
"filesystem": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"]
}
}
}
FileScopeGitUse For
.mcp.jsonProjectYesTeam-shared MCP servers
~/.claude/.mcp.jsonPersonalNoPersonal tool servers
TypeTransportUse For
stdiostdin/outLocal CLI tools (filesystem, git)
sseHTTP SSERemote APIs (Linear, Notion, Slack)

Higher entries override lower:

1. Managed policy (organization-enforced)
2. CLI arguments (--flag for this session)
3. Local settings (.claude/settings.local.json)
4. Project settings (.claude/settings.json)
5. User settings (~/.claude/settings.json)
ModeBehavior
defaultAsk for each tool use
acceptEditsAuto-allow file edits, ask for Bash
planRequire plan approval before implementation
delegateTeam lead approves teammate plans
dontAskAuto-allow everything
bypassPermissionsSkip all permission checks
{
"permissions": {
"allow": ["Bash(npm test)", "Bash(make *)", "Edit", "Write"],
"deny": ["Bash(rm -rf *)", "Bash(git push --force*)"]
}
}

Patterns support glob syntax. deny takes precedence over allow.

~/.claude/CLAUDE.md # Personal defaults (all projects)
./CLAUDE.md # Project root (committed)
./CLAUDE.local.md # Project personal (gitignored)
./src/CLAUDE.md # Subdirectory (loaded on demand)
./src/auth/CLAUDE.md # Deeper nesting works too

Subdirectory CLAUDE.md files load only when Claude reads files in that directory. Use them for module-specific conventions.

Claude maintains a persistent memory directory per project:

~/.claude/projects/{project-path-slug}/memory/MEMORY.md
  • First 200 lines of MEMORY.md load into every system prompt
  • Create topic files (patterns.md, debugging.md) for detailed notes
  • Link topic files from MEMORY.md to keep the index concise

Scoped instructions with path-based targeting:

.claude/rules/tests.md
---
path: "**/*.test.ts"
---
Use vitest. Mock external services. Assert both success and failure cases.

Rules activate only when Claude works on files matching the path glob.

Reference files inline in CLAUDE.md:

## Architecture
@src/ARCHITECTURE.md
## API Conventions
@docs/api-style-guide.md

Referenced files load their content into Claude’s context at session start.

Default context: 200K tokens. Extended context aliases provide 1M tokens:

Terminal window
# Use extended context model
claude --model claude-sonnet-4-5-20250929

When context fills, Claude compresses earlier messages. Control this with:

  • PreCompact hook — save state before compression happens
  • Structured handoff — write summaries to files before compaction
  • Keep CLAUDE.md lean — it reloads after every compaction
StrategyHow
SubagentsOffload research to Task agents (separate window)
Progressive disclosureStart with summaries, drill into files on demand
File-based stateWrite findings to disk, read back when needed
Lean context filesKeep CLAUDE.md under 300 lines

Control reasoning depth without switching models:

Terminal window
# Quick completion (less thinking)
claude --effort low
# Default balance
claude --effort medium
# Deep reasoning
claude --effort high

Match model to task complexity when spawning subagents:

Task ComplexityModelUse For
Data gatheringhaikuFile enumeration, listings, simple lookup
Standard analysissonnetCode analysis, documentation, patterns
Complex reasoningopusArchitecture, cross-cutting concerns
<!-- In Task tool call -->
model: "haiku" subagent_type: "general-purpose" prompt: "List all files matching
\*.test.ts and count assertions per file"

Coordinate multiple agents working on shared tasks.

1. TeamCreate → creates team + shared task list
2. TaskCreate (×N) → populate work items
3. Task (×N) → spawn teammates with team_name
4. TaskUpdate → assign work via owner field
5. SendMessage → coordinate between teammates
6. TaskUpdate → mark tasks completed
7. shutdown_request → gracefully stop teammates
8. TeamDelete → clean up team files
Team lead creates tasks → assigns owner → teammate claims and works →
marks complete → checks TaskList for next item

Teammates prefer tasks in ID order (lowest first). Tasks support blockedBy dependencies to enforce ordering.

MethodUse For
SendMessageDirect message to one teammate
broadcastCritical announcements (use sparingly)
TaskListCheck shared progress
TaskUpdateSignal completion or blockers

Messages deliver automatically — no polling needed. Teammates go idle between turns; sending a message wakes them.

I want to…Use
Add a custom worker.claude/agents/name.md
Create a slash command.claude/commands/name.md
Auto-format on file writePostToolUse hook
Block dangerous commandsPreToolUse hook with "decision": "block"
Add external tools.mcp.json with server config
Share project conventions./CLAUDE.md (committed)
Keep personal preferences~/.claude/CLAUDE.md
Persist learningsAuto memory MEMORY.md
Scope rules to file types.claude/rules/name.md with path glob
Run parallel researchTask tool with multiple agents
Coordinate a teamTeamCreate + TaskCreate + Task