agentsclimarketplace

Add agent hooks claude code

Skill yukihirop/nagi/.claude/skills/add-agent-hooks-claude-code

nagi (凪): AI agent orchestration framework (remake nanoclaw)

Install
npx -y skills add yukihirop/nagi --skill add-agent-hooks-claude-code

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Add agent-hooks plugin for sending tool execution and session start notifications to chat channels. Triggers on "add agent hooks", "enable hooks", "setup agent hooks", "add hooks".

SKILL.md

4.3 KB, as published. Nobody here has run it

Add Agent Hooks (Claude Code)

Step 0: Language selection

Before proceeding with any other steps in this skill, ask the user which language to continue in using AskUserQuestion. Keep this initial prompt in English because the preferred language is not yet known.

  • Question: Which language should I continue in?
  • Options: English, 日本語 (Japanese)

Use the selected language for all subsequent user-facing messages and for every further AskUserQuestion prompt in this skill. Do not translate code, file paths, shell commands, or file contents.

Enable PostToolUse and SessionStart hooks that send real-time notifications to the chat channel when the agent executes tools or starts a session.

What it does

  • PostToolUse — Sends a message like 🔧 `Bash: ls -la /workspace/group` to the chat channel after each tool execution
  • SessionStart — Sends 💭 Thinking... when a new session begins

Steps

1. Check prerequisites

test -f container/claude-code/plugins/agent-hooks/index.mjs && echo "PLUGIN_EXISTS" || echo "PLUGIN_MISSING"
test -f deploy/{ASSISTANT_NAME}/host/entry.ts && echo "ENTRY_EXISTS" || echo "ENTRY_MISSING"
test -f deploy/{ASSISTANT_NAME}/container/claude-code/entry.ts && echo "CONTAINER_ENTRY_EXISTS" || echo "CONTAINER_ENTRY_MISSING"

If plugin is missing, something is wrong — the plugin ships with the repo.

If deploy/{ASSISTANT_NAME}/host/entry.ts is missing, run /setup first.

If deploy/{ASSISTANT_NAME}/container/claude-code/entry.ts is missing:

cp deploy/templates/container/claude-code/entry.template.ts deploy/{ASSISTANT_NAME}/container/claude-code/entry.ts

2. Enable hooks in deploy/{ASSISTANT_NAME}/host/entry.ts (host side)

Read deploy/{ASSISTANT_NAME}/host/entry.ts and check if registerHooksPlugin is already called.

If not present, add after the MCP plugin registrations:

// Register agent hooks (PostToolUse / SessionStart notifications to chat)
orchestrator.registerHooksPlugin({
  postToolUse: true,
  sessionStart: true,
});

3. Enable hooks in deploy/{ASSISTANT_NAME}/container/claude-code/entry.ts (container side)

Read deploy/{ASSISTANT_NAME}/container/claude-code/entry.ts and check if the agent-hooks plugin is loaded.

If not present, ensure the plugin import block exists:

try {
  const pluginPath = "/app/agent-plugins/agent-hooks/index.mjs";
  const agentHooks = await import(/* webpackIgnore: true */ pluginPath);

  plugins.push({
    name: "agent-hooks",
    createHooks: (
      chatJid: string,
      groupFolder: string,
      hooksConfig: { postToolUse?: boolean; sessionStart?: boolean; skipTools?: string[] } | undefined,
      log: (msg: string) => void,
    ) => ({
      ...(hooksConfig?.postToolUse !== false ? {
        PostToolUse: [{ hooks: [agentHooks.createPostToolUseHook(chatJid, groupFolder, hooksConfig?.skipTools, log)] }],
      } : {}),
      ...(hooksConfig?.sessionStart !== false ? {
        SessionStart: [{ hooks: [agentHooks.createSessionStartHook(chatJid, groupFolder, log)] }],
      } : {}),
    }),
  });
} catch {
  // Plugin not available, skip
}

4. Verify

pnpm exec tsc --noEmit

TypeScript must compile without errors.

5. Restart nagi

launchctl kickstart -k gui/$(id -u)/com.nagi.{ASSISTANT_NAME}
sleep 2
launchctl list | grep com.nagi.{ASSISTANT_NAME}

6. Test

Tell user to send a message in Slack/Discord that triggers tool use (e.g. @ai /workspace/group の中身を教えて).

Expected: tool execution notifications appear in the chat channel as code-formatted messages.

Configuration options

In deploy/{ASSISTANT_NAME}/host/entry.ts, the hooks can be customized:

orchestrator.registerHooksPlugin({
  postToolUse: true,      // Enable/disable tool use notifications
  sessionStart: true,     // Enable/disable "Thinking..." message
  skipTools: [            // Additional tools to skip (mcp__nagi__send_message is always skipped)
    "mcp__nagi__list_tasks",
  ],
});

Set postToolUse: false or sessionStart: false to disable individual hooks.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.