Auto-log your Claude Code work with SessionStart / SubagentStop hooks

Two overlooked hook events for automatic activity logs.

Hooks are more than PreToolUse/PostToolUse

Most guides only cover PreToolUse/PostToolUse. A real `settings.json` also wires up `SessionStart`, `SubagentStop`, `Stop` and `UserPromptSubmit` — all six event types were present on this machine's live config.

SessionStart: fires once per new session

Omit `matcher` and it always runs. Use it to log when and where a session started.

{
  "hooks": {
    "SessionStart": [
      { "hooks": [ { "type": "command", "command": "node .claude/hooks/logger.js SessionStart" } ] }
    ]
  }
}

SubagentStop: fires when a subagent finishes

If you delegate work to multiple `.claude/agents/`, this event lets you log which one finished and when.

Minimal logger

A few lines of Node.js: read stdin JSON, append one JSON-Lines record with event name, timestamp and cwd.

// .claude/hooks/logger.js
const fs = require('fs');
let input = '';
process.stdin.on('data', (d) => (input += d));
process.stdin.on('end', () => {
  const line = JSON.stringify({ event: process.argv[2], at: new Date().toISOString(), cwd: process.cwd() });
  fs.appendFileSync(process.env.HOME + '/.claude/work.log.jsonl', line + '\n');
});

vs. Stop

`Stop` fires per conversation turn — good for tests/summaries. `SessionStart`/`SubagentStop` fire at the session/subagent granularity — good for time tracking.

Useful for solo devs & freelancers

Juggling several projects? Use `SessionStart` logs as a daily-report draft and `SubagentStop` logs as a record of what you delegated to AI.

FAQ

When does SessionStart fire?
Once, at the start of a new session. Omit `matcher` to always run it.
What is SubagentStop useful for?
Detecting when a delegated subagent finishes, and logging which one.
Stop vs SessionStart?
Stop fires per conversation turn; SessionStart fires once per session — different granularity.
Where should logs be stored?
No fixed rule, but JSON Lines (one JSON object per line) is easy to grep/jq later.
How does this help solo developers?
Use the logs as a draft daily report or a record of what was delegated to AI, across multiple projects.