Claude Hooks and Plugins: Extending Claude Code (2026 Guide)

What it is: A practical guide to Claude Code’s two main extensibility systems — hooks (event-triggered shell commands that run at specific points in the Claude Code lifecycle) and plugins (packaged collections of commands, agents, hooks, skills, and MCP servers that you can install and share). Together they turn Claude Code from a chat-with-a-coder tool into a fully customizable development environment.
Who it is for: Software engineers and AI-curious developers using Claude Code who want to customize behavior, automate guardrails, share team conventions, or build reusable workflows.
Best if: You’ve used Claude Code for a few weeks and now want to push past the defaults — build team-wide policies, enforce coding standards automatically, or package your favorite workflows into shareable plugins.
Skip if: You’re brand new to Claude Code — learn the basics first (see How to Use Claude AI). Daily AI fundamentals in our free Beginners in AI newsletter.

Claude Code is Anthropic’s command-line interface for software engineering with Claude. By default it’s already useful — you can have it read your code, write features, run tests, and commit changes. But the real leverage shows up when you start customizing what happens at specific points in its lifecycle.

That customization happens through two main mechanisms: hooks and plugins. Hooks let you run a shell command in response to a Claude Code event. Plugins let you package commands, agents, hooks, skills, and MCP servers into installable bundles that the whole team can use. Together they’re what turns Claude Code from a useful tool into a fully customizable development environment.

What are Claude Code hooks?

A hook is a shell command that Claude Code runs automatically when a specific event happens. You define hooks in your Claude Code configuration; Claude Code then invokes them at the right moments without you having to remember.

The major hook events:

HookWhen it firesWhat it’s good for
PreToolUseBefore Claude calls any tool (Bash, Edit, Write, Read, etc.)Validation, security gates, blocking destructive operations
PostToolUseAfter a tool call completesLogging, auto-formatting, running tests, sending notifications
UserPromptSubmitWhen you submit a promptPre-processing your input, injecting context, applying rules
StopWhen Claude finishes a turnCleanup, summary generation, status updates
NotificationWhen Claude needs your attentionCustom notifications (Slack, desktop, audio)
SessionStart / SessionEndAt session boundariesLoading context, archiving logs, repository setup

How do you configure a hook?

Hooks live in your Claude Code configuration (usually ~/.claude/settings.json for user-level hooks, or .claude/settings.json in a project root for project-level hooks). The basic shape:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "echo 'About to run a bash command'"
          }
        ]
      }
    ]
  }
}

The matcher filters which tool calls trigger the hook. The command is what runs. The hook gets information about the event through stdin and environment variables, and it can return JSON to influence what Claude Code does next.

What are some useful hook patterns?

  • Auto-format on save. A PostToolUse hook on the Edit and Write tools that runs prettier, black, gofmt, or your formatter of choice on the file Claude just touched. Code stays formatted without you thinking about it.
  • Run tests after writes. A PostToolUse hook that runs your test suite on any file Claude edits. Catches regressions immediately.
  • Block destructive commands. A PreToolUse hook on Bash that pattern-matches dangerous commands (rm -rf, git push --force, git reset --hard) and either prompts for confirmation or blocks them outright.
  • Inject context. A UserPromptSubmit hook that reads project-specific context (style guide, architectural decisions) and prepends them to your prompt so Claude has the team conventions every time.
  • Audit log. A PostToolUse hook that writes every tool call to a structured log file for compliance or debugging.
  • Custom notifications. A Notification hook that pings Slack or sends a desktop notification when Claude needs your input.
  • Pre-commit guardrails. A PreToolUse hook on Bash matched to git commit commands that runs linting and tests first.

The pattern that pays off the most: write a hook the first time you catch yourself running the same command manually after Claude finishes something. The hook eliminates the repetition forever.

What are Claude Code plugins?

A plugin is a packaged collection of Claude Code customizations that can be installed and shared. Inside a single plugin you can include:

  • Slash commands — custom /something commands that wrap common workflows.
  • Agents — specialized assistants with their own instructions, tool sets, and lifecycle (e.g. a code-reviewer agent, a test-writer agent, a docs-generator agent).
  • Hooks — the event-triggered shell commands described above, bundled in.
  • Skills — Anthropic’s reusable instruction packages that Claude loads automatically when the matching trigger appears.
  • MCP servers — Model Context Protocol servers that give Claude access to external tools and data.

The whole bundle lives in a single directory with a plugin.json manifest. Someone can install your plugin and instantly get all of its commands, agents, hooks, and configurations active in their Claude Code.

What does a plugin structure look like?

my-plugin/
├── plugin.json          # Manifest with name, version, dependencies
├── commands/            # Slash commands
│   ├── review-pr.md
│   └── refactor.md
├── agents/              # Specialized agents
│   └── code-reviewer.md
├── hooks/                # Event hooks
│   ├── auto-format.sh
│   └── test-after-write.sh
├── skills/               # Anthropic Skills
│   └── project-conventions/
│       └── SKILL.md
└── mcp-servers/          # MCP server configs
    └── jira-server.json

You don’t need to use every category — many plugins are just a few slash commands. Others include only agents. The point is that whatever combination is useful, you bundle once and distribute as a unit.

How do you install a plugin?

Claude Code supports installing plugins from several sources:

  • From a marketplace. Anthropic maintains an official plugin marketplace; community marketplaces exist as well. Run /plugin marketplace add <url> to subscribe, then browse and install with /plugin install.
  • From a git repository. Install directly from a GitHub URL or other git remote.
  • From a local directory. During development, point Claude Code at your local plugin folder.

Once installed, plugins become active in any Claude Code session. You can manage them with the /plugin family of commands — list, enable, disable, update, uninstall.

What are common plugin use cases?

  • Team coding conventions. Bundle the team’s style guide, linting rules, commit-message format, and PR description template into one plugin. New team members install one thing and get all the standards.
  • Vault / knowledge-base assistants. A plugin that wraps your team’s internal docs, runbooks, and post-mortems — with hooks to inject relevant context based on the prompt.
  • Project bootstrapping. A plugin that includes commands for creating a new service, scaffolding tests, generating CI configuration, and deploying to your environment.
  • Code-review automation. A plugin with a code-reviewer agent, hooks that run on git operations, and slash commands that pull PR context and run targeted reviews.
  • Personal productivity bundles. A plugin with your favorite slash commands, hooks, and skills assembled over time.
  • Custom MCP integrations. Bundle MCP server configurations for your team’s internal tools (JIRA, Linear, internal databases) so installing one plugin gives the whole team access.

What is the difference between a hook and a plugin?

A hook is a single piece of behavior — one event, one command. A plugin is a package that can contain many hooks (plus commands, agents, skills, MCP servers).

Practically: if you have one piece of automation you want for yourself, write a hook directly in your settings.json. If you want to share several pieces of automation with your team, package them into a plugin.

How do hooks interact with safety and security?

  • Hooks run as your local user. Whatever permissions you have, the hook has. Be cautious about installing plugins from untrusted sources.
  • PreToolUse hooks can block tool calls. This is the recommended way to add safety guardrails — matchers for rm -rf, force-push, sensitive-file edits, etc.
  • Hooks see prompts and tool calls. Don’t pipe Claude Code data through hooks that send it to untrusted external services.
  • Audit before installing. Read the hooks in a plugin before installing it. Most plugins keep hook scripts in plain shell or Python — readable in minutes.

FAQ

Do I need to write hooks in a specific language?

No. A hook is just a shell command. Use bash, Python, Node.js, Go, or anything else that can run from the command line. Most simple hooks are 1–5 lines of bash.

Can I temporarily disable hooks?

Yes. Run Claude Code with --no-hooks for a one-off session, or edit your settings to disable specific hook entries.

What’s the difference between a plugin and a Claude Skill?

Skills are Anthropic’s reusable-instruction format that Claude loads automatically when triggered. Skills are about instructions: how Claude should behave on a particular task. Plugins are broader: they can include Skills, but also commands, agents, hooks, and MCP servers. Think of Skills as a building block; plugins are the box that holds them.

Where do I find existing plugins?

The Anthropic plugin marketplace is the canonical source. Browse with /plugin marketplace in Claude Code. Community plugins are typically published on GitHub; the /plugin install <git-url> command pulls directly from a repo.

Can I publish my own plugin?

Yes. Put your plugin directory in a public git repo with a proper plugin.json manifest. To submit to the official marketplace, follow Anthropic’s plugin submission process documented in the Claude Code docs.

Do hooks slow down Claude Code?

Slightly. Each hook adds whatever its command takes to run. Keep hooks fast for events that fire frequently (PreToolUse, PostToolUse). For slow operations (running a full test suite), consider running asynchronously or only on specific matchers.

Can a hook stop Claude Code from doing something?

Yes. A PreToolUse hook can return a JSON response that blocks the tool call. This is how you implement safety guardrails — pattern-match dangerous commands and return a block decision.

The bottom line

Hooks and plugins are how you turn Claude Code from a useful CLI into a customized development environment. Hooks add event-triggered behavior (auto-format, run tests, block destructive commands, inject context). Plugins package collections of hooks, slash commands, agents, skills, and MCP server configurations into shareable bundles.

The realistic adoption path: start by writing one or two hooks for your most-repeated post-Claude actions (auto-format, run tests). Subscribe to the Anthropic plugin marketplace and try a few community plugins. When you have three or four useful customizations of your own, package them into a plugin and share with your team.

For broader context: What Is Claude Code?, How to Use Claude AI: The Complete Beginner’s Guide, Claude Skills Explained, Claude Opus 4.7 Explained. Daily AI fundamentals in our free Beginners in AI newsletter.

Learn Our Proven AI Frameworks

Beginners in AI created 6 branded frameworks to help you master AI: STACK for prompting, BUILD for business, ADAPT for learning, THINK for decisions, CRAFT for content, and CRON for automation.

Get Smarter About AI Every Morning

Free daily newsletter — one story, one tool, one tip. Plain English, no jargon.

Free forever. Unsubscribe anytime.

Sources

You May Also Like

Two ways to go further

The AI Prompt Library

1,000+ ready-to-use prompts for Claude, ChatGPT, and Gemini. Stop staring at a blank box.

Get it for $39 →

2-Hour Live AI Crash Course

A private, beginner-friendly session across Claude, ChatGPT, Gemini, and the wider landscape.

Book for $125 →

Discover more from Beginners in AI

Subscribe now to keep reading and get access to the full archive.

Continue reading