workspace/skills/token-tracker/SKILL.md
Track and display token consumption and cost for every NetClaw interaction.
npx skillsauth add automateyournetwork/netclaw token-trackerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Track and display token consumption and cost for every NetClaw interaction. Serialize MCP server responses in TOON format to reduce token usage by 40-60% on tabular network data.
This skill uses the netclaw_tokens shared library (src/netclaw_tokens/):
| Module | Function | Purpose | |--------|----------|---------| | counter.py | count_tokens() | Count tokens via Anthropic API (fallback: len/4 estimate) | | counter.py | count_message_tokens() | Count tokens for full message arrays | | cost_calculator.py | calculate_cost() | Calculate USD cost with model-aware pricing | | cost_calculator.py | get_pricing() | Look up model pricing (with env var override) | | toon_serializer.py | serialize_response() | Serialize data to TOON with JSON fallback | | session_ledger.py | SessionLedger | Cumulative session tracking with per-tool breakdown | | footer.py | format_footer() | Format mandatory token/cost footer | | toon_wrapper.py | wrap_json_response() | Convert JSON responses to TOON (for community servers) |
count_tokens() or count_message_tokens()calculate_cost() with the active model (Opus/Sonnet/Haiku)session_ledger.record() with tool name, token count, cost, and TOON savingsformat_footer() to produce the mandatory token/cost display line| Variable | Required | Description |
|----------|----------|-------------|
| ANTHROPIC_API_KEY | Yes | API key for Anthropic token counting (already used by NetClaw) |
| NETCLAW_TOKEN_PRICING_OVERRIDE | No | JSON string to override default model pricing |
| Model | Input (per 1M) | Output (per 1M) | |-------|-----------------|------------------| | Claude Opus 4.6 | $5.00 | $25.00 | | Claude Sonnet 4.6 | $3.00 | $15.00 | | Claude Haiku 4.5 | $1.00 | $5.00 |
Prompt caching discount: 90% off cached input tokens.
from netclaw_tokens import count_tokens, calculate_cost, format_footer, SessionLedger
from netclaw_tokens.toon_serializer import serialize_response
# Count tokens
tc = count_tokens("show BGP peers on router R1")
# Calculate cost
cost = calculate_cost(tc.input_tokens, 382, model="claude-opus-4-6")
# Serialize MCP response in TOON format
data = [{"peer": "10.0.0.1", "state": "Established", "as": 65001}]
response = serialize_response(data)
# Track in session ledger
ledger = SessionLedger()
ledger.record("pyats_show_bgp", tc, cost, toon_savings=response.savings_tokens)
# Format footer
footer = format_footer(tc, cost, toon_savings=response.savings_tokens,
session_summary=ledger.get_summary())
# Output: Tokens: 8 in / 382 out / 390 total | Cost: $0.0096 | TOON saved: 15 tokens ($0.0001) | Session: 390 tokens ($0.01)
Token summaries are automatically included in GAIT session logs via
SessionLedger.get_gait_summary(), providing an immutable audit trail
of token consumption per session.
testing
Human-in-the-loop escalation via HumanRail — route low-confidence agent decisions, pre-destructive operation approvals, and ambiguous incident tickets to real human engineers. Human answers are verified and returned as structured output. Workers are paid via Lightning Network. Use when the agent is uncertain, when a destructive change needs explicit human sign-off beyond a ServiceNow CR, or when an ambiguous ticket requires human triage before automated handling.
testing
Manage EVE-NG node lifecycle. Use when listing nodes, checking runtime state, creating or deleting nodes, starting or stopping nodes or whole labs, verifying node details, or wiping node NVRAM back to factory defaults.
development
Manage EVE-NG labs and platform inventory. Use when listing labs, checking lab metadata, creating or deleting labs, importing or exporting lab archives, checking EVE-NG health or auth, or verifying available node images before build work.
tools
Execute live CLI commands on running EVE-NG nodes over telnet console. Use when running show commands, making live config changes, verifying protocol state, testing connectivity, checking console readiness, or interacting with IOS, Junos, VPCS, EOS, or NX-OS nodes.