---
title: "mod-template"
url: "https://claudemods.dev/ja/builds/mod-template-8ec635"
source: "https://github.com/cskwork/claude-code-mods/tree/main/template"
source_type: "github"
repo: "https://github.com/cskwork/claude-code-mods/tree/main/template"
author: "cskwork"
author_handle: "cskwork"
stars: 0
category: "ワークフロー・CI"
categories: ["workflow"]
tags: ["claude-code", "hooks", "mod-template", "plugin", "scaffold"]
permission_level: 0
scan_complete: true
install: "claude plugin marketplace add cskwork/claude-code-mods\nclaude plugin install mod-template"
added: "2026-10-05T15:34:21.266Z"
updated: "2026-11-06T03:14:49Z"
locale: "ja"
content_locale: "ja"
---

# mod-template

スラッシュコマンド、ステータス行の項目、プロンプト上のバンド、テスト付きの $.state 契約を備え、cskwork/claude-code-mods marketplace からインストールできる Claude Code mod のスターターテンプレートです。

## Description

# claude-code-mods

Claude Code 用の mod（2.1.287 以降）：function hooks で Claude Code の動作を観察、書き換え、応答し、独自の UI を描画します。[Getting started with Claude Code mods](https://claude.dev/blog/getting-started-with-claude-code-mods/) を元にしています。

ランディングページ：https://cskwork.github.io/claude-code-mods/

| Mod | 内容 |
| --- | --- |
| [`token-weather`](token-weather) | プロンプト上にコンテキストウィンドウの 1 行予報を表示します：☀ Clear → ↯ Compact soon、使用済み token、直近 12 turn のスパークライン、直前の turn が追加した量です。 |
| [`blast-radius`](blast-radius) | 危険な Bash コマンド（再帰的な `rm`、`git reset --hard`、`git clean -f`、強制プッシュ、`git branch -D`、`git stash drop/clear`、`kubectl delete`、SQL の `DROP`/`TRUNCATE`、マイグレーション）の前に、影響範囲をドライランして **Proceed** または **Cancel** を尋ねます。キャンセルまたは閉じる操作は呼び出しを拒否します。 |
| [`template`](template) | 未インストールのスターター mod：スラッシュコマンド、ステータス行の項目、バンド、テスト付きの `$.state` 契約を備えます。 |

## インストール

Claude Code の中で実行します：

```
/plugin marketplace add cskwork/claude-code-mods
/plugin install token-weather@claude-code-mods
/plugin install blast-radius@claude-code-mods
/reload-plugins
```

## 新しい mod を作る

```bash
scripts/new-mod.sh my-mod "One line about what it does"
claude --plugin-dir "$PWD/my-mod"     # hot-reloads on every save
```

スクリプトは `template/` をコピーして名前を変更し、`.claude-plugin/marketplace.json` に追加した後、`claude plugin validate` と `claude plugin test` を実行します。

mod は 3 つのファイルと任意の状態契約で構成されます：

```
my-mod/
├── .claude-plugin/plugin.json   name, version, description, "types"
├── hooks/hooks.json             { "modules": ["./register.tsx"] }
├── hooks/register.tsx           export const register: Register = on => { ... }
├── types/index.d.ts             PluginState contract for $.state values
└── tests/my-mod.test.ts         claude plugin test my-mod
```

注意が必要なルール：

- すべての hook は `($, e, next)` です。`next(e)` を呼べば通過し、`next({ ...e, x })` なら書き換えます。呼ばずに戻れば応答します。
- 値は `$.state`（`atom` / `read` / `update`）に保存します。モジュール変数はホットリロードごとにリセットされます。
- Node も DOM も使いません。ファイル、プロセス、時計、UI は `$` 経由で扱い、UI 要素は `$.ui.resolve(e)` から取得します。
- テストのモックも hook です：`on('process.run', ($, e) => ({ value: ... }))`。
- エンジンが mod を読み込むと、隣に `.claude-plugin/types/` を書き込みます。そのため `tsc -p <mod>` で型チェックできます（gitignore 対象）。

## 確認

```bash
for m in token-weather blast-radius template; do claude plugin validate $m && claude plugin test $m; done
```

## Install

```
claude plugin marketplace add cskwork/claude-code-mods
claude plugin install mod-template
```

## Original README

# claude-code-mods

Mods for Claude Code (2.1.287+): plugins of function hooks that observe, rewrite or answer
what Claude Code does and draw their own UI. Based on
[Getting started with Claude Code mods](https://claude.dev/blog/getting-started-with-claude-code-mods/).

Landing page: https://cskwork.github.io/claude-code-mods/

| Mod | What it does |
| --- | --- |
| [`token-weather`](token-weather) | A one-line forecast of the context window above the prompt: ☀ Clear → ↯ Compact soon, tokens used, a sparkline of the last 12 turns, and how much the last turn added. |
| [`blast-radius`](blast-radius) | Before a risky Bash command runs (recursive `rm`, `git reset --hard`, `git clean -f`, force push, `git branch -D`, `git stash drop/clear`, `kubectl delete`, SQL `DROP`/`TRUNCATE`, migrations), dry-runs what it would touch and asks **Proceed** or **Cancel**. Cancel or dismiss denies the call. |
| [`template`](template) | Starter mod, not installed: a slash command, a status line entry, a band, and a `$.state` contract with a test. |

## Install

Inside Claude Code:

```
/plugin marketplace add cskwork/claude-code-mods
/plugin install token-weather@claude-code-mods
/plugin install blast-radius@claude-code-mods
/reload-plugins
```

## Make a new mod

```bash
scripts/new-mod.sh my-mod "One line about what it does"
claude --plugin-dir "$PWD/my-mod"     # hot-reloads on every save
```

The script copies `template/`, renames it, adds it to `.claude-plugin/marketplace.json`,
then runs `claude plugin validate` and `claude plugin test` on it.

A mod is three files plus an optional state contract:

```
my-mod/
├── .claude-plugin/plugin.json   name, version, description, "types"
├── hooks/hooks.json             { "modules": ["./register.tsx"] }
├── hooks/register.tsx           export const register: Register = on => { ... }
├── types/index.d.ts             PluginState contract for $.state values
└── tests/my-mod.test.ts         claude plugin test my-mod
```

Rules that bite:

- Every hook is `($, e, next)`. Call `next(e)` to pass on, `next({ ...e, x })` to rewrite, return without it to answer.
- Keep values in `$.state` (`atom` / `read` / `update`); module variables reset on every hot reload.
- No Node, no DOM: files, processes, clock and UI go through `$`. UI elements come from `$.ui.resolve(e)`.
- Test mocks are hooks too: `on('process.run', ($, e) => ({ value: ... }))`.
- After the engine loads a mod it writes `.claude-plugin/types/` beside it, so `tsc -p <mod>` type-checks it (gitignored).

## Check

```bash
for m in token-weather blast-radius template; do claude plugin validate $m && claude plugin test $m; done
```
