AgentSkillsCN

session-status

当用户询问会话时长、已用时长、当前工作时长,或“quanto tempo”这类问题时,请选用此技能。此外,任何需要获知会话已用时长的技能或工作流程,亦可使用此功能。

SKILL.md
--- frontmatter
name: session-status
description: Use when user asks about session duration, elapsed time, how long they've been working, or "quanto tempo". Also use when any skill or workflow needs to know session elapsed time.

Session Status

Reports current Claude Code session elapsed time.

Mechanism

A SessionStart hook writes $(date +%s) to a file inside the plugin directory and exports CLAUDE_SESSION_FILE via CLAUDE_ENV_FILE. The session ID is stable across compaction, so the timestamp survives context resets. A SessionEnd hook cleans up.

Usage

Run this to get session elapsed time:

bash
start=$(cat "$CLAUDE_SESSION_FILE" 2>/dev/null)
if [ -n "$start" ]; then
  now=$(date +%s)
  elapsed=$((now - start))
  hours=$((elapsed / 3600))
  minutes=$(((elapsed % 3600) / 60))
  started=$(date -r "$start" "+%H:%M" 2>/dev/null || date -d "@$start" "+%H:%M" 2>/dev/null)
  if [ $hours -gt 0 ]; then
    echo "Session: ${hours}h ${minutes}m (started at ${started})"
  else
    echo "Session: ${minutes}m (started at ${started})"
  fi
else
  echo "Session file not found - hook may not be configured"
fi

Output Format

Display to user:

code
Session: 2h 15m (started at 14:30)

If file missing, inform: session tracking hook not configured.