context-hogs · Hooks para Claude Code | Prompt Studio
    1. Claude Code
    2. Hooks
    3. context-hogs
    Claude Code · HooksPostToolUse

    context-hogs

    Ranking de los archivos que más contexto consumen.

    por Karan Bansal

    PostToolUseSessionEnd

    Licencia: MITVer original

    Instalación

    /plugin marketplace add karanb192/claude-code-hooks
    /plugin install context-hogs@claude-code-hooks

    Contenido

    # context-hogs
    
    > Per-file context-cost leaderboard: attributes every tool result's tokens to the files it loaded, so you know which files cost you the most.
    
    A `PostToolUse` hook fires after every `Read`, `Grep`, `Glob`, and `Bash` call, measures the tool result's bytes, resolves the file path(s) that result belongs to, and appends a ledger row. Tokens are estimated from bytes (~4 bytes/token) and dollars from a configurable input-token rate (hooks don't receive real token counts, so nothing is fabricated). At `SessionEnd`, or on demand via the skill, it aggregates the ledger into your repo's most token-expensive files (read count, cumulative tokens, estimated cost, plus repeat-offender flags for lockfiles, generated code, and giant utils) and renders that leaderboard.
    
    ## Install
    
    ```
    /plugin marketplace add karanb192/claude-code-hooks   # once per machine
    /plugin install context-hogs@claude-code-hooks
    ```
    
    Restart Claude Code, done. (Or from a shell: `claude plugin install context-hogs@claude-code-hooks`.)
    
    ## What it does
    
    | Event | Runs | What happens |
    |-------|------|--------------|
    | PostToolUse (`Read\|Grep\|Glob\|Bash`) | async (zero added latency) | Measures the tool result's bytes, resolves the file path(s) it belongs to, appends a ledger row. |
    | SessionEnd | sync | Aggregates the whole ledger, renders the leaderboard card via `systemMessage`, and writes a suggested CLAUDE.md ignore block for the top offenders. |
    
    `/context-hogs:leaderboard` renders this repo's context-cost leaderboard on demand.
    
    ## Configuration
    
    All optional, set via environment variables:
    
    | Variable | Default | Purpose |
    |----------|---------|---------|
    | `CONTEXT_HOGS_BYTES_PER_TOKEN` | `4` | Bytes-per-token ratio used to estimate tokens. |
    | `CONTEXT_HOGS_USD_PER_MTOK` | `3.0` | Input $/1M tokens used to estimate cost. Set to your model's current input rate. |
    | `CONTEXT_HOGS_TOP_N` | `10` | Number of files shown on the leaderboard. |
    | `CONTEXT_HOGS_LEDGER_CAP` | `50000` | Max ledger rows kept; older rows are compacted at SessionEnd. |
    
    State is stored under `~/.claude/context-hogs/<repo-key>/ledger.jsonl`.
    
    ## Data & privacy
    
    Records file paths, read counts, and byte/token estimates per repo. It makes no network calls (the script only uses `fs`, `path`, and `os`), so everything stays on your local machine.
    
    ## Uninstall
    
    ```
    /plugin uninstall context-hogs@claude-code-hooks
    ```
    

    Más en Hooks

    • Formatear al editar

      Ejecuta Prettier sobre cada archivo que Claude edita o crea.

    • Bloquear archivos .env

      Impide que Claude lea o edite archivos de secretos.

    • Aviso al terminar

      Notificación de escritorio en macOS cuando Claude termina.

    • Chequeo de tipos al editar

      Corre tsc después de editar archivos TypeScript y muestra los errores.

    • Contexto al iniciar

      Carga la rama y los últimos commits al abrir una sesión.

    • Registro de comandos

      Guarda cada comando de shell en un log para auditoría.

    Ver todo en Hooks (621) →

    Tu colección definitiva de prompts de IA. Inspírate, explora ejemplos y crea con IA.

    Hubs principales

    • Prompts
    • Imágenes
    • Videos
    • Generar Videos
    • Plantillas
    • Animaciones
    • Precios
    • Conoce
    • Afiliado

    Explorar por tipo

    • Kits de componentes
    • Etiquetas de imagen
    • Etiquetas de video
    • Webs

    Temas populares

    • Música
    • Portafolio
    • Gaming
    • Viajes
    • Nano Banana Pro

    Legal

    • Términos de uso
    • Política de privacidad
    • Política de cookies
    • Política de licencias
    • Política de reembolsos
    • Términos del programa de afiliados
    • Términos de Crowdfunding

    Magzin LLC, 800 Third Avenue Associates, New York, NY, 10022, United States

    © 2026 Prompt Studio by Magzin. Todos los derechos reservados.