context-compactor

context-compactor is a skill for Claude Code, Codex from aragaobruno/toolbelt. It costs 34 tokens per session (432 once invoked), scanned A, original, MIT.

A codebase scanner that creates a compact map of Python, JavaScript, and TypeScript files by listing their classes, functions, methods, and documentation comments.

In plain words
What is it for?
Use it to create an architectural overview of a code directory, with optional exclusions such as tests or dependency folders.
Why use it?
It helps an agent understand a large project's structure without loading every implementation detail into its working context.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/aragaobruno/toolbelt/context-compactor
Any agent
npx skills add aragaobruno/toolbelt --skill context-compactor
Clone the repo
git clone --depth 1 https://github.com/aragaobruno/toolbelt

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 context-compactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/aragaobruno/toolbelt/context-compactor.svg)](https://agentmods.dev/skills/aragaobruno/toolbelt/context-compactor)
Your own site
<a href="https://agentmods.dev/skills/aragaobruno/toolbelt/context-compactor"><img src="https://agentmods.dev/badge/skills/aragaobruno/toolbelt/context-compactor.svg" alt="Measured on agentmods" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 432 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00034 $0.00432
Opus 5 $0.00017 $0.00216
Sonnet 5 $0.00007 $0.00086
Haiku 4.5 $0.00003 $0.00043

Measured 4d ago against content hash 6df8a0c71e55, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

context-compactor 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 4d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/compactor.py, scripts/test_compactor.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

skills/context/context-compactor/SKILL.md · 49 lines

What it actually says

📦 context-compactor

Overview

Feeding raw source files into an LLM context window is expensive and introduces noise. The context-compactor recursively scans a codebase, parses files (supporting Python, JavaScript, and TypeScript), and extracts only the structural elements—classes, methods, function signatures, and docstrings—while omitting the actual body implementations.

This results in a lightweight, token-efficient structural map of your codebase that agents can use to understand the architecture without reading thousands of lines of code.

Quick Start

To scan the current directory and generate a codebase map:

uv run skills/context/context-compactor/scripts/compactor.py C:\Users\araga\.gemini\antigravity\scratch\toolbelt --output map.txt

Utility Scripts

compactor.py (CLI)

A Python utility that recursively processes directories and extracts structural code elements.

  • Arguments:
    • <directory_path> (Required)
    • --output (Required): The file path where the output will be saved.
    • --exclude (Optional): Glob patterns to exclude (e.g., *.test.js,node_modules).
  • Example:
    uv run compactor.py C:\Users\araga\.gemini\antigravity\scratch\toolbelt --output codebase_summary.txt --exclude "node_modules,*.spec.js"
    

Output Format Example

For a Python file, the compactor will extract:

File: auth.py
----------------------------------------
class Authenticator:
    """Manages user sessions and OAuth flows."""

    def __init__(self, client_id: str):
        ...

    def get_token(self, code: str) -> str:
        """Exchanges authorization code for an access token."""
        ...
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. 4d ago First seen · 49 lines · 34 tokens per session scan A 6df8a0c71e55

Subscribe to this mod's changes

context-compactor is a skill published in the GitHub repository aragaobruno/toolbelt (2 stars, last pushed 1mo ago), licensed MIT. It adds 34 tokens to every session and 432 once invoked, about $0.0002 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-31.