
Driving Claude Code Sessions
Drive long Claude Code sessions with checkpoints, handoffs, and context hygiene.
Install
npx skills add https://github.com/obra/claude-session-driver --skill driving-claude-code-sessionsWhat is this skill?
- Long-session checkpoint patterns.
- Context hygiene between tasks.
- Handoff notes for fresh sessions.
Adoption & trust: 16 installs on skills.sh; 90 GitHub stars; 1/3 security scanners passed (skills.sh audits).
Recommended Skills
Microsoft Foundrymicrosoft/azure-skills
Azure Aimicrosoft/azure-skills
Azure Hosted Copilot Sdkmicrosoft/azure-skills
Lark Eventlarksuite/cli
Running Claude Code Via Litellm Copilotxixu-me/skills
Setup Matt Pocock Skillsmattpocock/skills
Journey fit
Common Questions / FAQ
Is Driving Claude Code Sessions safe to install?
skills.sh reports 1 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Driving Claude Code Sessions
#!/bin/bash # Shared helpers for claude-session-driver scripts. Sourced, not executed. # # Functions defined here: # resolve_session <arg> Print the session_id for a worker, given either # the session_id directly (passes through if a # matching .meta or .events.jsonl file exists) or # the tmux_name (looked up via meta file). Exits # non-zero with a message to stderr if neither # matches a known worker. _CSD_WORKER_DIR=/tmp/claude-workers # Event types emitted by the emit-event hook. Keep in sync with the case # statement in hooks/emit-event. _CSD_VALID_EVENTS="session_start user_prompt_submit pre_tool_use stop session_end" validate_event_type() { local arg="$1" for e in $_CSD_VALID_EVENTS; do if [ "$arg" = "$e" ]; then return 0 fi done echo "Error: '$arg' is not a known event type. Valid events: $_CSD_VALID_EVENTS" >&2 return 1 } resolve_session() { local arg="$1" # If the arg directly corresponds to a known session_id (has either a meta # file or an events file), pass it through. This works for real UUID-style # session_ids as well as synthetic ones used by tests. if [ -f "$_CSD_WORKER_DIR/$arg.meta" ] || [ -f "$_CSD_WORKER_DIR/$arg.events.jsonl" ]; then echo "$arg" return 0 fi # Otherwise treat as a tmux_name. Scan meta files for a match. local meta found found="" for meta in "$_CSD_WORKER_DIR"/*.meta; do [ -f "$meta" ] || continue if [ "$(jq -r '.tmux_name' "$meta" 2>/dev/null)" = "$arg" ]; then found=$(jq -r '.session_id' "$meta") break fi done if [ -z "$found" ]; then echo "Error: no worker known as '$arg' (searched $_CSD_WORKER_DIR/ for session_id or tmux_name match)" >&2 return 1 fi echo "$found" } #!/bin/bash set -euo pipefail # csd — single CLI for claude-session-driver. Dispatches to subcommand # functions defined below. Sources _lib.sh for shared helpers. # # Top-level subcommands (no --worker): launch, adopt, list, grant-consent # Per-worker subcommands (require --worker): converse, send, wait-for-turn, # status, read-events, read-turn, stop, handoff, session-id, events-file # # Per-worker subcommands are normally invoked through a shim at # /tmp/claude-workers/bin/<tmux-name> that bakes in --worker. Direct # invocation as `csd --worker <name> <sub>` is also supported. CSD_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" SCRIPT_DIR="$(dirname "$CSD_PATH")" # shellcheck source=_lib.sh source "$SCRIPT_DIR/_lib.sh" # Constants / arrays TOP_LEVEL_SUBS=(launch adopt list grant-consent help) PER_WORKER_SUBS=(converse send wait-for-turn status read-events read-turn \ stop handoff session-id events-file) # Functions usage() { cat <<EOF Usage: csd <subcommand> [args...] csd --worker <name> <subcommand> [args...] A worker is a Claude Code session in a tmux pane with the session-driver plugin loaded. \`csd launch\` prints a *shim path* on stdout (deterministic at /tmp/claude-workers/bin/<tmux-name>) — run that shim for all per-worker subcommands. \`csd stop\` removes the shim along with the worker's state. Top-level subcommands: launch <tmux-name> <cwd> [-- claude-args...] Bootstrap a worker; shim path on stdout, panel on stderr adopt <tmux-name> <cwd> <session-id> [-- claude-args...] Re-adopt an existing Claude session as a driveable worker via \`claude --resume <session-id>\`. Restores a worker after a reboot/crash wiped /tmp/claude-workers while the conversation transcript survived. If a tmux session named <tmux-name> already exists (e.g. restored by tmux-resurrect), respawns its pane in place; else opens a new one. Shim path on stdout, pane