AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Cost Track

skill-manastalukdar-ai-devstudio-cost-track · by manastalukdar

Report token spend per session and cumulative totals from session logs

No reviews yet
0 installs
41 views
0.0% view→install

Install

$ agentstack add skill-manastalukdar-ai-devstudio-cost-track

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-manastalukdar-ai-devstudio-cost-track)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
2mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Cost Track? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

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

if [ -f ".claude/sessions/.current-session" ] && [ -s ".claude/sessions/.current-session" ]; then
    ACTIVE=$(cat ".claude/sessions/.current-session")
    ACTIVE_SIZE=$(wc -c /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

# 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 "^/"

Phase 3: Load cost register

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 the following rate table for cost estimation (USD, approximate as of mid-2025):

| Model | Input (per 1M tokens) | Output (per 1M tokens) | |---------------|-----------------------|------------------------| | Haiku 4.5 | $0.80 | $4.00 | | Sonnet 4.6 | $3.00 | $15.00 | | Opus 4.8 | $15.00 | $75.00 |

Default: assume Sonnet 4.6, 70% input / 30% output split.

# Per-session cost estimate
TOKENS_IN=$((ACTIVE_TOKENS * 70 / 100))
TOKENS_OUT=$((ACTIVE_TOKENS * 30 / 100))
COST_USD=$(echo "scale=4; ($TOKENS_IN * 3 + $TOKENS_OUT * 15) / 1000000" | bc)

Write updated register:

jq -n --argjson cum "$((CUMULATIVE + ACTIVE_TOKENS))" \
       --argjson cnt "$((SESSIONS_COUNTED + 1))" \
  '{cumulative_tokens: $cum, sessions_counted: $cnt, last_updated: now | todate}' \
  > "$REGISTER"

Phase 5: Display report

Cost Tracker — 2026-06-04

Active session
  File size:   12,840 bytes
  Est. tokens: ~3,210
  Est. cost:   ~$0.0577  (Sonnet 4.6, 70/30 split)

Recent archived sessions (last 5)
  session-2026-06-03-feature-auth.md   ~2,800 tokens  ~$0.0504
  session-2026-06-02-bugfix-api.md     ~1,950 tokens  ~$0.0351
  session-2026-06-01-refactor.md       ~4,100 tokens  ~$0.0738

Cumulative (18 sessions tracked)
  Est. tokens: ~52,300
  Est. cost:   ~$0.94

Note: estimates are file-size proxies; actual API usage may differ.
Run /cost-track --reset to zero the cumulative register.

Token Optimization

Expected range: 80–200 tokens (all Bash, no model invocation)

Caching: Writes running totals to .claude/cache/cost-track/register.json. The register persists across sessions; only new/unprocessed session files are added to the total.

Early exit: If no sessions directory exists, prints a one-line setup message and exits.

Patterns used: Bash for system queries, early exit, caching.

Edge Cases

  • No bc available: Falls back to integer arithmetic with $((...)).
  • No session files: Reports "0 sessions tracked" and exits.
  • --reset flag: Prompts for confirmation before clearing the register, then writes zeros.
  • Very large session files: Caps display at 20 most recent; --all removes cap.

Safety

Read-only except for writing to .claude/cache/cost-track/register.json. No external network calls. No commits.

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.