User Agents

Web browsers and everyday web tech, explained

Claude Code Extensions: Hooks, Skills, or Subagents?

· 6 min read · Extensions

In this article
  1. What Each Extension Actually Does
  2. Hooks: Automate the Workflow Around Claude
  3. Skills: Package Knowledge and Procedures
  4. Subagents: Delegate Focused Tasks
  5. How to Choose: A Decision Guide
  6. Common Problems and Misconceptions
  7. Costs and Performance Considerations
  8. Safety and Best Practices
  9. Frequently Asked Questions

You should use hooks for automatic, event-driven actions, skills for reusable knowledge and workflows, and subagents for specialized, parallelizable tasks. The choice depends on what you want Claude to do: hooks react to events, skills package expertise, and subagents act as focused collaborators. Most real projects use a combination of all three.

What Each Extension Actually Does

Claude Code supports three main extension mechanisms, each with a distinct role in how they modify or enhance Claude's behavior.

  • Hooks are shell commands or scripts that run automatically at specific points in Claude's lifecycle—like before or after a tool call, or when a session starts. They let you enforce rules, run linters, or inject context without manual prompting.
  • Skills are folders containing a SKILL.md file (with instructions) and optional resources. They give Claude a packaged set of knowledge or a step-by-step procedure it can load on demand, like a style guide or a deployment checklist.
  • Subagents are separate Claude instances with their own system prompt, tools, and model settings. You can delegate a task to a subagent and get a focused result, often in parallel with other work.

Hooks: Automate the Workflow Around Claude

Hooks are best for things that should happen every time without asking. For example, you can set a PreToolUse hook that runs a code formatter before Claude edits a file, or a Stop hook that runs tests after each response. This makes them ideal for guardrails and quality checks.

Common hook use cases:

  • Running a linter or type checker after every file edit.
  • Blocking edits to sensitive files (like .env) via a PreToolUse hook that exits with an error.
  • Injecting a custom system prompt or context at session start.
  • Logging all tool calls for audit trails.

Hooks are not for giving Claude new knowledge—they are for enforcing behavior. They are also the most “automatic” of the three, as they trigger without user prompting.

Skills: Package Knowledge and Procedures

Skills are like a reference manual Claude can consult. When you mention a skill name (or Claude detects it from context), it reads the SKILL.md file and follows the instructions. This is useful for repetitive, well-defined tasks that require specific steps or domain knowledge.

For example, you could create a skill called “deploy-to-aws” that contains a step-by-step guide for deploying a service, including the exact CLI commands and environment variables. Claude would then follow that procedure when asked to deploy.

Skills shine when:

  • You have a documented workflow that changes rarely.
  • You want to share best practices across a team.
  • You need to inject a large amount of context (like a coding standard) without cluttering the main prompt.

Unlike hooks, skills are on-demand—Claude only loads them when relevant.

Subagents: Delegate Focused Tasks

Subagents are separate AI workers with their own instructions and tools. You can spawn a subagent to handle a specific subtask—like “review this pull request for security issues” or “write unit tests for this module”—and get back a result. Subagents can run in parallel, so you can split a large task into smaller pieces and speed up the overall process.

Key characteristics of subagents:

  • They have their own system prompt, so you can give them specialized expertise (e.g., “You are a security expert”).
  • They can have different tools—a subagent might only have read-only access, while another can edit files.
  • They return a result to the main Claude instance, which can then integrate it.

Subagents are ideal for tasks that are isolated and can be done independently, like analyzing a specific file or researching a topic. They are not meant for ongoing background automation—they are one-shot collaborators.

How to Choose: A Decision Guide

To decide which extension to use, ask yourself what problem you are solving.

  1. Is the action triggered by an event? (e.g., “after every edit”) → Use a hook.
  2. Is it a repeatable procedure or domain knowledge? (e.g., “how to run our test suite”) → Use a skill.
  3. Is it a focused, self-contained task that can be delegated? (e.g., “review this code for bugs”) → Use a subagent.

Often you will combine them. For instance, a hook could trigger a subagent to run a security scan on every commit, and a skill could provide the subagent with the scanning guidelines.

Common Problems and Misconceptions

One common misconception is that skills and subagents are interchangeable. They are not: skills are passive knowledge, while subagents are active workers. Another mistake is using hooks for tasks that require Claude's judgment—hooks are just shell commands, so they cannot reason.

Another issue is overusing subagents for trivial tasks, which adds overhead and slows down the main conversation. Similarly, poorly written skills can confuse Claude if instructions are ambiguous. Keep skills focused and test them.

Also note that hooks can be dangerous if they modify files in unexpected ways—always test them in a sandbox first. And subagents consume additional tokens, so use them judiciously for complex tasks only.

Costs and Performance Considerations

All three extensions have different cost implications. Hooks are essentially free—they run local shell commands, though they may invoke external tools that cost money. Skills add negligible cost because they only load text into the context window. Subagents, however, consume tokens for each subagent call, so using many subagents can increase your API bill significantly.

Performance-wise, hooks add minimal latency (they are just commands). Skills add a slight delay when loading the skill file. Subagents add the most latency because they are separate model calls, but they can run in parallel, so the wall-clock time may be similar to doing the task sequentially.

Safety and Best Practices

When using hooks, be extremely careful with the commands you run—they execute with your user permissions. Never use a hook to execute untrusted code without review. For skills, avoid giving instructions that could lead to destructive actions; always include checks. For subagents, limit their tools to only what is necessary, and consider using read-only subagents for review tasks.

Also, remember that Claude Code extensions are still evolving. Always refer to the official documentation for the latest syntax and capabilities. Test extensions in a safe environment before using them on critical projects.

Frequently Asked Questions

Can I use hooks, skills, and subagents together?

Yes, they are designed to complement each other. For example, a hook could trigger a subagent to run a review, and a skill could provide the subagent with the review checklist.

Do skills work in subagents?

Subagents can have access to skills if you configure them to. The subagent's system prompt can reference a skill, or you can include the skill content in its prompt manually.

How do I debug a hook that isn't working?

Check the hook's exit code and output. Hooks that exit with a non-zero code will fail, and Claude will report the error. Also, verify the hook's path and permissions—it must be executable.

Can I create my own subagent?

Yes, you can define subagents in a `.claude/agents` directory, specifying the system prompt, tools, and model. This is a common way to create specialized assistants.

Are there any limits on the number of hooks or skills?

There is no hard limit, but having too many can slow down Claude or clutter the context. Keep them organized and only load what is necessary.

What is the difference between a skill and a subagent's system prompt?

A skill is a reusable package that can be loaded on demand, while a subagent's system prompt is fixed for that subagent. Skills are more flexible because they can be shared across different contexts.