tokf-filter

tokf-filter is a skill for Claude Code, Codex from mpecan/tokf. It costs 59 tokens per session (10,383 once invoked), scanned A, original, MIT.

A guide for writing tokf filters, TOML configuration files that shorten command output before it reaches an AI model.

In plain words
What is it for?
Use it to create or modify filters for matching, replacing, and transforming command output.
Why use it?
It helps keep command results within context limits and defines where filters live and how their processing steps run.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to create or modify filters for matching, replacing, and transforming command output.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mpecan/tokf/tokf-filter
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mpecan/tokf --skill tokf-filter
Clone the repo
git clone --depth 1 https://github.com/mpecan/tokf

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for tokf-filter

README.md
[![agentmods](https://agentmods.dev/badge/skills/mpecan/tokf/tokf-filter.svg)](https://agentmods.dev/skills/mpecan/tokf/tokf-filter)
Your own site
<a href="https://agentmods.dev/skills/mpecan/tokf/tokf-filter"><img src="https://agentmods.dev/badge/skills/mpecan/tokf/tokf-filter.svg" alt="Measured on agentmods" height="20"></a>
Per session 59 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 10,383 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Rogue Agent · line 3
    Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
    Fix: Remove any persistence mechanisms (cron jobs, startup scripts, state files). Skills should not maintain state across sessions without explicit user consent.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00059 $0.10383
Opus 5 $0.00030 $0.05192
Sonnet 5 $0.00012 $0.02077
Haiku 4.5 $0.00006 $0.01038

Measured 8d ago against content hash 0f260c608a0e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

tokf-filter scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

crates/tokf-cli/skills/tokf-filter/SKILL.md · 1,038 lines

How it starts

The opening of the file, as written. The whole thing — 1,038 lines — stays where its author put it; the contents beside it link to each section on GitHub.

tokf Filter Authoring

You are an expert at writing tokf filter files. tokf is a config-driven CLI that compresses command output before it reaches an LLM context. Filters are TOML files that define how to process a command's output.

When the user asks you to create or modify a filter, follow this guide exactly. Produce valid, idiomatic TOML that matches the schema described below.


Section 1 — What a Filter File Is

A filter file is a TOML file that describes:

  • Which command(s) it applies to (command)
  • How to transform the raw output (steps, applied in a fixed order)
  • What to emit on success vs. failure

Filters live in three places, searched in priority order:

  1. .tokf/filters/ — project-local (repo-level overrides)
  2. ~/.config/tokf/filters/ — user-level overrides
  3. Built-in library (embedded in the tokf binary)

First match wins. Use tokf which "cargo test" to see which filter would activate for a given command.


Section 2 — Processing Order

Steps execute in this fixed order — do not rearrange them:

  1. match_output — whole-output substring checks; if matched, short-circuits the entire pipeline and emits immediately
  2. [[replace]] — per-line regex transforms applied to every line, in array order
  3. strip_ansi / trim_lines — per-line cleanup (ANSI stripping, whitespace trimming)
  4. skip / keep — line-level filtering (drop or retain lines by regex)
  5. dedup / dedup_window — collapse duplicate consecutive lines
  6. lua_script — Luau escape hatch; runs after dedup, before JSON/section/parse
  7. [json] — JSON extraction via JSONPath; when configured, replaces section/parse/chunk
  8. [[section]] OR [parse] — structured extraction (these are mutually exclusive; section is a state machine, parse is a declarative grouper). Skipped when [json] is configured.
  9. [[chunk]] — block-based structured extraction with per-block aggregation, grouping, and tree output (runs on raw output, alongside sections). Skipped when [json] is configured.
  10. Exit-code branch[on_success] or [on_failure] depending on exit code
  11. [fallback] — if neither on_success nor on_failure produced output
  12. strip_empty_lines / collapse_empty_lines — post-processing cleanup on the final output

Read the full file on GitHub · 1,038 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 1,038 lines · 59 tokens per session scan A 0f260c608a0e

Subscribe to this mod's changes

tokf-filter is a skill published in the GitHub repository mpecan/tokf (196 stars, last pushed today), licensed MIT. It adds 59 tokens to every session and 10,383 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.