tool-compaction

tool-compaction is a skill for Claude Code, Codex from dimetron/pi-go. It costs 61 tokens per session (1,718 once invoked), scanned A, original, MIT.

A set of rules for shrinking tool results before they are sent to an AI model, then passing those results through callbacks and duplicate-removal logic. It focuses on how tool names and output fields are matched.

In plain words
What is it for?
It helps change tool-output compaction, duplicate removal, after-tool callbacks, or tool output structures safely. It also guides investigation when reported prompt-size savings are not real.
Why use it?
Small naming or field mismatches can make the shrinking step silently do nothing or write to the wrong place. These rules make the data path agree with what each tool actually registers and returns.

Skill for Claude CodeCodex

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

Good fit It helps change tool-output compaction, duplicate removal, after-tool callbacks, or tool output structures safely. It also guides investigation when reported prompt-size savings are not real.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/dimetron/pi-go/tool-compaction
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 dimetron/pi-go --skill tool-compaction
Clone the repo
git clone --depth 1 https://github.com/dimetron/pi-go

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 tool-compaction

README.md
[![agentmods](https://agentmods.dev/badge/skills/dimetron/pi-go/tool-compaction/github.svg)](https://agentmods.dev/skills/dimetron/pi-go/tool-compaction)
Your own site
<a href="https://agentmods.dev/skills/dimetron/pi-go/tool-compaction"><img src="https://agentmods.dev/badge/skills/dimetron/pi-go/tool-compaction/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for tool-compaction

Your own site · 80×15
<a href="https://agentmods.dev/skills/dimetron/pi-go/tool-compaction"><img src="https://agentmods.dev/badge/skills/dimetron/pi-go/tool-compaction.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,718 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.
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.00061 $0.01718
Opus 5.5 $0.00024 $0.00687
Sonnet 5.5 $0.00012 $0.00344
Haiku 4.5 $0.00006 $0.00172

Measured 12d ago against content hash 1e5b81ea3787, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

tool-compaction 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 12d 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.

.pi-go/skills/tool-compaction/SKILL.md · 120 lines

How it starts

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

Tool-output compaction, the after-tool chain, and dedup

Every rule here exists because its violation was silent: nothing crashed, the pipeline simply did nothing.

Tool-output compaction: one route per tool, and write what you read

internal/tools/compactor*.go shrinks tool results before they reach the model. Seven of its nine pipelines were no-ops in production for a long time, and every cause was a silent mismatch rather than a crash. The invariants below exist so that cannot recur.

  • Route on the registered name. compactorPipelines is keyed by the name a tool actually registers — hyphens for the git tools (git-file-diff), and ripgrep for the search tool, which self-names via grepToolName and is built once by CoreTools. The tool registers grep only on a host without rg. A switch on underscore spellings is what made three git pipelines unreachable.
  • A pipeline may only write the field it read. CompactResult carries CompactWrite{Key, Value} pairs. Do not add a probe order that guesses a target field: the previous stdout → content → output → diff → result → data order wrote to the wrong key, and no tool emits output at all.
  • Keep the value's type. ADK round-trips every result through json.Marshal/json.Unmarshal (internal/typeutil/convert.go), so a []GrepMatch arrives as []any of map[string]any — never a typed slice. Cap the array; do not re-render it to a string. The TUI result summaries read the same keys (internal/tui/tool_display.go) as []any.
  • Preserve the true total. A cap sets truncated and leaves total_matches/total_files/total_entries/total_hunks as the pre-cap count, so a partial list is never read as the whole answer. truncated carries omitempty, so it is absent from a complete result — applyCompaction writes named keys unconditionally for exactly this reason.
  • Decline when there is nothing to gain. Return nil when the result would not shrink (the rtk never_worse guard). Do not cap lists that mislead when truncated: git-overview caps recent_commits but leaves the staged/unstaged/untracked lists whole, because hiding a dirty file is a correctness problem, not a saving.
  • Test against real structs. Build test payloads by marshalling the tool's actual output struct (buildProdResult), never a hand-written map. Synthetic maps carrying an output key are what kept the dead pipelines green. TestCompactor_EveryToolCompacts and TestCompactorRouting_EveryRegisteredTool are the guards; both fail if a route or field drifts.

Read the full file on GitHub · 120 lines

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. 12d ago First seen · 120 lines · 61 tokens per session scan A 1e5b81ea3787

Subscribe to this mod's changes

tool-compaction is a skill published in the GitHub repository dimetron/pi-go (232 stars, last pushed 7d ago), licensed MIT. It adds 61 tokens to every session and 1,718 once invoked, about $0.0002 per session on Opus 5.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-11-18.

Related

tool-compaction compared with skills from other repositories

tool-compaction next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
tool-compactiondimetron/pi-goSkill2327d agoMITA61Claude Code, Codex
test-fixpatriceckhart/zotSkill372yesterdayMITA17Claude Code
find-tracesaxiomhq/cliSkill607d agoMITA37Claude Code
explore-datasetaxiomhq/cliSkill607d agoMITA40Claude Code
promptkitty-assemblebaldaworks/promptkittySkill55d agoMITA78Claude Code, Codex
troubleshoot-tervaterva-sh/tervaSkill5yesterdayMITA83Claude Code, Codex
golang-lintalexastrum/sklSkill116d agoMITA100Claude Code