Feature Request: Plugin API with conversation context access for post-response hooks

Resolved 💬 2 comments Opened Feb 14, 2026 by ReachToWisdom Closed Mar 15, 2026

Problem

When a Claude Code session ends unexpectedly — due to context window overflow, session timeout, crash, or manual termination — all conversation history is lost. There is no built-in mechanism to automatically persist conversation summaries or session logs.

Current workaround limitations

The existing hooks system (Stop, SessionEnd, UserPromptSubmit) cannot solve this because:

  1. Hooks have no access to conversation content — they only receive metadata (session_id, cwd, transcript_path)
  2. Stop hook cannot inject follow-up instructions — stdout from Stop hooks is not fed back to Claude
  3. Rules/memory can remind Claude to log manually, but Claude may forget during complex multi-step tasks (which is exactly when logging matters most)
  4. MCP servers can add custom tools, but cannot hook into the response lifecycle

Real-world scenario

I maintain session logs (chat.md) to preserve conversation continuity across sessions. Despite having explicit rules in SESSION_RECORDS.md requiring Claude to update chat.md after every response, Claude frequently forgets during intensive work. When the session then breaks due to context overflow, all progress context is lost.

Proposed Solution

Plugin API with conversation context access

Introduce a plugin system (or enhanced hook API) that provides:

  1. Post-response callback with conversation access

``json
{
"hook_event_name": "PostResponse",
"user_message": "the user's message",
"assistant_response": "Claude's response (or summary)",
"tools_used": ["Edit", "Write", "Bash"],
"files_modified": ["src/app.ts", "README.md"]
}
``

  1. Plugin lifecycle hooks
  • onResponseComplete(context) — after each Claude response
  • onSessionStart(context) — with previous session data
  • onSessionEnd(context) — with full session summary
  • onContextOverflow(context)before compaction, allowing plugins to save state
  1. Plugin manifest (plugin.json)

``json
{
"name": "session-logger",
"version": "1.0.0",
"hooks": ["PostResponse", "SessionEnd", "ContextOverflow"],
"permissions": ["read_conversation", "write_files"]
}
``

Use cases this would enable

  • Automatic session logging — persist conversation summaries without relying on Claude's memory
  • Project state tracking — auto-update TODO/progress files
  • Analytics — track token usage, tool usage patterns per session
  • Custom integrations — Slack notifications, Jira updates, etc.
  • Context preservation — save critical state before context overflow

Alternatives Considered

| Approach | Why insufficient |
|----------|-----------------|
| Stop hook | No conversation content access |
| UserPromptSubmit hook | Reminds Claude but doesn't guarantee execution |
| Rules/MEMORY.md | Claude forgets during complex tasks |
| MCP server | Cannot hook into response lifecycle |
| Source code fork | Proprietary license prevents modification |

Additional Context

  • The transcript_path in hook stdin points to the JSONL transcript file, but parsing it in a shell script is fragile and undocumented
  • A first-class plugin API with structured conversation data would be far more reliable
  • This would also benefit the growing ecosystem of Claude Code extensions (like bkit) that currently rely on hooks + rules workarounds

Environment: Claude Code CLI (npm @anthropic-ai/claude-code)

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗