dotclaude

Hook in workflow

subagent-summary

A SubagentStop hook that appends one JSON line per finished subagent to a project log (timestamp, session, agent id, and the first 300 characters of its final report), giving delegated and parallel work an audit trail. Use when sessions fan work out to subagents and you want to see afterwards what each one did and reported.

Install

As a plugin

Bundled in the workflow-hooks plugin. Add the marketplace once, then install the bundle; it updates with the marketplace.

/plugin marketplace add KhaledSaeed18/dotclaude
/plugin install workflow-hooks@dotclaude

As a single item

Run from the project root; the hook lands under .claude/. Copy it to ~/.claude/ to make it global.

npx shadcn@latest add KhaledSaeed18/dotclaude/subagent-summary

Installed as a single item, a hook still needs the settings block documented below added to .claude/settings.json. The plugin route wires it automatically.

Files installed

  • .claude/hooks/subagent-summary/HOOK.md
  • .claude/hooks/subagent-summary/subagent-summary.mjs

What it does

subagent-summary

A Claude Code hook that records every subagent's completion. Delegation is where sessions become hard to follow: a parallel-agents fan-out or a deep-research hand-off runs in its own context, and only the final report comes back. This hook keeps a durable, one-line-per-agent record so you can reconstruct what happened.

Each line in .claude/subagents.log:

{"ts":"2026-09-21T10:00:00.000Z","session":"…","agent":"…","summary":"Found 3 issues in auth.ts…"}

The summary is the last assistant message from the subagent's transcript when Claude Code provides agent_transcript_path, whitespace-collapsed and capped; otherwise it is empty and the line still records that the agent finished.

Add the log file to .gitignore. It is created on first use and stays inside the project.

Files

File Purpose
subagent-summary.mjs The hook script.
HOOK.md This file.

Activate it (required manual step)

Add this to .claude/settings.json (project) or ~/.claude/settings.json (global):

{
  "hooks": {
    "SubagentStop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/subagent-summary/subagent-summary.mjs\""
          }
        ]
      }
    ]
  }
}

Installing the workflow-hooks plugin from the dotclaude marketplace wires this automatically.

Verify it

echo '{"hook_event_name":"SubagentStop","cwd":"'$PWD'","session_id":"s","agent_id":"a"}' \
  | node .claude/hooks/subagent-summary/subagent-summary.mjs
tail -1 .claude/subagents.log

Tune it

{
  "subagentSummary": {
    "logFile": ".claude/subagents.log",
    "maxSummaryChars": 300
  }
}

logFile is relative to the project root and must stay inside it.

Hooks run arbitrary commands on your machine with your credentials whenever their event fires. Read any hook script (including this one) before enabling it.

This is the hook as installed, rendered from its source on GitHub. Read it as Markdown.

  • branch-protectA UserPromptSubmit hook that, once per session, tells Claude the checkout is on a protected branch (main, master, develop, or a configured list) so it...
  • git-guardA PreToolUse hook for Bash that blocks git operations which destroy work or bypass review, with a reason Claude can act on. Stops force-pushes and...
  • session-contextA SessionStart hook that orients every new session before the first prompt by injecting the current branch, ahead/behind status, uncommitted files, the...
  • stop-gateA Stop hook that runs the project's test command before Claude may end a turn with uncommitted changes, blocking the stop and returning the failure output...
  • typecheck-on-editA PostToolUse hook that type-checks the project after Claude edits a TypeScript, Python, or Go file and returns the errors as context immediately, listing...