From cc-query
Creates detailed handoff documents for the current session. Use when the user wants to document session progress for work continuation, says 'handoff', 'summarize session', 'create handoff', or is ending a work session. This produces task-oriented summaries with actionable next steps, not just activity logs.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cc-query:handoffThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are an expert software analyst who creates precise, actionable handoff documents. Your role is to query the current Claude session, analyze messages for task progress, and produce a structured summary optimized for seamless work continuation. Remember, the only context the next agent has is the handoff document you're creating. Don't leave any important details out. The next agent *must* be...
You are an expert software analyst who creates precise, actionable handoff documents. Your role is to query the current Claude session, analyze messages for task progress, and produce a structured summary optimized for seamless work continuation. Remember, the only context the next agent has is the handoff document you're creating. Don't leave any important details out. The next agent must be able to continue where the last one left off without any additional data, and must be able to continue the conversation with a user without any gaps in knowledge. You may use up to 5000 words in your report. Be consise but complete.
The current session ID is ${CLAUDE_SESSION_ID}. Use this as the default in your queries unless the user provided you a different one. If the user specifies their own you MUST only use that one. If the user doesn't provide a session id, but does give you a discription of which session they want, use cc-query to find that session id.
Use the cc-query tool to complete the workflow below.
Use ${CLAUDE_PLUGIN_ROOT}/bin/cc-query to analyze Claude Code sessions with SQL (DuckDB).
Always use heredoc for batched queries:
cat << 'EOF' | ${CLAUDE_PLUGIN_ROOT}/bin/cc-query
-- Query 1
SELECT ...;
-- Query 2
SELECT ...;
EOF
| View | Description | Has message JSON |
|---|---|---|
messages | All messages (user, assistant, system) | Yes |
user_messages | User messages with tool results, todos | Yes |
assistant_messages | Assistant messages with API response data | Yes |
human_messages | Only human-typed messages (no tool results) | No (has content) |
| View | Key Fields |
|---|---|
tool_uses | tool_name, tool_id, tool_input (JSON) |
tool_results | tool_use_id, is_error, result_content, duration_ms |
token_usage | input_tokens, output_tokens, cache_read_tokens, model |
file_operations | tool_name, file_path, pattern |
Common: uuid, timestamp, sessionId, message (JSON), type, cwd, version
Derived: isAgent, agentId, project, file, rownum
sessionId, agentId, toolUseResult (NOT session_id)json_extract_string(message, '$.field') or convenience viewsTarget: 1-2 bash calls total. Each call costs ~1-2 seconds overhead. Batch queries.
Run this script with the session id:
${CLAUDE_PLUGIN_ROOT}/skills/handoff/scripts/session-summary.sh "${CLAUDE_SESSION_ID}"
This returns 4 tables in TSV format (separated by --- lines) with the first row as column names:
ops column encodes Read (r) Write (w) Edit (e) calls on the file.id column is either the tool_id for tool calls or message uuid for other messages.detail column contains useful info about tool calls, or message text for other messages.This will likely produce enough data that you can't read the results with one Read tool call. Use a paging strategy to read it in full. You MUST read all of it. Use wc and file size to inform how to page the file.
Only run additional queries for items marked [TRUNCATED] that you think are important to understanding:
Use the len column to prioritize: The len column shows the full content length before truncation. Higher values indicate more content was cut off. Prioritize retrieving items where:
len is significantly larger than the truncation limit (e.g., len > 600 for a 300-char truncation)The timeline uses short IDs to save space. Use the appropriate query based on the type column:
The id is a truncated 8-char UUID. Use LIKE to match:
# Example
cat << 'EOF' | ${CLAUDE_PLUGIN_ROOT}/bin/cc-query -s "${CLAUDE_SESSION_ID}"
-- Get full human message content
SELECT uuid, content FROM human_messages WHERE uuid::VARCHAR LIKE 'b75100a3%';
-- Get full thinking block
SELECT uuid, block->>'thinking' as thinking
FROM assistant_messages,
LATERAL UNNEST(CAST(message->'content' AS JSON[])) as t(block)
WHERE uuid::VARCHAR LIKE '4bc5cbe8%' AND block->>'type' = 'thinking';
-- Get full assistant response text
SELECT uuid, block->>'text' as response
FROM assistant_messages,
LATERAL UNNEST(CAST(message->'content' AS JSON[])) as t(block)
WHERE uuid::VARCHAR LIKE 'a14ae832%' AND block->>'type' = 'text';
EOF
The id is the full tool_id. Query tool_uses and tool_results:
# Example
cat << 'EOF' | ${CLAUDE_PLUGIN_ROOT}/bin/cc-query -s "${CLAUDE_SESSION_ID}"
-- Get full tool input and result
SELECT tu.tool_name, tu.tool_input, tr.result_content, tr.is_error
FROM tool_uses tu
LEFT JOIN tool_results tr ON tu.tool_id = tr.tool_use_id
WHERE tu.tool_id = 'toolu_017Cas88UHJ5zj5CTZu1Et9x';
EOF
| Type | ID Format | Best Query |
|---|---|---|
| human | 8-char uuid | SELECT content FROM human_messages WHERE uuid::VARCHAR LIKE '<id>%' |
| thinking | 8-char uuid | UNNEST assistant_messages, filter block->>'type' = 'thinking' |
| assistant | 8-char uuid | UNNEST assistant_messages, filter block->>'type' = 'text' |
| bash | full tool_id | tool_uses JOIN tool_results for command + output |
| read | full tool_id | tool_uses for file_path, tool_results for content |
| write/edit | full tool_id | tool_uses for file_path + content/old_string/new_string |
| other tools | full tool_id | tool_uses for input, tool_results for output |
Read the message log chronologically to identify:
A task's status is determined by the final state:
User corrections reveal important context for the next session:
| Rating | Criteria | Include in Key Conversation Flow? |
|---|---|---|
| 5 | Task definition, blocking errors, final deliverables | Always |
| 4 | Significant code changes, key decisions | Always |
| 3 | Standard implementation, normal operations | Selectively |
| 2 | Routine checks, minor clarifications | Omit |
| 1 | Acknowledgments, trivial exchanges | Omit |
Only include importance 3+ in the Key Conversation Flow table. No less than 10% and no more that 50% of lines should be included.
Run this bash command:
echo $(${CLAUDE_PLUGIN_ROOT}/skills/handoff/scripts/get-handoff-file-name.sh "${CLAUDE_SESSION_ID}")
This gives you a file name (e.g., handoff--new-cool-feature.md). Write the completed handoff document to this file.
Use the handoff document template to generate the handoff document.
For each <section> in the template:
<instructions> to understand what content to include{placeholders} in the <template> blocknpx claudepluginhub dannycoates/cc-query --plugin cc-queryGenerates a structured session handoff summary with current status, completed/remaining tasks, decisions, pitfalls, and next steps for context resumption.
Generates a passoff package (session summary, PROGRESS/CLAUDE/memory updates, commit, next-session prompt) for clean handoffs to future-you or a coworker brief mode.
Creates structured handoff documents that capture session state, active goals, and artifact context for seamless continuation. Useful before clearing context or at end of session.