<!--
Claude Sessions
Part of the Bles Software agent skills repository:
https://www.bles-software.com/claude-skills

Install for Claude Code:
  mkdir -p ~/.claude/skills/claude-sessions
  mv claude-sessions.md ~/.claude/skills/claude-sessions/SKILL.md

Install for Codex:
  mkdir -p ~/.codex/skills/claude-sessions
  mv claude-sessions.md ~/.codex/skills/claude-sessions/SKILL.md

For Gemini CLI and other agents, drop the body of this file into the
project instruction file the agent already reads.
-->

---
name: claude-sessions
description: Manage Claude Code sessions - save, list, and reconnect to previous sessions. Use when user wants to save current session, list sessions, connect to a specific session, or manage session history.
allowed-tools: Read, Bash, Write, Glob
---

# Claude Sessions Management Skill

Save, list, and reconnect to Claude Code sessions with custom names.

## Quick Reference

| Command | Description |
|---------|-------------|
| `/sessions list` | List all saved sessions |
| `/sessions save <name>` | Save current session with a name |
| `/sessions connect <name>` | Connect to a saved session |
| `/sessions current` | Show current session info |
| `/sessions history` | Show session usage history |
| `/sessions all` | Show ALL Claude sessions (saved and unsaved) |

## Session Storage Location

Sessions are stored in:
- **Saved sessions**: `~/teleclaudious/state/saved_sessions.json`
- **Telegram mapping**: `~/teleclaudious/state/telegram_sessions.json`
- **Claude sessions**: `~/.claude/session-env/`

## How to Use

### 1. Save Current Session

To save the current session with a memorable name:

```bash
~/teleclaudious/venv/bin/python ~/teleclaudious/telegram_bot/session_cli.py save "my-project-work" --description "Working on the API integration" --tags api,backend
```

### 2. List Saved Sessions

```bash
~/teleclaudious/venv/bin/python ~/teleclaudious/telegram_bot/session_cli.py list
```

Output example:
```
Saved Sessions:
1. my-project-work (abc123...)
   Last used: 2026-01-05 15:30:00
   Description: Working on the API integration
   Tags: api, backend

2. bug-fix-session (def456...)
   Last used: 2026-01-04 10:00:00
```

### 3. Find a Session

```bash
~/teleclaudious/venv/bin/python ~/teleclaudious/telegram_bot/session_cli.py find "project"
```

### 4. Get Session ID for Connection

```bash
~/teleclaudious/venv/bin/python ~/teleclaudious/telegram_bot/session_cli.py get "my-project-work"
```

This returns just the session ID, useful for scripting.

### 5. Show All Claude Sessions

```bash
~/teleclaudious/venv/bin/python ~/teleclaudious/telegram_bot/session_cli.py all
```

Shows all sessions in `~/.claude/session-env/`, both saved and unsaved.

### 6. Delete a Saved Session

```bash
~/teleclaudious/venv/bin/python ~/teleclaudious/telegram_bot/session_cli.py delete "old-session"
```

Note: This only removes the saved reference, not the actual Claude session data.

### 7. Show History

```bash
~/teleclaudious/venv/bin/python ~/teleclaudious/telegram_bot/session_cli.py history
```

## Connecting to a Session

To connect to a saved session, use the Claude CLI:

```bash
# Get the session ID
SESSION_ID=$(~/teleclaudious/venv/bin/python ~/teleclaudious/telegram_bot/session_cli.py get "my-project-work")

# Resume the session
claude --resume "$SESSION_ID" -p "Continue where we left off"
```

## For Telegram Bot Integration

The Telegram bot can use these commands to switch sessions:

```
/session save <name> - Save current session
/session list - List saved sessions
/session connect <name> - Switch to a saved session
/session current - Show current session
```

## Data Structure

Each saved session contains:

```json
{
  "session_id": "uuid-string",
  "name": "human-readable-name",
  "description": "What was worked on",
  "tags": ["tag1", "tag2"],
  "created_at": "2026-01-05T10:00:00",
  "last_used": "2026-01-05T15:30:00",
  "use_count": 5,
  "session_exists": true
}
```

## Current Session Detection

To find the current session being used by the Telegram bot:

```bash
cat ~/teleclaudious/state/telegram_sessions.json | jq '."6233944104".session_id'
```

## Auto-Save Pattern

Consider implementing auto-save at significant milestones:
- After completing a major feature
- Before switching to a different task
- At end of work session

## Session Naming Conventions

Recommended naming patterns:
- `project-feature` - e.g., `teleclaudious-sessions`
- `date-task` - e.g., `2026-01-05-bugfix`
- `client-work` - e.g., `acme-api`
