npx claudepluginhub shakestzd/htmlgraph<!-- Efficiency: SDK calls: 2-3, Bash calls: 0, Context: ~5% -->
# /htmlgraph:end
End the current session and record work summary
## Usage
## Parameters
## Examples
Gracefully end the current session and show work summary
## Instructions for Claude
This command uses the SDK's `end_session()` method.
### Implementation:
python
# First try environment variable (Claude Code provides this)
session_id = os.getenv("CLAUDE_SESSION_ID")
# Fallback to SDK query if not available
if not session_id:
active_sessions = sdk.sessions.where(status="active")
if not...End the current session and record work summary
/htmlgraph:end
/htmlgraph:end
Gracefully end the current session and show work summary
This command uses the SDK's end_session() method.
import os
from htmlgraph import SDK
sdk = SDK(agent="claude")
# Parse arguments
**DO THIS:**
1. **Get current session ID:**
```python
# First try environment variable (Claude Code provides this)
session_id = os.getenv("CLAUDE_SESSION_ID")
# Fallback to SDK query if not available
if not session_id:
active_sessions = sdk.sessions.where(status="active")
if not active_sessions:
print("Error: No active session to end")
return
session_id = active_sessions[0].id
Get current work item for handoff:
active_work = sdk.get_active_work_item()
handoff_notes = None
if active_work:
# Prepare handoff notes with current work context
handoff_notes = f"Working on: {active_work.get('title', 'Unknown')}"
if active_work.get('description'):
handoff_notes += f"\n\nContext: {active_work['description']}"
End the session using SDK:
session = sdk.end_session(
session_id=session_id,
handoff_notes=handoff_notes
)
Extract session details:
session.idsession.created_at to nowPresent the session summary using the output template below
Include the summary of accomplishments:
Provide next-session guidance:
htmlgraph serve.htmlgraph/sessions/CRITICAL CONSTRAINT:
/htmlgraph:end when the user explicitly requests it
### Output Format:
## Session Ended
**Session ID:** {session_id}
**Duration:** {duration}
**Events:** {event_count}
### Work Summary
{features_worked_on_with_counts}
### Progress Made
- {accomplishment_summary}
---
Session recorded in `.htmlgraph/sessions/`
View dashboard: `htmlgraph serve`