Skip to content
Agent Orchestration
Command

/session-end

Cleanup and persist session state before ending work.

From plugin
ruflo
80k196 skills169 agents196 commands3 MCP
> /plugin marketplace add ruvnet/ruflo

Command definition

session-end.md

hook session-end

Cleanup and persist session state before ending work.

Usage

npx claude-flow hook session-end [options]

Options

  • `--session-id, -s <id>` - Session identifier to end
  • `--save-state` - Save current session state (default: true)
  • `--export-metrics` - Export session metrics
  • `--generate-summary` - Create session summary
  • `--cleanup-temp` - Remove temporary files

Examples

Basic session end

npx claude-flow hook session-end --session-id "dev-session-2024"

With full export

npx claude-flow hook session-end -s "feature-auth" --export-metrics --generate-summary

Quick close

npx claude-flow hook session-end -s "quick-fix" --save-state false --cleanup-temp

Complete persistence

npx claude-flow hook session-end -s "major-refactor" --save-state --export-metrics --generate-summary

Features

State Persistence

  • Saves current context
  • Stores open files
  • Preserves task progress
  • Maintains decisions

Metric Export

  • Session duration
  • Commands executed
  • Files modified
  • Tokens consumed
  • Performance data

Summary Generation

  • Work accomplished
  • Key decisions made
  • Problems solved
  • Next steps identified

Cleanup Operations

  • Removes temp files
  • Clears caches
  • Frees resources
  • Optimizes storage

Integration

This hook is automatically called by Claude Code when:

  • Ending a conversation
  • Closing work session
  • Before shutdown
  • Switching contexts

Manual usage in agents:

# At session end
npx claude-flow hook session-end --session-id "your-session" --generate-summary

Output

Returns JSON with:

{
  "sessionId": "dev-session-2024",
  "duration": 7200000,
  "saved": true,
  "metrics": {
    "commandsRun": 145,
    "filesModified": 23,
    "tokensUsed": 85000,
    "tasksCompleted": 8
  },
  "summaryPath": "/sessions/dev-session-2024-summary.md",
  "cleanedUp": true,
  "nextSession": "dev-session-2025"
}

See Also

  • `hook session-start` - Session initialization
  • `hook session-restore` - Session restoration
  • `performance report` - Detailed metrics
  • `memory backup` - State backup
Read more
@ruvnet
Ships withruflo

📖 RuFlo Explained — Build an AI Team That Plans, Remembers, Tests, and Improves A 14-chapter guide: from the basic idea to a first useful task, then memory, agent teams, plugins, cost and verification. Agent = Model + Harness.

80k200 skills169 agents3 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
80.4k
Star history of ruvnet/ruflo on GitHub, a chart by star-history.com

Other commands on ruflo.

agent-types

agent-types

Command

Complete guide to all 54 available agent types in Claude Flow.

@ruvnet@ruvnetInstall Command
COMMAND_COMPLIANCE_REPORT

COMMAND_COMPLIANCE_REP…

Command

Reviewed all command files in `.claude/commands/analysis/` directory to ensure proper usage of: - `mcp__claude-flow__*` tools…

@ruvnet@ruvnetInstall Command
bottleneck-detect

bottleneck-detect

Command

Analyze performance bottlenecks in swarm operations and suggest optimizations.

@ruvnet@ruvnetInstall Command

More commands from other plugins.

ask

ask

Command

This compatibility command keeps `/oh-my-claudecode:ask` available without loading the full `ask` skill description in every…

@yeachan-heo@yeachan-heoInstall Command
code-review

code-review

Command

Technical code review for quality, bugs, and AGENTS.md compliance

archon13d24k
@coleam00@coleam00Install Command