← ClaudeAtlas

cost-tracklisted

Report token spend per session and cumulative totals from session logs
manastalukdar/ai-devstudio · ★ 1 · AI & Automation · score 77
Install: claude install-skill manastalukdar/ai-devstudio
# Cost Tracker Report estimated token spend per development session and cumulative totals, using session file sizes and logged metadata as proxies. Works without API access. ## Usage ``` /cost-track # Summary for current + recent sessions /cost-track --all # All archived sessions /cost-track --reset # Clear cumulative cost register ``` ## Behavior ### Phase 1: Check active session ```bash if [ -f ".claude/sessions/.current-session" ] && [ -s ".claude/sessions/.current-session" ]; then ACTIVE=$(cat ".claude/sessions/.current-session") ACTIVE_SIZE=$(wc -c < "$ACTIVE" 2>/dev/null || echo 0) # Rough estimate: ~4 chars per token for session narrative ACTIVE_TOKENS=$((ACTIVE_SIZE / 4)) echo "Active session: ~${ACTIVE_TOKENS} tokens estimated" fi ``` ### Phase 2: Scan archived sessions ```bash # Collect all archived session files find .claude/sessions -name "*.md" -not -name ".current-session" | sort -r | head -20 ``` For each file, compute: - File size → divide by 4 for rough token estimate - Session name and date from filename - Number of `/skill` invocations via `grep -c "^/" <file>` ### Phase 3: Load cost register ```bash REGISTER=".claude/cache/cost-track/register.json" if [ -f "$REGISTER" ]; then CUMULATIVE=$(jq -r '.cumulative_tokens' "$REGISTER") SESSIONS_COUNTED=$(jq -r '.sessions_counted' "$REGISTER") else CUMULATIVE=0 SESSIONS_COUNTED=0 fi ``` ### Phase 4: Compute estimates and update register Apply