9 cards
Choosing an extension mechanism
Must happen 100% of the time → hook or permission; should happen → CLAUDE.md or skill; connect external data → MCP; context-heavy work → subagent.
Hook `PreToolUse`
Runs before a tool call and can block it; exit 2 blocks and sends stderr to Claude; exit 0 does not mean auto-approve.
Hook `PostToolUse` with matcher `Edit|Write`
Typical pattern to auto-format the file just edited (read `tool_input.file_path` from JSON stdin).
What a hook is, security-wise
A shell command running with your permissions; hooks in an unfamiliar repo only run after trust, but `claude -p` has no trust dialog.
Skill
A directory with `SKILL.md` in `.claude/skills/<name>/` or `~/.claude/skills/<name>/`; invoked with `/name` or auto-loaded by Claude based on `description`.
`disable-model-invocation: true`
The skill only runs when the user types `/name`; use for workflows with side effects like deploy, release, commit.
Adding an HTTP MCP server
`claude mcp add --transport http <name> <url>`; stdio: `claude mcp add [options] <name> -- <command>`.
MCP scopes
`local` (default, `~/.claude.json`), `project` (`.mcp.json` in the repo, shared via git), `user` (all your projects).
MCP server risks
Third-party code or services access your data; servers fetching external content can bring prompt injection; many servers consume context.