Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

How to Build a Claude Code Plugin with Custom Commands and Hooks

A practical guide to structuring a Claude Code plugin, adding slash commands and hooks, loading it locally, testing behavior, and choosing how to share it.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build a Claude Code plugin by putting its manifest at .claude-plugin/plugin.json, slash-command Markdown files in commands/, and event-hook configuration in hooks/hooks.json. Load the plugin locally with claude --plugin-dir ./my-plugin, then validate and test it before sharing it directly or through a marketplace.

Start with the plugin root and manifest

The plugin root is the directory Claude Code loads. Only the manifest belongs inside .claude-plugin/; component directories sit alongside it.

As an Amazon Associate I earn from qualifying purchases.

my-plugin/
├── .claude-plugin/
│   └── plugin.json
├── commands/
│   └── audit.md
├── hooks/
│   └── hooks.json
└── scripts/
    └── validate.sh

This is a minimal illustrative structure: scripts/ is an author-chosen location, not a required directory. Other supported component locations include agents/, skills/, and .mcp.json; add only the components your plugin needs. See Anthropic’s plugin layout documentation and official Claude Code repository for current conventions.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create .claude-plugin/plugin.json as the plugin manifest. Consult the current Claude Code documentation for required manifest fields and valid values rather than copying a schema from an older example: plugin conventions can evolve.

Choose a command, a hook, or both

Component Where it goes How it runs Design consideration
Custom slash command A Markdown file under commands/ A person invokes it explicitly Use its description and argument hints to communicate purpose and inputs.
Hook Configuration in hooks/hooks.json Automatically in response to a configured event Choose the event and matcher deliberately; inspect executable behavior and side effects.

Create a command Markdown file

Put each command in a Markdown file under commands/. The file defines a saved prompt that the user invokes as a slash command. The plugin development toolkit documents frontmatter such as description, argument-hint, and allowed-tools, along with dynamic arguments, file references, and plugin-aware namespacing. Check the installed Claude Code documentation for the exact current syntax and invocation name; namespacing helps prevent collisions with commands from other plugins.

Configure event-driven hooks

Put hook declarations in hooks/hooks.json, using a top-level hooks key and a shape based on the hooks setting. Select only events the plugin needs. The toolkit lists events including PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, and Notification. Event names, matchers, and schema details should be checked against the current documentation before implementation.

Hooks are executable automation, not merely descriptive prompt text. Validate input, keep behavior narrowly scoped, and use ${CLAUDE_PLUGIN_ROOT} for paths that must work wherever the plugin is installed. Review scripts and their side effects; a JSON file passing schema validation does not establish that a hook is safe or appropriate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Load and test the plugin locally

  1. Start Claude Code with the plugin root: from a shell, run claude --plugin-dir ./my-plugin. This loads the plugin for that session; it does not publish it or install it for every project.
  2. Exercise the command: invoke its plugin-aware slash-command name in that session, supplying any arguments the command expects. Confirm the prompt and any referenced files or tools behave as intended.
  3. Exercise hooks with controlled inputs: verify the intended event and matcher, inspect the hook’s output and side effects, and include cases with missing or malformed input.
  4. Reload after edits: while the session is running, use /reload-plugins to reload plugin changes, as described in the creation documentation.

The plugin development toolkit documents utilities including validate-hook-schema.sh hooks/hooks.json, test-hook.sh my-hook.sh test-input.json, and a hook linter. These are toolkit utilities rather than guaranteed built-in Claude Code commands; confirm the utility paths and availability in your installed toolkit before using them. Its guided creation workflow also covers planning, implementation, validation, testing, and documentation. The toolkit’s named “8-Phase Process” describes that workflow specifically, not a requirement imposed on every plugin. See the plugin development toolkit resources for its current materials.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Pick a distribution route

Route Audience and access Updates Review
Share a directory or ZIP Direct recipients Recipients need an updated copy when you change it. No marketplace listing process is required for direct sharing.
Team marketplace Users who can access the marketplace Marketplace-based distribution can support updates. Current marketplace terms and setup depend on the marketplace.
Anthropic’s directory Potential directory users Directory distribution rather than direct file handoff Submission is subject to review; acceptance or publication is not guaranteed.

Choose direct sharing for a small, known audience; use a marketplace when discoverability and managed distribution matter. The available sources describe these broad routes but do not establish complete current marketplace terms. Check Anthropic’s plugin documentation and its plugin resources for current submission and setup details.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.