Skip to content

feat: update install-hook to add SessionEnd analysis hook #241

@melagiri

Description

@melagiri

Context

Part of the Native Analysis via Claude Code Hooks feature (Phase 12, v4.8.0).
Plan: docs/plans/2026-03-28-native-analysis-hooks.md

Issue 4 of 6 — Depends on #240 (insights command must exist).

Problem

Today code-insights install-hook only installs a Stop hook for auto-sync. To enable native analysis, we also need a SessionEnd hook that triggers code-insights insights --hook --native -q.

Solution

Update installHookCommand() to install both hooks by default:

{
  "hooks": {
    "Stop": [
      { "hooks": [{ "type": "command", "command": "node <cli> sync -q" }] }
    ],
    "SessionEnd": [
      { "hooks": [{ "type": "command", "command": "node <cli> insights --hook --native -q", "timeout": 120000 }] }
    ]
  }
}

New Flags

  • --sync-only — install only the Stop (sync) hook
  • --analysis-only — install only the SessionEnd (analysis) hook

Updated Uninstall

uninstallHookCommand() cleans both Stop and SessionEnd hooks.

Updated Messaging

Install Code Insights Hooks

This will add two Claude Code hooks:

  Stop hook         — Syncs sessions after each response
  SessionEnd hook   — Analyzes sessions using your Claude subscription
                      No API key needed. (~15-30s per session)

Install both hooks? [Y/n]

Acceptance Criteria

  • Default install-hook installs both Stop + SessionEnd hooks
  • --sync-only installs only Stop hook
  • --analysis-only installs only SessionEnd hook
  • Duplicate detection works for both hook types
  • uninstall-hook removes both hook types
  • SessionEnd hook has 120s timeout configured
  • Updated CLI output messaging explains both hooks
  • Telemetry tracks which hook types were installed

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeatureNew functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions