/session:end
Cleanly end a Claude Code session, removing its lock and optionally cleaning up the git worktree.
Quick Start
/agileflow:session:endHow It Works
- Shows current session information
- Asks if you want to remove the git worktree
- Removes the session lock file
- Optionally deletes the worktree directory
Example Interaction
Ending Session 2 "auth"
Path: /home/user/myproject-auth
Branch: session-2
Created: 2 hours ago
Do you want to remove the git worktree?
○ Keep worktree (just end session tracking)
○ Remove worktree (delete directory and branch)
Cleanup Options
| Option | What Happens |
|---|---|
| Keep worktree | Session lock removed, directory stays. You can cd there and work manually. |
| Remove worktree | Directory deleted, branch optionally removed, full cleanup. |
When to Use Each Option
Keep Worktree
- You want to continue working there without Claude
- You need to preserve uncommitted changes
- You'll return to this work later
Remove Worktree
- Work is complete and merged
- You want to free up disk space
- Cleaning up abandoned experiments
Ending Current Session
When running from your current session:
/agileflow:session:end
# This ends your current session
# You'll see a warning before proceedingEnding Other Sessions
You can also end sessions you're not currently in:
/agileflow:session:status
# See all sessions
/agileflow:session:end
# Select which session to endWhat Gets Cleaned Up
Session Lock
Always removed:
.agileflow/sessions/2.lock → deleted
Registry Entry
Updated:
{
"sessions": {
"2": {
"ended": "2025-12-26T15:00:00Z",
"status": "ended"
}
}
}Git Worktree (optional)
If you choose to remove:
git worktree remove /home/user/myproject-auth
# Directory deleted
# Branch optionally deletedSafety Checks
The command prevents accidental data loss:
- Uncommitted changes: Warning shown if worktree has uncommitted work
- Main session: Cannot remove main project worktree
- Active sessions: Warning if trying to end another active session
Stale Session Cleanup
If a session died unexpectedly:
/agileflow:session:status
# Shows "stale" for dead sessions
/agileflow:session:end
# Select the stale session to clean upRelated Commands
/session:status- Check session state first/session:new- Create replacement session/session:history- See ended sessions