惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
Microsoft Azure Blog
Microsoft Azure Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog
Y
Y Combinator Blog
博客园_首页
有赞技术团队
有赞技术团队
博客园 - Franky
腾讯CDC
G
Google Developers Blog
Recent Announcements
Recent Announcements
博客园 - 【当耐特】
D
Docker
The GitHub Blog
The GitHub Blog
MyScale Blog
MyScale Blog
H
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
A
About on SuperTechFans
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
V
V2EX
U
Unit 42
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学

Show HN

Show HN: AI agents for UK GDAD PCF roles and their skills The Two Pillars: Mixer Mode and Meta-Software in the Reorganization of Software Work After AI GitHub - JaiCode08/teleport-env What 1,000+ Harness Experiments Taught Me About Self-Improving Agents Show HN: Liiists, a Markdown-first, iOS and CLI list app SwiperTab – Get this Extension for 🦊 Firefox (en-US) GitHub - kouhxp/fftext: Summarize, explain, fact-check, or translate any text, URL, or file. No GPU. No cloud. One command GitHub - sweetpad-dev/sweetpad: Develop Swift/iOS projects using VSCode GitHub - dogmaticdev/IRON: IRON a.k.a. Intermediate Representation Object Notation is a Interpreter/Database that is used to create Programming Languages. GitHub - sjhalani7/vaen: Package your AI coding harness into a portable .agent file, and share it across repos, teams, & the community without ever having to copy-paste instructions, skills, MCP config, or secrets. Show HN: Gandalf the Grader Show HN: Citadeld – replay any CI failure locally from a single file GitHub - tdortman/cuSBF: High-Performance GPU Super Bloom Filter coral-ai/claude-code-token-xray at main · Coral-Bricks-AI/coral-ai GitHub - ulyssestenn/funes: Funes is a Git-based framework for LLM-managed knowledge work: an AI Librarian ingests raw sources, builds an interlinked Markdown knowledge base, and uses it to produce cited reports, analyses, and other outputs. GitHub - ThatXliner/gah: Git Add Hunk, built for agents to use GitHub - harmont-dev/harmont-cli: Command-line client for the Harmont CI platform GitHub - brooksmcmillin/mcp-authflow: OAuth 2.0 Authorization Server framework for MCP servers GitHub - javaid-codes/audit-supply-chain-agents GitHub - amorey/gochan: A small library of common channel architectures for Go, inspired by Rust GitHub - arifozgun/OpenGem: Free, Open-Source AI API Gateway with Gemini, OpenAI & Anthropic Compatibility in 1 file GitHub - Pranesh950/BioPetals: 🌸 Run BIOxAI models at home, BitTorrent-style. Fine-tuning and inference up to 10x faster than offloading GitHub - cnguyen14/bounty-doctor: Diagnose a GitHub bounty issue before you waste hours: detects honeypot scam repos, AI-bot attempt swarms, and stale contests. Show HN: CoreMCP – MCP Server for On-Prem DBs Show HN: KittyHTML – Render HTML/CSS as an inline image in your terminal GitHub - bingud/filemat: Web-based file manager Show HN: TruthLens – Free multi-signal deepfake image detector GitHub - apexlocal-jz/claude-usage-tray: Windows system-tray app showing your Claude Code rate-limit usage at a glance. Zero deps, ~300 lines of PowerShell. Cross-IDE (works regardless of VS Code, Cursor, plain terminal). Release v0.1.2.1 · kouhxp/yapsnap GitHub - noopolis/moltnet: Self-hostable chat network for AI agents. Pre-built bridges for Claude Code, Codex, and the Claws. Rooms, DMs, history. No Slack bots, no Matrix, no glue code.
GitHub - samjoch/tok: Claude Tokens Counter
samjoch · 2026-06-02 · via Show HN

Exact Claude token counter for the terminal. Reuses your local Claude Code login from the macOS Keychain — no ANTHROPIC_API_KEY required — and calls Anthropic's official count_tokens endpoint, so the number matches what Claude actually bills.

Build

cargo build --release
# binary at target/release/tok  (optionally: cp target/release/tok ~/.local/bin/)

Requires that Claude Code is installed and you've logged in at least once (claude). The OAuth token is read from the Keychain entry Claude Code-credentials.

Interactive mode (default)

Run with no input to open a Claude-Code-style field with a live count:

  • Type or paste your prompt — the token count and estimated input cost update as you edit (debounced).
  • Ctrl+V — smart paste: attaches an image if the clipboard holds one, otherwise inserts text. (Plain ⌘V text paste also works.)
  • Pasted images appear inline as [Image 1], [Image 2], … just like Claude Code. The placeholder is display-only — the image itself is counted as an image block, the [Image N] text is not.
  • Ctrl+X — drop the last attached image · Ctrl+L — clear everything
  • Esc / Ctrl+C — quit

Pipe / scripting mode

Any text, file, or image argument switches to a single count-and-print:

tok "Hello, world!"              # -> 16 tokens · ≈ $0.000240 input
echo "from a pipe" | tok          # reads stdin
tok -q "just the number"          # -> 11   (integer only, for scripts)
tok --file prompt.txt             # count a file's contents
tok "describe this" -i shot.png   # text + image (repeat -i for more)
tok -m claude-haiku-4-5 "hi"      # price reflects the chosen model

The cost shown is the input cost (what it takes to send this prompt once) at the model's per-token input price — count_tokens doesn't generate output, so there's no output cost to include. Prices are approximate, matched by model family (opus/sonnet/haiku).

Options

flag meaning
-f, --file <PATH> read prompt text from a file
-i, --image <PATH> attach an image (png/jpg/gif/webp), repeatable
-m, --model <ID> model to count against (counts are identical across Claude models)
-q, --quiet print only the integer
--interactive force the field even when input is piped

How it works

tok reads the claudeAiOauth.accessToken (scope user:inference) from the Keychain and POSTs your text/images to https://api.anthropic.com/v1/messages/count_tokens with the anthropic-beta: oauth-2025-04-20 header. It only sends content for counting; no completion is generated and nothing is billed for tokens.

If you see a 401, your login expired — run claude once to refresh it.