Skip to content

Documentation Index

Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt Use this file to discover all available pages before exploring further.

Create a mod

Have Claude write a Claude Code mod from a description, or write one yourself that counts tool calls and adds a command. Learn the reload and validate loop.

A mod is a Claude Code plugin with an entry file, called the hooks module: a JavaScript or TypeScript file whose functions Claude Code calls when events happen. To make one:

  • Ask Claude to write it: describe what you want in a Claude Code session
  • Write it yourself: follow the tutorial to learn how a mod's code works. You don't need Node.js, a bundler, or a build step, because Claude Code loads .js and .ts files directly.

If you haven't decided whether a mod is the right tool, read the comparison on the overview first.

Mods require Claude Code v2.1.287 or later. In your shell, run claude --version to check. To see whether mods can load for you, see Check whether mods can load.

Ask Claude for a mod

Describe the mod you want in an interactive Claude Code session, and Claude writes it. Claude works from a built-in skill named plugin-authoring, which tells it where to write the mod, which events and methods your version has, and how the mod gets loaded. Claude can load the skill when you ask for a mod, or you can load it yourself by running /plugin-authoring at the Claude Code prompt.

The mod runs once you approve it, except in sessions where a mod Claude writes can't load.

Ask for the mod in your own words, for example make a mod that shows the current git branch above the prompt. Claude writes the mod in a directory of its own in the session's mods folder, which is ~/.claude/dev-mods/ followed by the session's ID. A mod's full path looks like ~/.claude/dev-mods/3f2a9c1e-5b7d-4e8a-9c21-6d0f4b8a7e13/git-branch/.

<Note>
  In the `default` and `acceptEdits` [permission modes](/docs/en/permission-modes#protected-paths), Claude Code asks before Claude creates each of the mod's files, because `~/.claude` is a protected path. Approve each file as it comes up.
</Note>

When Claude saves the first file, Claude Code asks whether to enable hot reloading for the session. Hot reloading runs the mods Claude writes in this session and picks up each later change.

Choose one of these answers:

* **Enable for this session**: the mods in the session's mods folder load when the turn ends, and reload at the end of each turn that changes them. Your answer lasts for the session, including after you resume it.
* **Not now**: nothing loads for now. The files stay where Claude wrote them, and the mods load the next time that session starts. To keep a mod from ever loading, delete its directory.

Run /plugin at the Claude Code prompt and press Tab until the Installed tab is selected. It lists the mod, and you can turn it off there.

Use what you asked for. For the example prompt, the current branch name appears above the prompt box. If the mod doesn't do what you wanted, tell Claude what to change. The mod reloads at the end of each turn that changes its files, so you can try the change as soon as Claude finishes.

Use the mod in other sessions

A mod Claude wrote loads only in the session that made it, and Claude Code deletes that session's mods folder once it's older than cleanupPeriodDays. To keep the mod, copy its directory out of the mods folder to a place of your own, such as ~/mods/git-branch. Then choose how to load it:

  • In a session you start: in your shell, run claude --plugin-dir ~/mods/git-branch
  • For other people: add it to a marketplace so they can install it

Sessions where a mod Claude writes can't load

A mod Claude writes loads only after you approve it, in a trusted workspace where mods are allowed to run. In these sessions it doesn't load:

  • Nobody is there to approve: the session can't show you a prompt, as in a claude -p run or dontAsk mode
  • The workspace isn't trusted: you haven't accepted the trust prompt for the directory
  • Mods are disabled: you started with --safe-mode or --bare, you set disableAllHooks, or your organization's managed settings block it

Write a mod yourself

In this tutorial you build a mod named first-mod that counts the tool calls Claude makes, shows the count beside the spinner while Claude works, and adds a /tally command that prints it. You then read the type declarations Claude Code writes beside your mod and run claude plugin validate. Together they show you the events and methods your version offers and what Claude Code reads from your code.

This recording shows the finished mod. The spinner counts tool calls, /tally prints the count, and an edit to the code takes effect while the session runs: