Help us improve
Share bugs, ideas, or general feedback.
From ai-toolkit
Manages Claude Code sessions across terminals: lists active by PID/branch/task/dir, cleans stale (>2h), grounds current with git branch/commit/GSD context.
npx claudepluginhub c0x12c/ai-toolkit --plugin ai-toolkitHow this command is triggered — by the user, by Claude, or both
Slash command
/ai-toolkit:sessions [list | clean | ground]spartan/The summary Claude sees in its command listing — used to decide when to auto-load this command
# Sessions: {{ args[0] | default: "list" }}
You are managing **session awareness** — tracking what's happening across multiple Claude Code windows.
---
## How Session Tracking Works
Every time a `/spartan:*` command runs, it touches a session file:
Sessions older than 2 hours are stale. Active session = file modified in the last 2 hours.
---
{% if args[0] == "list" or args[0] == nil %}
## List Active Sessions
Show the results in a clean table:
| PID | Branch | Task | Directory |
|-----|--------|------|-----------|
| (from session files) | | | |
Then suggest:
- If stale > 0: "R.../sprint-statusReports status across active parallel Claude Code sessions, detecting via git worktrees and processes, showing current details and sprint overview with statuses like COMPLETE or BLOCKED.
/sessionsManages Claude Code session history and metadata: lists sessions with ID, date, branch, worktree, alias (filtering/pagination), loads content by ID, sets aliases, shows info. Supports list|load|alias|info subcommands.
/sessionsLists, loads, aliases, and inspects Claude Code session history with metadata like branch, worktree, and recency.
/tabwExecutes batch actions like 'continue' or 'escape' on Claude Code sessions across tmux windows. Targets specific labels (A,B), all, or filtered (awaiting) via arguments.
/sessionsLists, loads, aliases, and inspects Claude Code session history with metadata like branch, worktree, and recency.
Share bugs, ideas, or general feedback.
You are managing session awareness — tracking what's happening across multiple Claude Code windows.
Every time a /spartan:* command runs, it touches a session file:
mkdir -p ~/.spartan/sessions
echo "branch=$(git branch --show-current 2>/dev/null || echo 'unknown') task={{ args[0] | default: 'general' }} dir=$(basename $(pwd)) time=$(date +%s)" > ~/.spartan/sessions/$$
Sessions older than 2 hours are stale. Active session = file modified in the last 2 hours.
{% if args[0] == "list" or args[0] == nil %}
mkdir -p ~/.spartan/sessions
echo "=== Active Claude Sessions ==="
echo ""
ACTIVE=0
STALE=0
NOW=$(date +%s)
CUTOFF=$((NOW - 7200)) # 2 hours
for f in ~/.spartan/sessions/*; do
[ -f "$f" ] || continue
MOD=$(stat -f %m "$f" 2>/dev/null || stat -c %Y "$f" 2>/dev/null || echo 0)
PID=$(basename "$f")
CONTENT=$(cat "$f" 2>/dev/null)
if [ "$MOD" -gt "$CUTOFF" ]; then
ACTIVE=$((ACTIVE + 1))
echo " [$PID] $CONTENT"
else
STALE=$((STALE + 1))
fi
done
echo ""
echo "Active: $ACTIVE | Stale: $STALE"
Show the results in a clean table:
| PID | Branch | Task | Directory |
|---|---|---|---|
| (from session files) |
Then suggest:
/spartan:sessions clean to remove stale sessions."{% elif args[0] == "clean" %}
Remove session files older than 2 hours:
NOW=$(date +%s)
CUTOFF=$((NOW - 7200))
CLEANED=0
for f in ~/.spartan/sessions/*; do
[ -f "$f" ] || continue
MOD=$(stat -f %m "$f" 2>/dev/null || stat -c %Y "$f" 2>/dev/null || echo 0)
if [ "$MOD" -lt "$CUTOFF" ]; then
rm "$f"
CLEANED=$((CLEANED + 1))
fi
done
echo "Cleaned $CLEANED stale sessions."
Then show remaining active sessions (run the list logic above).
{% elif args[0] == "ground" %}
Show the grounding context for this session:
echo "=== Session Grounding ==="
echo "Directory: $(basename $(pwd))"
echo "Branch: $(git branch --show-current 2>/dev/null || echo 'not a git repo')"
echo "Last commit: $(git log --oneline -1 2>/dev/null || echo 'none')"
# Check for active GSD project
if [ -f .planning/PROJECT.md ]; then
echo "GSD Project: active"
head -5 .planning/PROJECT.md 2>/dev/null
fi
# Check for active workstream
if [ -d .planning/workstreams ]; then
echo "Workstreams: $(ls .planning/workstreams/ 2>/dev/null | wc -l | tr -d ' ')"
fi
Show a clean summary:
You are in: [directory]
Branch: [branch]
Last commit: [message]
GSD: [active/none]
This is what gets injected into skill preambles when 3+ sessions are active.
{% else %}
Available options:
/spartan:sessions — List all active sessions (default)/spartan:sessions clean — Remove stale sessions (older than 2 hours)/spartan:sessions ground — Show grounding context for this session
{% endif %}~/.spartan/sessions/ — one file per process ID/spartan:sessions clean/spartan:* command starts with a grounding line~/.spartan/sessions/ doesn't exist, create it silently