-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Labels
Description
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 5 of 6 — Depends on #240 (insights command).
Problem
When the analysis hook fails, or a user installs Code Insights after having existing sessions, unanalyzed sessions accumulate. We need a recovery mechanism.
Solution
code-insights insights check subcommand
code-insights insights check [options]
--days <n> Lookback window (default: 7)
--quiet, -q Machine-readable output (just count)
Behavior by Count
| Unanalyzed (last 7d) | Behavior |
|---|---|
| 0 | Silent exit |
| 1-2 | Auto-analyze silently (calls insights <id> --native for each) |
| 3-10 | Print count + suggest: "Run code-insights insights check --analyze to process them" |
| 11+ | Print count + time estimate + suggest command |
Query
SELECT s.id, s.title, s.started_at
FROM sessions s
LEFT JOIN analysis_usage au ON au.session_id = s.id AND au.analysis_type = 'session'
WHERE s.started_at > datetime('now', '-7 days')
AND s.deleted_at IS NULL
AND au.session_id IS NULL
ORDER BY s.started_at DESCOptional SessionStart Hook
For automatic detection, users can add a SessionStart hook:
{
"SessionStart": [{
"hooks": [{ "type": "command", "command": "node <cli> insights check -q" }]
}]
}This is informational only (prints a notice), not installed by default.
Acceptance Criteria
-
insights checkqueries unanalyzed sessions in last 7 days - 1-2 sessions: auto-analyzes with --native
- 3+ sessions: prints suggestion message with count
-
--days <n>overrides lookback window -
--quietoutputs just the count (for scripting) -
--analyzeflag processes all found sessions - Progress output during batch processing:
[1/8] session-title ... done (12s) - Non-blocking — single notice, no nag on repeat invocations
Reactions are currently unavailable