Token导航 LogoToken导航

Agent Skill · 研究检索

prompt-token-counter(提示令牌计数器)

用于辅助提示词、系统指令、Agent 行为约束和工作流模板的整理。它适合让 Agent 规范任务边界、统一输出格式、拆分操作步骤或优化提示词可复用性。使用时需要保留真实业务约束,不要把示例当硬规则;涉及自动执行、外部工具或高风险操作时,应在提示词中明确确认步骤、权限边界和失败处理方式。

prompt-token-counter 是研究检索类 Agent Skill,可用宿主为 OpenClaw,通过ClawHub获取,权限为需要联网;许可证为 MIT-0,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 12,292。

总安装 10,392周安装 433GitHub Stars 公开资料未说明下载 3,464核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT-0
版本
1.0.11

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:prompt-token-counter(提示令牌计数器)
来源仓库:https://github.com/zhaobudaoyuema/prompt-token-counter
安装命令:
openclaw skills install prompt-token-counter
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install prompt-token-counter

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

计算 300 多个 LLM 模型的代币并估算成本。主要用途:审核 OpenClaw 工作区令牌消耗(内存、角色、技能)。

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 OpenClaw;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 openclaw skills install prompt-token-counter;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

prompt-token-counter 怎么安装?

在终端执行 openclaw skills install prompt-token-counter。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

prompt-token-counter 支持哪些 AI 工具?

公开资料标注支持 OpenClaw。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

prompt-token-counter 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

prompt-token-counter 是免费的吗?

来源标注的许可证是 MIT-0。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

prompt-token-counter 用的人多吗?

公开数据是累计安装 10,392 次,近一周安装 433 次,下载 3,464 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

prompt-token-counter 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 专注 OpenClaw 一种宿主,触发方式和使用习惯不用来回切换。
  • 许可证明确为 MIT-0,商用和分发边界好判断。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 OpenClaw,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。
  • 需要许可证清楚、并且有第三方扫描结果的团队项目。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
prompt-token-counter

提示令牌计数器 · 本页

10,392—需要联网MIT-0通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

name
prompt-token-counter
version
1.0.10
description
Count tokens and estimate costs for 300+ LLM models. Primary use: audit OpenClaw workspace token consumption (memory, persona, skills).
trigger
token count, cost estimate, prompt length, API cost, OpenClaw audit, workspace token usage, memory/persona/skills tokens, context window limit

Prompt Token Counter (toksum)

First load reminder: This skill provides the scripts CLI (toksum). Use it when the user asks to count tokens, estimate API costs, or audit OpenClaw component token consumption (memory, persona, skills).

Before Installing — Security & Privacy

  • What will be read: The audit workflow reads files under ~/.openclaw/workspace and ~/.openclaw/skills (AGENTS.md, SOUL.md, MEMORY.md, SKILL.md, etc.). Those files may contain personal data or secrets. Only install if you accept that access.
  • URL fetching: The CLI can fetch HTTP(S) URLs via -u. SKILL.md requires the agent to confirm each URL with the user before fetching. Insist the agent follow that rule; never allow automatic fetching of unknown URLs.
  • Source verification: Source: https://github.com/Zhaobudaoyuema/prompt-token-counter. Review scripts/core.py and scripts/cli.py before use. The code performs local file reads and optional HTTP GETs only; no other network calls or data exfiltration.
  • Run locally first: If unsure, run the CLI manually in an isolated environment against safe test files to verify behavior.

Primary Use: OpenClaw Token Consumption Audit

Goal: Help users identify which OpenClaw components consume tokens and how much.

1. Memory & Persona Files

These files are injected into sessions and consume tokens. Search and count them:

FilePurposeTypical Location
AGENTS.mdOperating instructions, workflow, priorities~/.openclaw/workspace/
SOUL.mdPersona, tone, values, behavioral guidelines~/.openclaw/workspace/
IDENTITY.mdName, role, goals, visual description~/.openclaw/workspace/
USER.mdUser preferences, communication style~/.openclaw/workspace/
MEMORY.mdLong-term memory, persistent facts~/.openclaw/workspace/
TOOLS.mdTool quirks, path conventions~/.openclaw/workspace/
HEARTBEAT.mdPeriodic maintenance checklist~/.openclaw/workspace/
BOOT.mdStartup ritual (when hooks enabled)~/.openclaw/workspace/
memory/YYYY-MM-DD.mdDaily memory logs~/.openclaw/workspace/memory/

Workspace path: Default ~/.openclaw/workspace; may be overridden in ~/.openclaw/openclaw.json via agent.workspace.

2. Skill Files (SKILL.md)

Skills are loaded per session. Count each SKILL.md:

LocationScope
~/.openclaw/skills/*/SKILL.mdOpenClaw managed skills
~/.openclaw/workspace/skills/*/SKILL.mdWorkspace-specific skills (override)

3. Audit Workflow

  1. Locate workspace: Resolve ~/.openclaw/workspace (or config override).
  2. Collect files: List all memory/persona files and SKILL.md paths above.
  3. Count tokens: Run python -m scripts.cli <path1> <path2> ... -m <model> -c (batch mode).
  4. Summarize: Group by category (memory, persona, skills), report total and per-file.

Example audit command (PowerShell):

$ws = "$env:USERPROFILE\.openclaw\workspace"
python -m scripts.cli -m gpt-4o -c "$ws\AGENTS.md" "$ws\SOUL.md" "$ws\USER.md" "$ws\IDENTITY.md" "$ws\MEMORY.md" "$ws\TOOLS.md"

Example audit (Bash):

WS=~/.openclaw/workspace
python -m scripts.cli -m gpt-4o -c "$WS/AGENTS.md" "$WS/SOUL.md" "$WS/USER.md" "$WS/IDENTITY.md" "$WS/MEMORY.md" "$WS/TOOLS.md"

Project Layout

prompt_token_counter/
├── SKILL.md
├── package.json                # npm package (OpenClaw skill)
├── publish_npm.py               # Publish to npm; syncs version
└── scripts/                    # Python package, CLI + examples
    ├── cli.py                  # Entry point
    ├── core.py                 # TokenCounter, estimate_cost
    ├── registry/
    │   ├── models.py           # 300+ models
    │   └── pricing.py          # Pricing data
    └── examples/               # Script examples
        ├── count_prompt.py
        ├── estimate_cost.py
        ├── batch_compare.py
        └── benchmark_token_ratio.py

Invoke: python -m scripts.cli from project root.

Version Sync (publish_npm.py)

When publishing to npm, publish_npm.py bumps the patch version and syncs it to:

  • package.json — version
  • SKILL.md — frontmatter version
  • scripts/__init__.py — __version__

Run: python publish_npm.py (after npm login).


Runtime Dependencies

  • Python 3 — required
  • tiktoken (optional) — pip install tiktoken for exact OpenAI counts

Language Rule

Respond in the user's language. Match the user's language (e.g. Chinese if they write in Chinese, English if they write in English).


URL Usage — Mandatory Agent Rule

Before using -u / --url to fetch content from any URL, you MUST:

  1. Explicitly warn the user that the CLI will make an outbound HTTP/HTTPS request to the given URL.
  2. Confirm the URL is trusted — tell the user: "Only use URLs you fully trust. Untrusted URLs may expose your IP, leak data, or be used for SSRF. Do you confirm this URL is safe?"
  3. Prefer alternatives — if the user can provide the content via -f (local file) or inline text, suggest that instead of URL fetch.
  4. Never auto-fetch — do not invoke -u without the user having explicitly provided the URL and acknowledged the risk.

If the user insists on using a URL: Proceed only after they confirm. State clearly: "I will fetch from [URL] to count tokens. Proceed?"


Model Name — Mandatory Agent Rule

Before invoking the CLI, you MUST have a concrete model name from the user.

  1. Require explicit model — -m / --model is required. Do not guess or assume; the user must provide the exact name (e.g. gpt-4o, claude-3-5-sonnet-20241022).
  2. If unclear, ask — if the user says "GPT" or "Claude" or "the latest model" without a specific name, ask: "Please specify the exact model name (e.g. gpt-4o, claude-3-5-sonnet-20241022). Run python -m scripts.cli -l to list supported models."
  3. Do not auto-pick — never substitute a model on behalf of the user without their confirmation.
  4. Validate when possible — if the model name seems ambiguous, offer -l output or confirm: "I'll use [model]. Is that correct?"

CLI Usage

Default: Read from local file(s). No segmentation. Supports multiple file paths for batch execution.

python -m scripts.cli [OPTIONS] [FILE ...]
OptionShortDescription
--model-mModel name (required unless --list-models) — Agent must obtain exact name from user; ask if unclear
--file-fRead from file (repeatable)
--url-uRead from URL (repeatable) — Agent must warn user before use; only trusted URLs
--list-models-lList supported models
--cost-cShow cost estimate
--output-tokensUse output token pricing
--currencyUSD or INR
--verbose-vDetailed output

Examples

# Multiple local files (default batch mode)
python -m scripts.cli file1.txt file2.txt -m gpt-4
python -m scripts.cli AGENTS.md SOUL.md MEMORY.md -m gpt-4o -c

# Single file with -f
python -m scripts.cli -f input.txt -m claude-3-opus -c

# Inline text (when arg is not an existing file path)
python -m scripts.cli -m gpt-4 "Hello, world!"

# List models
python -m scripts.cli -l

# Run bundled example scripts
python scripts/examples/count_prompt.py file1.txt file2.txt -m gpt-4
python scripts/examples/estimate_cost.py "Your text" gpt-4
python scripts/examples/batch_compare.py file1.txt -m gpt-4 claude-3-opus

Python API

from scripts import TokenCounter, count_tokens, estimate_cost, get_supported_models

tokens = count_tokens("Hello!", "gpt-4")
counter = TokenCounter("claude-3-opus")
tokens = counter.count_messages([
    {"role": "system", "content": "..."},
    {"role": "user", "content": "..."}
])
cost = estimate_cost(tokens, "gpt-4", input_tokens=True)

Supported Models

300+ models across 34+ providers: OpenAI, Anthropic, Google, Meta, Mistral, Cohere, xAI, DeepSeek, etc. Use python -m scripts.cli -l for full list.

  • OpenAI: exact via tiktoken
  • Others: ~85–95% approximation

Response Output — Agent Guideline

After returning token count or cost estimate results, the agent MUST:

  1. Include the project link — e.g.

> Source: prompt-token-counter

  1. Briefly explain how tokens are calculated — e.g.

> How tokens are counted: OpenAI models use tiktoken (exact). Other models use provider-specific formulas calibrated from benchmark data. For CJK-heavy text, the ratio is blended by CJK character ratio so that Chinese gets fewer chars per token.


Common Issues

IssueAction
"tiktoken is required"pip install tiktoken
UnsupportedModelErrorUse -l for valid names
Cost "NA"Model has no pricing; count still valid
User provides URLAgent must warn: outbound request, SSRF risk, only trusted URLs; confirm before -u
Model unclear / vagueAgent must ask: user to specify exact model name; offer -l to list; do not guess

When to Trigger This Skill

Activate this skill when the user:

TriggerExample phrases
Token count"How many tokens?", "Count tokens in this prompt", "Token length of X"
Cost estimate"Estimate API cost", "How much for this text?", "Cost for GPT-4"
Prompt size"Check prompt length", "Is this too long?", "Context window limit"
OpenClaw audit"How many tokens does my workspace use?", "Audit OpenClaw memory/persona/skills", "Which components consume tokens?", "Token usage of AGENTS.md / SOUL.md / skills"
Model comparison"Compare token cost across models", "Which model is cheaper?"

Also trigger when the agent needs to count tokens or estimate cost before/after generating content.


Quick Reference

ItemCommand
Invokepython -m scripts.cli
List modelspython -m scripts.cli -l
Cost-c (input) / --output-tokens (output)
Currency--currency USD or INR

平台分布

OpenClaw

98.08%
按下载量换算3,397

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills