Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Image Read Gate — Stop Oversized Screenshots in Context

    1

    A PreToolUse hook for the Read tool that checks image headers before Claude Code reads a screenshot. Oversized images are blocked, a smaller JPEG copy is written, and Claude is told to read the copy instead.

    $12

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Image Read Gate — Stop Oversized Screenshots in Context

    Image Read Gate — Stop Oversized Screenshots in Context

    Example session with this skill installed

    Scan the docs folder and tell me which screenshots the image gate would block before I let you read them, and check docs/retina-dashboard.png on its own.

    • Read your context and instructions
    • Compiled the image read gate
    • Generated the image

    Summary

    2 of the 3 images in docs/ are over the limits (longest side 1280 px, size 500 KB) and would be blocked. Reading all three would add about 8.7 MB to the session.

    Result

    $ python3 scripts/image_read_gate.py --scan docs
       4.3 MB   2880x1800   retina-dashboard.png
       2.3 MB   2560x1440   checkout-flow.png
    2 of 3 images exceed the limits (max side 1280 px, max 500.0 KB); reading them all would add about 8.7 MB to a session
    $ python3 scripts/image_read_gate.py --check docs/retina-dashboard.png
    BLOCK 2880x1800 4.3 MB: longest side 2880 px > 1280; file 4.3 MB > 500.0 KB
    $ python3 scripts/image_read_gate.py --check docs/settings-panel.png
    ALLOW 1024x640 4.7 KB
    
    ImageSizeVerdict
    retina-dashboard.png2880x1800, 4.3 MBBLOCK
    checkout-flow.png2560x1440, 2.3 MBBLOCK
    settings-panel.png1024x640, 4.7 KBALLOW

    When a real Read is blocked, Claude is told the path of a smaller JPEG copy (for example 1280x800, 240.3 KB) and reads that instead. The original file is never touched.

    Next steps

    1. Add the hook to .claude/settings.json using examples/settings.json as the template.
    2. Use allow_paths in .claude/image-read-gate.json for images that must stay full size.
    3. Start in warn-only mode if you want to see what it would block first.

    Note: the sample images were generated for the README; the gate judges size, not content, and the smaller copy is a JPEG.

    retina-dashboard.png

    PNG · 1536×1024

    Generated

    Example file from a real run - the skill writes it into your workspace.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    When Claude Code reads an image, the file goes into the conversation as base64 and is re-read on every later turn. One 4 MB Retina screenshot becomes about 5.7 MB of context carried through the rest of the session. Ten of them and the session is slow, expensive and near its limit, for pixels the model scales down anyway.

    Image Read Gate is a single-file PreToolUse hook that stops it before the Read happens:

    $ python3 scripts/image_read_gate.py --check docs/retina-dashboard.png
    BLOCK 2880x1800 4.3 MB: longest side 2880 px > 1280; file 4.3 MB > 500.0 KB
    $ python3 scripts/image_read_gate.py --scan docs
       4.3 MB   2880x1800   retina-dashboard.png
       2.3 MB   2560x1440   checkout-flow.png
    2 of 3 images exceed the limits (max side 1280 px, max 500.0 KB); reading them all would add about 8.7 MB to a session
    

    (Sample images generated for the README.)

    What it does

    • Reads the PNG, JPEG, GIF and WebP headers itself, so the check needs no image library and is instant
    • Blocks a Read when the longest side or the file size is over your limit (defaults: 1280 px, 500 KB)
    • Writes a smaller JPEG copy with Pillow, sips (macOS) or ImageMagick, and tells Claude the copy's path: "Read this smaller copy instead"
    • Never blocks the copy itself, reuses a copy it already made, and never touches your original file
    • Optional JSON config: limits, warn-only mode, allowed paths for images that must stay full size, cache folder, a decision log that stores file names only
    • --scan DIR shows which images in a project would be blocked and what they would add to a session; --check FILE and --resize FILE for one image

    Honest limits, stated in the README: it judges size, not content; the copy is a JPEG, so fine text can get harder to read (raise the limit or allow the path); only the Read tool is covered.

    What is inside

    • SKILL.md, README.md, LICENSE
    • scripts/image_read_gate.py
    • tests/test_gate.py (20 tests)
    • examples/settings.json and examples/image-read-gate.json

    Requirements and safety

    Python 3.8+, macOS or Linux. The check uses the standard library only; making the smaller copy needs Pillow, sips or ImageMagick. The hook makes no network calls and needs no credentials.

    License

    Personal, non-transferable license for your own projects, including commercial work. No resale or redistribution.

    Only covers the Read tool. JPEG conversion may impact fine text clarity. Requires local installation of Pillow, sips, or ImageMagick.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 5 days ago

    Requires

    Python 3.8+
    macOS

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Environment Variables
    Listed5 days ago

    What's inside

    Frequently Asked Questions

    A Read puts the whole image into the conversation as base64, and it is re-read on every later turn. One 4 MB screenshot becomes about 5.7 MB of context. The gate stops that before the Read happens.

    Claude is told the path of a smaller JPEG copy (made with Pillow, sips or ImageMagick) and reads that instead. Your original file is never touched, and the copy itself is never blocked.

    Yes. An optional JSON config sets the limits (defaults 1280 px and 500 KB), warn-only mode, allowed paths for images that must stay full size, the cache folder, and a decision log that stores file names only.

    It is a Claude Code hook for the Read tool, registered with a hook entry in .claude/settings.json (see examples/settings.json). The package follows the SKILL.md format, but the hook itself is built for Claude Code.

    It judges size, not content. The copy is a JPEG, so fine text can get harder to read (raise the limit or allow the path). Only the Read tool is covered. It needs Python 3.8+ on macOS or Linux.

    New in LLM Ops