compute-token-stats-rust-ultra
Ultra-fast token+cost computation for Codex + Claude SSE logs (Rust) plus Python anchor/fast comparisons; includes build+run+benchmark guide.
Best use case
compute-token-stats-rust-ultra is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Ultra-fast token+cost computation for Codex + Claude SSE logs (Rust) plus Python anchor/fast comparisons; includes build+run+benchmark guide.
Teams using compute-token-stats-rust-ultra should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/compute-token-stats-rust-ultra/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How compute-token-stats-rust-ultra Compares
| Feature / Agent | compute-token-stats-rust-ultra | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Ultra-fast token+cost computation for Codex + Claude SSE logs (Rust) plus Python anchor/fast comparisons; includes build+run+benchmark guide.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Compute Token Stats (Rust Ultra)
*[Created by Codex: 019beb87-b904-7a81-a7c9-5b5d5575d2f7 2026-01-23]*
*[Edited by Claude: 9d1228e9-aabe-4ab3-9b9c-c0c1d1f64ebc 2026-01-27]*
## ⚠️ CRITICAL: Agent Instructions
**If the user asked you to load this skill, you MUST use it for token cost computation.**
1. **ALWAYS use the Rust binaries** - they are ultra-fast and purpose-built for this task
2. **NEVER write custom Python** to parse tokens - the Rust tool already does this
3. If you think you need Python, **STOP and ask the user first** - 99% of the time the answer is NO
4. **These binaries are PIPE-ONLY** - they read from stdin, not files directly
### ⚠️ NEVER RUN STANDALONE - WILL HANG!
```bash
# WRONG - will hang waiting for stdin forever!
/tmp/.claude/skills/compute-token-stats-rust-ultra/rust/target/release/token_costs
# CORRECT - always pipe data to it
cat file.jsonl | /tmp/.claude/skills/compute-token-stats-rust-ultra/rust/target/release/token_costs
```
### Filtering by SID
To compute tokens for specific sessions, filter first then pipe:
```bash
# Filter by single SID
grep '"sid":"abc123"' ~/centralized-logs/claude/sse_lines.jsonl | \
/tmp/.claude/skills/compute-token-stats-rust-ultra/rust/target/release/claude_token_costs
# Filter by multiple SIDs (use grep -F with file)
grep -F -f /tmp/sids.txt ~/centralized-logs/codex/sse_lines.jsonl | \
/tmp/.claude/skills/compute-token-stats-rust-ultra/rust/target/release/token_costs
```
---
Compute token totals + estimated costs from massive JSONL SSE logs:
- Codex: `~/centralized-logs/codex/sse_lines.jsonl`
- Claude: `~/centralized-logs/claude/sse_lines.jsonl`
This skill includes:
- **Rust Ultra** (streaming, byte-scan, no JSON DOM): `rust/` → `token_costs` + `claude_token_costs`
- **Python anchor** (ground truth): `python/run_compute_token_costs_anchor.py` → runs `~/swe/token-computation/compute_token_costs.py`
- **Python fast** (byte-scan): `python/compute_{codex,claude}_token_costs_fast_pipe.py`
## Build (Rust Ultra)
```bash
cd /tmp/.claude/skills/compute-token-stats-rust-ultra/rust && \
cargo build --release --bins
```
## Run (Rust Ultra)
Codex:
```bash
cat ~/centralized-logs/codex/sse_lines.jsonl | \
/tmp/.claude/skills/compute-token-stats-rust-ultra/rust/target/release/token_costs
```
Claude:
```bash
cat ~/centralized-logs/claude/sse_lines.jsonl | \
/tmp/.claude/skills/compute-token-stats-rust-ultra/rust/target/release/claude_token_costs
```
## Run (Python anchor / ground truth)
Generate a pricing snapshot (recommended; makes runs reproducible):
```bash
python /Users/sotola/swe/token-computation/pull_pricing.py \
--providers openai,anthropic --timeout 20 --snapshot-dir ~/centralized-logs/pull-pricing/snapshots
```
Then run:
```bash
python /tmp/.claude/skills/compute-token-stats-rust-ultra/python/run_compute_token_costs_anchor.py \
--codex ~/centralized-logs/codex/sse_lines.jsonl \
--claude ~/centralized-logs/claude/sse_lines.jsonl \
--pricing-snapshot ~/centralized-logs/pull-pricing/snapshots/<pick-one>.json
```
## Quick benchmark + cost diff (%)
This compares **Rust Ultra** (streaming stdin) vs **Python anchor** on the same datasets and prints:
- seconds
- lines/sec (Python uses file line count / wall time)
- cost diff (%)
```bash
python /tmp/.claude/skills/compute-token-stats-rust-ultra/python/bench_rust_vs_anchor.py
```
## Notes on “unknown” Codex sessions
When `turn.session_configured` is missing for some `sid` (log truncation / invalid state machine), per-`sid` model attribution is unknowable.
- The **anchor** (`compute_token_costs.py`) prices Codex totals with a single detected `codex.model`.
- Rust Ultra keeps per-model attribution when possible; for `(unknown)` it prices using the detected pricing model to stay consistent with the anchor.Related Skills
azure-identity-rust
Azure Identity SDK for Rust authentication. Use for DeveloperToolsCredential, ManagedIdentityCredential, ClientSecretCredential, and token-based authentication.
ultrathink
Use /ultrathink <TASK_DESCRIPTION> to launch a Coordinator Agent that directs four specialist sub-agents—Architect, Research, Coder, and Tester—to analyze, design, implement, and validate your codi...
rust-learner
Rust 学习与生态追踪专家。处理新版本特性、crate 更新、最佳实践演进、RFC、每周新闻等问题。触发词:latest version, what's new, Rust 版本, 新特性, update, upgrade, rfc, 每周新闻, 学习, 教程
token-efficiency
Minimize token consumption when reading files and gathering context
azure-storage-blob-rust
Azure Blob Storage SDK for Rust. Use for uploading, downloading, and managing blobs and containers.
azure-keyvault-secrets-rust
Azure Key Vault Secrets SDK for Rust. Use for storing and retrieving secrets, passwords, and API keys. Triggers: "keyvault secrets rust", "SecretClient rust", "get secret rust", "set secret rust".
azure-keyvault-keys-rust
Azure Key Vault Keys SDK for Rust. Use for creating, managing, and using cryptographic keys. Triggers: "keyvault keys rust", "KeyClient rust", "create key rust", "encrypt rust", "sign rust".
azure-keyvault-certificates-rust
Azure Key Vault Certificates SDK for Rust. Use for creating, importing, and managing certificates.
tauri2-react-rust
Guides development of cross-platform desktop apps with Tauri 2, TypeScript, React, and Rust. Use when building Tauri apps, implementing IPC, designing Rust backend or TypeScript/React frontend, when researching or cloning a website (open site, snapshot elements), when verifying local dev or built frontend in browser, or when the user mentions Tauri, Tauri 2, Rust backend, React frontend, desktop app architecture, invoke/commands, cross-platform, 调研网站, 验证效果, agent-browser.
systems-programming-rust-project
You are a Rust project architecture expert specializing in scaffolding production-ready Rust applications. Generate complete project structures with cargo tooling, proper module organization, testing
rust
Write production-quality Rust code following industry best practices and idiomatic patterns. Use for any Rust coding task including applications, libraries, refactoring, debugging, or code review — with particular expertise in cross-platform GUI development.
rust-router
CRITICAL: Use for ALL Rust questions including errors, design, and coding. HIGHEST PRIORITY for: 比较, 对比, compare, vs, versus, 区别, difference, 最佳实践, best practice, tokio vs, async-std vs, 比较 tokio, 比较 async, Triggers on: Rust, cargo, rustc, crate, Cargo.toml, 意图分析, 问题分析, 语义分析, analyze intent, question analysis, compile error, borrow error, lifetime error, ownership error, type error, trait error, value moved, cannot borrow, does not live long enough, mismatched types, not satisfied, E0382, E0597, E0277, E0308, E0499, E0502, E0596, async, await, Send, Sync, tokio, concurrency, error handling, 编译错误, compile error, 所有权, ownership, 借用, borrow, 生命周期, lifetime, 类型错误, type error, 异步, async, 并发, concurrency, 错误处理, error handling, 问题, problem, question, 怎么用, how to use, 如何, how to, 为什么, why, 什么是, what is, 帮我写, help me write, 实现, implement, 解释, explain