Estimates the token cost of agent skills and their linked resources
Project description
skillcost
Estimates the token cost of agent skills and their linked resources.
Given a target file (typically a SKILL.md), skillcost counts tokens and crawls all linked files
and URLs to produce three cost figures:
| Metric | Description |
|---|---|
| Resident | Tokens loaded on every prompt, just because the skill is installed. |
| Baseline | Tokens loaded when the skill is invoked — the skill file itself. |
| Maximum | Tokens loaded if the agent follows every link in the skill file. |
This also works on CLAUDE.md or any other plain-text UTF-8 file.
Installation
Requires Python 3.12+.
# Using pip
pip install skillcost
# Or, using uv
uv tool install skillcost
Usage
skillcost <path/to/file>
Output defaults to human-readable text. Pass --json or --yaml for machine-readable output.
skillcost SKILL.md
skillcost --json SKILL.md
skillcost --yaml SKILL.md
Example output
Token Cost Report
=================
Resident : 97
Baseline : 1,940
Maximum : 18,390
Files (24)
/path/to/reference/conventions.md 926
/path/to/reference/utilities.md 1,751
...
Links
Local links : 17
HTTP links : 0
Token counting
Token counts are computed using OpenAI's tiktoken library
with the cl100k_base encoding.
How links are counted
skillcost recognizes standard Markdown links in .md files:
[text](relative/path)— a local link; followed recursively and counted toward the maximum cost only.[text](https://...)— an HTTP link; fetched once and counted toward the maximum cost. If the response is HTML (text/htmlorapplication/xhtml+xml), it is converted to Markdown via markdownify before tokenizing; other content types are tokenized as-is. The fetched content is not re-parsed for further links. ``
Caveats on the maximum
The maximum is an upper bound on what an agent could pull in, not what it typically will. Real invocations are almost always lower. A few things to keep in mind:
- It assumes every link is followed. Agents usually read only the subset relevant to the task at hand, so actual usage is often much lower than the maximum.
- HTTP links are fetched once, not crawled. HTML responses are converted to Markdown before tokenizing, which approximates what an agent would actually read. Other content types (JSON, plain text, etc.) are tokenized as-is, so their counts may overstate the human-readable cost.
- Network-dependent and time-sensitive. HTTP fetches can fail (counted as 0) or return different content over time, so the maximum is not reproducible across runs.
- Non-
.mdfiles are read but not parsed. Their full contents are tokenized; any links inside them are not followed. - Cycles are handled. Each file and URL is counted at most once per run.
- Anchors (
#section) are stripped before resolving local paths; the whole file is counted. - The tokenizer is
cl100k_base. Counts are an approximation for Claude models, which use a different tokenizer — expect small differences in practice.
Contributing
See CONTRIBUTING.md.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file skillcost-1.1.0.tar.gz.
File metadata
- Download URL: skillcost-1.1.0.tar.gz
- Upload date:
- Size: 56.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b78a5253b4cd5e4e0dad37da2413e825069155d13f8baed2b38fe2941d920af
|
|
| MD5 |
5bd40ac5c1b941e40f7d16cb07af1f1a
|
|
| BLAKE2b-256 |
3896f45aab6e69eeab2ec0289b0490d3df090742370cf71a364c6a492e6c092b
|
File details
Details for the file skillcost-1.1.0-py3-none-any.whl.
File metadata
- Download URL: skillcost-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0df5446b201101b0189291d7f359a8d1828add60f3f5e7bf2c5b024c610b9739
|
|
| MD5 |
ffb86f88d9248aad2d57e0c02aa2569b
|
|
| BLAKE2b-256 |
3611fd56b1a1eb61e7b896058d16a1d3f7d67166109db698c1a88d24c1c77945
|