ac-hooks-manager
自律的なコーディングにおける、Stopフックの設定、ツール実行前後のフック管理、継続的な自動実行の設定など、様々なフックをインストール・管理して、より効率的な開発を支援するSkill。
📜 元の英語説明(参考)
Hook installation and management for autonomous coding. Use when setting up Stop hooks, managing pre/post tool hooks, or configuring autonomous continuation.
🇯🇵 日本人クリエイター向け解説
自律的なコーディングにおける、Stopフックの設定、ツール実行前後のフック管理、継続的な自動実行の設定など、様々なフックをインストール・管理して、より効率的な開発を支援するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o ac-hooks-manager.zip https://jpskill.com/download/9330.zip && unzip -o ac-hooks-manager.zip && rm ac-hooks-manager.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/9330.zip -OutFile "$d\ac-hooks-manager.zip"; Expand-Archive "$d\ac-hooks-manager.zip" -DestinationPath $d -Force; ri "$d\ac-hooks-manager.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
ac-hooks-manager.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
ac-hooks-managerフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] ac-hooks-manager
AC Hooks Manager
自律的な動作を可能にするための Hook のインストールと管理を行います。
概要
自律的な動作のためのすべての Claude Code の Hook を管理します。
- Stop Hook: 自律的な継続を可能にします
- PreToolUse Hook: セキュリティ検証
- PostToolUse Hook: 結果処理
- SessionStart/End Hooks: 状態管理
クイックスタート
自律 Hook のインストール
from scripts.hooks_manager import HooksManager
hooks = HooksManager(project_dir)
await hooks.install_autonomous_hooks()
# 自律的な継続のために Stop hook をインストールします
Hook の状態の確認
status = await hooks.get_status()
print(f"Stop hook: {'installed' if status.stop_hook else 'missing'}")
Stop Hook (コアとなるイノベーション)
Stop hook は、Claude Code の停止イベントをインターセプトすることにより、自律的な継続を可能にします。
Claude Code が応答を完了
│
▼ (Stop イベントが発生)
Stop Hook スクリプト
├─ トランスクリプトを読み込む
├─ 安全性制限をチェックする
├─ Opus analyzer を呼び出す
└─ 決定を返す
│
├─ CONTINUE: 停止をブロックし、次のタスクを注入する
└─ COMPLETE: 停止を許可し、終了する
仕組み
- Claude Code が 応答を完了します
- Stop イベントが発生 します (hook は JSON 入力を受信します)
- Hook スクリプトが実行 されます:
stop_hook_activeをチェックします (無限ループを防止します)- イテレーション/コスト制限をチェックします
- Opus analyzer を呼び出して決定を行います
- 決定が返されます:
CONTINUE: 終了コード 2 + 理由 → Claude は継続しますCOMPLETE: 終了コード 0 → Claude は停止します
Stop Hook の入力
{
"session_id": "abc123",
"transcript_path": "/path/to/conversation.jsonl",
"cwd": "/current/working/directory",
"permission_mode": "default",
"hook_event_name": "Stop",
"stop_hook_active": false
}
重要なフィールド: stop_hook_active
false: Hook が最初に発生 (分析に進みます)true: Hook がすでに一度ブロックされた (ドゥームループを防ぐために停止を許可します)
Stop Hook の出力
継続する場合:
{
"decision": "block",
"reason": "Next task: implement the login endpoint"
}
終了コード: 2
停止する場合:
{
"decision": "approve"
}
終了コード: 0
Hook の設定
.claude/settings.json
{
"hooks": {
"Stop": [{
"matcher": {},
"hooks": [{
"type": "command",
"command": ".claude/skills/ac-hooks-manager/scripts/autonomous-loop.sh"
}],
"timeout": 120
}],
"PreToolUse": [{
"tools": ["Bash"],
"hooks": [{
"type": "command",
"command": ".claude/skills/ac-security-sandbox/scripts/validate.sh"
}]
}],
"PostToolUse": [{
"tools": ["Write", "Edit"],
"hooks": [{
"type": "command",
"command": "npx prettier --write \"$FILE\""
}]
}]
}
}
Hook の種類
1. Stop Hook (自律的な継続)
await hooks.install_stop_hook(
script_path=".claude/skills/ac-hooks-manager/scripts/autonomous-loop.sh",
timeout=120
)
2. PreToolUse Hook (セキュリティ)
await hooks.install_pre_tool_hook(
tools=["Bash"],
script_path=".claude/skills/ac-security-sandbox/scripts/validate.sh"
)
3. PostToolUse Hook (フォーマット)
await hooks.install_post_tool_hook(
tools=["Write", "Edit"],
command="npx prettier --write \"$FILE\""
)
4. Session Hooks
await hooks.install_session_hooks(
on_start=".claude/hooks/load-memory.sh",
on_end=".claude/hooks/save-memory.sh"
)
操作
1. すべての自律 Hook のインストール
await hooks.install_autonomous_hooks()
# インストールされるもの:
# - Stop hook (継続)
# - PreToolUse hook (セキュリティ)
# - Session hooks (メモリ)
2. 特定の Hook のインストール
await hooks.install_hook(
event="Stop",
config={
"type": "command",
"command": "path/to/script.sh"
},
timeout=120
)
3. Hook の削除
await hooks.remove_hook(event="Stop")
4. 状態の確認
status = await hooks.get_status()
# 返されるもの:
# stop_hook: bool
# pre_tool_hooks: list
# post_tool_hooks: list
# session_hooks: dict
5. Hook の検証
errors = await hooks.validate()
if errors:
for error in errors:
print(f"Hook error: {error}")
自律ループスクリプト
scripts/autonomous-loop.sh
#!/bin/bash
# Read input from stdin
INPUT=$(cat)
# Extract fields
STOP_ACTIVE=$(echo "$INPUT" | jq -r '.stop_hook_active')
TRANSCRIPT=$(echo "$INPUT" | jq -r '.transcript_path')
CWD=$(echo "$INPUT" | jq -r '.cwd')
# Safety check: prevent doom loops
if [ "$STOP_ACTIVE" == "true" ]; then
echo '{"decision": "approve"}'
exit 0
fi
# Load state
STATE_FILE="$CWD/.claude/autonomous-state.json"
if [ -f "$STATE_FILE" ]; then
ITERATION=$(jq -r '.iteration' "$STATE_FILE")
COST=$(jq -r '.estimated_cost' "$STATE_FILE")
else
ITERATION=0
COST=0
fi
# Check limits
MAX_ITERATIONS=50
MAX_COST=20.00
if [ "$ITERATION" -ge "$MAX_ITERATIONS" ]; then
echo '{"decision": "approve"}'
exit 0
fi
if (( $(echo "$COST > $MAX_COST" | bc -l) )); then
echo '{"decision": "approve"}'
exit 0
fi
# Call Opus analyzer (see ac-opus-analyzer skill)
DECISION=$(python3 "$CWD/.claude/skills/ac-hooks-manager/scripts/analyze.py" \
--transcript "$TRANSCRIPT" \
--iteration "$ITERATION")
# Return decision
echo "$DECISION"
exit $(echo "$DECISION" | jq -r 'if .decision == "block" then 2 else 0 end')
安全機構
1. ドゥームループの防止
if [ "$STOP_ACTIVE" == "true" ]; then
exit 0 # 停止を許可
fi
2. イテレーション制限
if [ "$ITERATION" -ge "$MAX_ITERATIONS" ]; then
exit 0 # 停止を許可
fi
3. コスト制限
if (( $(echo "$COST > $MAX_COST" | bc -l) )); then
exit 0 # 停止を許可
fi
4. 失敗の検出
FAILURES=$(jq -r '.consecutive_failures' "$STATE_FILE")
if [ "$FAILURES" -ge 3 ]; then
exit 0 # 停止を許可、エスカレーション
fi
統合
(原文がここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
AC Hooks Manager
Hook installation and management for enabling autonomous operation.
Overview
Manages all Claude Code hooks for autonomous operation:
- Stop Hook: Enables autonomous continuation
- PreToolUse Hook: Security validation
- PostToolUse Hook: Result processing
- SessionStart/End Hooks: State management
Quick Start
Install Autonomous Hooks
from scripts.hooks_manager import HooksManager
hooks = HooksManager(project_dir)
await hooks.install_autonomous_hooks()
# Installs Stop hook for autonomous continuation
Check Hook Status
status = await hooks.get_status()
print(f"Stop hook: {'installed' if status.stop_hook else 'missing'}")
The Stop Hook (Core Innovation)
The Stop hook enables autonomous continuation by intercepting Claude Code's stop event:
Claude Code completes response
│
▼ (Stop event fires)
Stop Hook Script
├─ Read transcript
├─ Check safety limits
├─ Call Opus analyzer
└─ Return decision
│
├─ CONTINUE: block stop, inject next task
└─ COMPLETE: allow stop, terminate
How It Works
- Claude Code finishes a response
- Stop event fires (hook receives JSON input)
- Hook script executes:
- Checks
stop_hook_active(prevents infinite loops) - Checks iteration/cost limits
- Calls Opus analyzer for decision
- Checks
- Decision returned:
CONTINUE: Exit code 2 + reason → Claude continuesCOMPLETE: Exit code 0 → Claude stops
Stop Hook Input
{
"session_id": "abc123",
"transcript_path": "/path/to/conversation.jsonl",
"cwd": "/current/working/directory",
"permission_mode": "default",
"hook_event_name": "Stop",
"stop_hook_active": false
}
Critical Field: stop_hook_active
false: First time hook firing (proceed with analysis)true: Hook already blocked once (allow stop to prevent doom loop)
Stop Hook Output
To Continue:
{
"decision": "block",
"reason": "Next task: implement the login endpoint"
}
Exit code: 2
To Stop:
{
"decision": "approve"
}
Exit code: 0
Hook Configuration
.claude/settings.json
{
"hooks": {
"Stop": [{
"matcher": {},
"hooks": [{
"type": "command",
"command": ".claude/skills/ac-hooks-manager/scripts/autonomous-loop.sh"
}],
"timeout": 120
}],
"PreToolUse": [{
"tools": ["Bash"],
"hooks": [{
"type": "command",
"command": ".claude/skills/ac-security-sandbox/scripts/validate.sh"
}]
}],
"PostToolUse": [{
"tools": ["Write", "Edit"],
"hooks": [{
"type": "command",
"command": "npx prettier --write \"$FILE\""
}]
}]
}
}
Hook Types
1. Stop Hook (Autonomous Continuation)
await hooks.install_stop_hook(
script_path=".claude/skills/ac-hooks-manager/scripts/autonomous-loop.sh",
timeout=120
)
2. PreToolUse Hook (Security)
await hooks.install_pre_tool_hook(
tools=["Bash"],
script_path=".claude/skills/ac-security-sandbox/scripts/validate.sh"
)
3. PostToolUse Hook (Formatting)
await hooks.install_post_tool_hook(
tools=["Write", "Edit"],
command="npx prettier --write \"$FILE\""
)
4. Session Hooks
await hooks.install_session_hooks(
on_start=".claude/hooks/load-memory.sh",
on_end=".claude/hooks/save-memory.sh"
)
Operations
1. Install All Autonomous Hooks
await hooks.install_autonomous_hooks()
# Installs:
# - Stop hook (continuation)
# - PreToolUse hook (security)
# - Session hooks (memory)
2. Install Specific Hook
await hooks.install_hook(
event="Stop",
config={
"type": "command",
"command": "path/to/script.sh"
},
timeout=120
)
3. Remove Hook
await hooks.remove_hook(event="Stop")
4. Check Status
status = await hooks.get_status()
# Returns:
# stop_hook: bool
# pre_tool_hooks: list
# post_tool_hooks: list
# session_hooks: dict
5. Validate Hooks
errors = await hooks.validate()
if errors:
for error in errors:
print(f"Hook error: {error}")
Autonomous Loop Script
scripts/autonomous-loop.sh
#!/bin/bash
# Read input from stdin
INPUT=$(cat)
# Extract fields
STOP_ACTIVE=$(echo "$INPUT" | jq -r '.stop_hook_active')
TRANSCRIPT=$(echo "$INPUT" | jq -r '.transcript_path')
CWD=$(echo "$INPUT" | jq -r '.cwd')
# Safety check: prevent doom loops
if [ "$STOP_ACTIVE" == "true" ]; then
echo '{"decision": "approve"}'
exit 0
fi
# Load state
STATE_FILE="$CWD/.claude/autonomous-state.json"
if [ -f "$STATE_FILE" ]; then
ITERATION=$(jq -r '.iteration' "$STATE_FILE")
COST=$(jq -r '.estimated_cost' "$STATE_FILE")
else
ITERATION=0
COST=0
fi
# Check limits
MAX_ITERATIONS=50
MAX_COST=20.00
if [ "$ITERATION" -ge "$MAX_ITERATIONS" ]; then
echo '{"decision": "approve"}'
exit 0
fi
if (( $(echo "$COST > $MAX_COST" | bc -l) )); then
echo '{"decision": "approve"}'
exit 0
fi
# Call Opus analyzer (see ac-opus-analyzer skill)
DECISION=$(python3 "$CWD/.claude/skills/ac-hooks-manager/scripts/analyze.py" \
--transcript "$TRANSCRIPT" \
--iteration "$ITERATION")
# Return decision
echo "$DECISION"
exit $(echo "$DECISION" | jq -r 'if .decision == "block" then 2 else 0 end')
Safety Mechanisms
1. Doom Loop Prevention
if [ "$STOP_ACTIVE" == "true" ]; then
exit 0 # Allow stop
fi
2. Iteration Limits
if [ "$ITERATION" -ge "$MAX_ITERATIONS" ]; then
exit 0 # Allow stop
fi
3. Cost Limits
if (( $(echo "$COST > $MAX_COST" | bc -l) )); then
exit 0 # Allow stop
fi
4. Failure Detection
FAILURES=$(jq -r '.consecutive_failures' "$STATE_FILE")
if [ "$FAILURES" -ge 3 ]; then
exit 0 # Allow stop, escalate
fi
Integration Points
- ac-session-manager: Triggers hooks
- ac-security-sandbox: PreToolUse validation
- ac-opus-analyzer: Decision making
- ac-state-tracker: State persistence
- ac-config-manager: Hook configuration
References
references/HOOK-MECHANICS.md- Detailed hook behaviorreferences/STOP-HOOK.md- Stop hook deep divereferences/SAFETY.md- Safety mechanisms
Scripts
scripts/hooks_manager.py- Core HooksManagerscripts/autonomous-loop.sh- Stop hook handlerscripts/analyze.py- Opus analyzer wrapperscripts/hook_installer.py- Hook installation