Feature Request: Plugin API with conversation context access for post-response hooks
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:
- Hooks have no access to conversation content — they only receive metadata (
session_id,cwd,transcript_path) - Stop hook cannot inject follow-up instructions — stdout from Stop hooks is not fed back to Claude
- Rules/memory can remind Claude to log manually, but Claude may forget during complex multi-step tasks (which is exactly when logging matters most)
- 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:
- 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"]
}
- Plugin lifecycle hooks
onResponseComplete(context)— after each Claude responseonSessionStart(context)— with previous session dataonSessionEnd(context)— with full session summaryonContextOverflow(context)— before compaction, allowing plugins to save state
- 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_pathin 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)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗