Skip to content

Add a Cursor stop hook for automatic transcript sync #313

Description

@lesbass

Which area does this affect?

Provider support (new or existing)

What problem are you trying to solve?

code-insights install-hook currently configures only Claude Code's SessionEnd hook. Cursor users can sync sessions manually, but they do not have an equivalent automatic workflow after an Agent turn completes.

Recent Cursor versions expose native hooks through ~/.cursor/hooks.json. The reliable end-of-turn event is stop, whose payload includes conversation_id, transcript_path, status, token counts, and workspace roots.

Using Cursor's sessionEnd event is currently problematic: it fires when the composer/tab is explicitly closed rather than after each completed turn, and command execution on window_close has a known Cursor lifecycle bug. Running LLM analysis on every stop would also repeatedly consume credits for the same growing session.

Proposed solution

Add provider selection to the hook commands:

code-insights install-hook --cursor
code-insights uninstall-hook --cursor

The Cursor installer should:

  • Preserve unrelated settings and hooks in ~/.cursor/hooks.json.
  • Install one native stop command hook.
  • Sync only the transcript_path supplied by Cursor, using the Cursor provider.
  • Avoid automatic LLM analysis on every turn; analysis remains explicit or can be added later when Cursor exposes a reliable final-session lifecycle.
  • Be idempotent and support symmetric uninstall.
  • Continue to leave the existing Claude Code behavior as the default.

The hook entry point should accept Cursor's conversation_id payload field and ignore unsuccessful/non-terminal stop events safely.

Alternatives you've considered

  • Use Cursor sessionEnd: currently unreliable on window close and not an end-of-turn event.
  • Run code-insights sync --source cursor manually: works but loses automatic ingestion.
  • Analyze on every stop: technically possible, but wasteful because a multi-turn session would be re-analyzed repeatedly.
  • Replace the Claude hook behavior: rejected because it would break backward compatibility.

Contribution

  • I'd be willing to implement this myself and open a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions