ctxfire
See what every coding agent loads, why it loads, and what that repeated context could cost.
ctxfire is a local, telemetry-free static analyzer for multi-agent context
graphs. It connects agent definitions to repository instructions, rules, and
skills; multiplies the estimated input by each agent's schedule; and keeps every
assumption visible.
implementer [codex@1]
context candidates: 3 files, 18120 exact bytes/fire
estimate: 3810 tokens/fire × 8/day = 30480 tokens/day
reviewer [claude-code@1]
context candidates: 4 files, 22644 exact bytes/fire
estimate: 4725 tokens/fire × 8/day = 37800 tokens/day
TOTAL estimated tokens/day: 68280
This is not a runtime meter or an invoice calculator. File sizes are exact; tokens, conditional activation, cache behavior, schedules, and API-equivalent prices are estimates recorded in every report.
Why another context-cost tool?
Most repository analyzers ask, “How large is this codebase?” Runtime meters ask,
“What did this one session consume?” ctxfire asks a different question:
What is the transitive instruction surface of each agent, and what happens when the team loads it repeatedly every day?
The unit of analysis is agent → loading rule → context file → schedule, not a
flat repository walk.
Quickstart
Python 3.11+ and Git are the only requirements.
pipx install git+https://github.com/korovin-aa97/ctxfire.git@v0.1.0
ctxfire --version
cp ctxfire.example.toml ctxfire.toml
ctxfire scan
Or run without a persistent install:
uvx --from git+https://github.com/korovin-aa97/ctxfire.git@v0.1.0 ctxfire scan
Start from ctxfire.example.toml:
schema_version = "1"
[project]
name = "my-agent-team"
root = "."
bytes_per_token = 4.0
tokenizer = "byte-estimate"
model = "unspecified"
price_date = "unspecified"
cache_assumption = "no-cache-credit"
conditional_activation_rate = 0.25
[[agents]]
name = "implementer"
adapter = "codex@1"
working_directory = "."
fires_per_day = 8
include = ["docs/product-rules.md"]
conditional = ["docs/playbooks/**/*.md"]
usd_per_million_input_tokens is optional. Add it only with a model and a
dated price you have verified. ctxfire deliberately ships no silently aging
vendor price table.
Commands
# Human report
ctxfire scan --config ctxfire.toml
# Stable schema 1.0 snapshot
ctxfire scan --format json --output before.json
# Why is each edge present?
ctxfire explain --agent implementer
ctxfire explain --file AGENTS.md
# Attribute change between snapshots
ctxfire diff before.json after.json
# CI: exit 2 only when a budget is exceeded
ctxfire check --max-tokens-per-day 75000
# GitHub-compatible SARIF
ctxfire check --max-tokens-per-day 75000 --format sarif --output ctxfire.sarif
Exit codes are stable: 0 success/pass, 1 invalid input or operational error,
and 2 a valid scan that exceeded a check budget.
Exact versus estimated
| Field | Kind | Meaning |
|---|---|---|
| relative path, file presence, byte size | Exact | Facts from the local working tree |
| adapter and inclusion reason | Declared model | Versioned loading semantics used for the graph |
| tokens | Estimated | ceil(bytes / bytes_per_token) by default, or an opt-in local tokenizer count |
| conditional activation | Estimated | User-provided rate from 0 to 1 |
| fires/day | Assumption | Planning input; ctxfire is not a scheduler |
| USD/day | Estimated equivalence | Dated input-token price × estimated tokens; not a bill |
| cache | Assumption | Stated in the report; v0.1 does not observe cache hits |
The default estimator never reads file contents. This makes it reproducible and privacy-safe, but less accurate than a model-specific tokenizer—especially for non-English text and code-heavy files.
For an opt-in local tokenizer:
pipx install 'ctxfire[tokenizers]'
Then set tokenizer = "tiktoken:cl100k_base" (or another explicit tiktoken
encoding). The report records the installed tokenizer version and changes
discovery.content_access to matched-file-content-local. Matched bytes are
read only in memory; they are never printed, stored, or uploaded.
Supported adapters
| Adapter | Always-on context | Conditional candidates |
|---|---|---|
explicit@1 |
include patterns |
conditional patterns |
agents-md@1 |
ancestor AGENTS.md chain for working_directory |
configured patterns |
codex@1 |
precedence-selected ancestor instruction chain, under a declared byte cap | ancestor .agents/skills/*/SKILL.md bodies |
claude-code@1 |
ancestor project memory and conservative project rules | descendant memory and project skill bodies |
Adapters are conservative static models, not claims that every candidate is
loaded on every invocation. Details, source links, and known uncertainty are in
docs/ADAPTER_SPEC.md.
Git-aware and private by default
- Uses
git ls-files --cached --others --exclude-standardat a Git top-level. - Includes tracked files and non-ignored untracked files; ignored build output does not silently inflate the graph.
- Probes only known exact engine instruction paths and exact configured paths
outside that universe, so an ignored
CLAUDE.local.mdis still counted and clearly warned without opening arbitrary ignored trees. - Skips symlinks rather than following them outside the repository.
- Skips submodule gitlinks and missing/non-regular paths with a warning.
- Emits repository-relative paths, never an absolute workstation path.
- Default byte mode reads file metadata only. The optional tokenizer reads only matched files locally; neither mode makes network calls, emits telemetry, uploads content, or invokes a model.
For non-Git directories, a clearly reported conservative filesystem fallback is
used. See docs/PRIVACY.md and
docs/DISCOVERY.md.
CI example
- name: Enforce agent context budget
run: |
pipx install git+https://github.com/korovin-aa97/ctxfire.git@v0.1.0
ctxfire check --max-tokens-per-day 75000 \
--format sarif --output ctxfire.sarif
Pin a release tag or commit in CI. ctxfire diff also lets reviewers see
whether a context-cost increase came from a new file, a removed file, or a size
change.
Current limitations
- The default byte-ratio estimator is intentionally approximate. The optional tiktoken backend is more repeatable for a named encoding but still does not prove which tokenizer a hosted agent runtime used.
- Claude rule frontmatter is not parsed by the v0.1 adapter. Rules are counted
as always-on by default; set
claude_rules_activation = "conditional"only when that is a justified project-wide approximation. - User-level/global engine instructions are outside the project root and are intentionally not scanned.
- Imports referenced inside Markdown are not inferred. Add them explicitly.
- Submodule contents and symlink targets are not traversed.
- Subscription quotas, tool output, conversation history, cached-token billing, output tokens, and runtime prompt construction are outside scope.
Development
python -m venv .venv
. .venv/bin/activate
python -m pip install -e '.[dev]'
ruff check .
mypy src
pytest
python -m build
The report contract is public API. Schema changes require a new schema version, fixture updates, and a changelog entry.
See the deterministic before/after demo for a small, inspectable
diff walkthrough.
Questions about bills, privacy, shared files, rules, symlinks, or prices are answered in the FAQ.
The default package has no runtime dependencies; the optional tokenizer stack and its licenses are recorded in the dependency review.
Project status
v0.1.0 is an intentionally small first release. It was exercised against 18
unrelated public repositories; the dated methodology and results live in
docs/VALIDATION.md. Contributions are welcome—see
CONTRIBUTING.md and the extension guide.
Built from operating a mixed Claude/Codex production fleet. The analyzer is a clean, generic extraction: no private fleet configuration or telemetry is included.
MIT © 2026 Alexander Korovin.
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 ctxfire-0.1.0.tar.gz.
File metadata
- Download URL: ctxfire-0.1.0.tar.gz
- Upload date:
- Size: 805.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
364ad39babc78a3dbef6c13ecff90bf4a0087183f595eec2ba7ee7a48dc1aea9
|
|
| MD5 |
4e08d5aad267d3419dcf57bb53d046a5
|
|
| BLAKE2b-256 |
d960f368c56bdb7aaad6d96c33d8359af5e14d2d637f1224cda4af87f111cd8f
|
Provenance
The following attestation bundles were made for ctxfire-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on korovin-aa97/ctxfire
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ctxfire-0.1.0.tar.gz -
Subject digest:
364ad39babc78a3dbef6c13ecff90bf4a0087183f595eec2ba7ee7a48dc1aea9 - Sigstore transparency entry: 2643050998
- Sigstore integration time:
-
Permalink:
korovin-aa97/ctxfire@928d11516cf85ee85e18ca6574144eae6e2c3756 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/korovin-aa97
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@928d11516cf85ee85e18ca6574144eae6e2c3756 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ctxfire-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ctxfire-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d064442755ba8afa80b9294c1d18fa60893a0a1eb5cf4503f48910381c75572
|
|
| MD5 |
b0963b7834173f8f6726b239a2ebd4a1
|
|
| BLAKE2b-256 |
ed8c314d5dd3f811004b9e8cc75aac4402eeebda4c00cd19e61bf46e7fbbc06d
|
Provenance
The following attestation bundles were made for ctxfire-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on korovin-aa97/ctxfire
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ctxfire-0.1.0-py3-none-any.whl -
Subject digest:
1d064442755ba8afa80b9294c1d18fa60893a0a1eb5cf4503f48910381c75572 - Sigstore transparency entry: 2643051041
- Sigstore integration time:
-
Permalink:
korovin-aa97/ctxfire@928d11516cf85ee85e18ca6574144eae6e2c3756 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/korovin-aa97
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@928d11516cf85ee85e18ca6574144eae6e2c3756 -
Trigger Event:
release
-
Statement type: