dynamic-image-http

dynamic-image-http is a cursor rule for Cursor from golid-ai/golid. It costs 33 tokens per session (820 once invoked), scanned A, original, MIT.

A set of rules for HTTP endpoints that dynamically render image files, covering caching, rendering time limits, response sizes, and content-type handling. HTTP endpoints are URLs that return data to clients.

In plain words
What is it for?
Use it when adding a backend endpoint that returns generated PNG, badge, or PDF image bytes.
Why use it?
It prevents image requests from doing unbounded CPU work, returning oversized responses, or being cached incorrectly. It also protects missing or private resources from leaking information through cached responses.

Cursor rule for Cursor

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 rules/golid-ai/golid/dynamic-image-http
Clone the repo
git clone --depth 1 https://github.com/golid-ai/golid

Made for: Cursor.

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 dynamic-image-http

README.md
[![agentmods](https://agentmods.dev/badge/rules/golid-ai/golid/dynamic-image-http.svg)](https://agentmods.dev/rules/golid-ai/golid/dynamic-image-http)
Your own site
<a href="https://agentmods.dev/rules/golid-ai/golid/dynamic-image-http"><img src="https://agentmods.dev/badge/rules/golid-ai/golid/dynamic-image-http.svg" alt="Measured on agentmods" height="20"></a>
Per session 33 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 820 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.00033 $0.00820
Opus 5 $0.00016 $0.00410
Sonnet 5 $0.00007 $0.00164
Haiku 4.5 $0.00003 $0.00082

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

Security

Grade A, and why

dynamic-image-http 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.

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.

.cursor/rules/dynamic-image-http.mdc · 97 lines

How it starts

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

Dynamic Image HTTP

Thesis: HTTP-facing dynamic image endpoints need explicit cache posture, render budgets, and byte caps so clients/CDNs behave predictably without unbounded work or stale conditional-GET surprises.

Rule 3: Cache headers per response

Different paths emit different cache headers. Never use the same Cache-Control for all responses — it creates cache oracles for disabled or missing resources.

Response Cache-Control
200 image/png (success) public, max-age=300, stale-while-revalidate=3600
304 Not Modified (ETag match) inherits success headers
404 Not Found (any miss case) no-store
500 Internal Server Error no-store

The miss-case no-store is critical for privacy when the endpoint resolves auth/visibility state — a max-age 404 would let an attacker confirm a slug's existence via response time after the cache expires.

Also set X-Content-Type-Options: nosniff on success responses so clients don't sniff the bytes as something other than PNG.

Rule 4: Per-request render budget

Image rendering is CPU-bound and unbounded by default (a huge name

  • long skills + many fields can take seconds). Always wrap the render in a context.WithTimeout.
const RenderBudget = 750 * time.Millisecond

func Handler(c echo.Context) error {
    ctx, cancel := context.WithTimeout(c.Request().Context(), RenderBudget)
    defer cancel()
    img, err := RenderImage(ctx, profile)
    // ...
}

func RenderImage(ctx context.Context, profile *Profile) (*Image, error) {
    // Check ctx.Err() before each expensive step (gradient, text, encode)
    if err := ctx.Err(); err != nil { return nil, err }
    drawGradient(img)
    drawText(...)
    encodePNG(img)
    return result, nil
}

A render that exceeds the budget returns 500 with no-store so a transient slow render doesn't poison the cache.

Rule 5: Max encoded bytes ceiling

Define an explicit MaxBytes constant and reject renders that exceed it. Unfurlers have their own caps (Slack 5MB, LinkedIn 5MB, Twitter 5MB, Facebook 8MB) but you want to fail fast on a runaway render before you hit the wire.

Read the full file on GitHub · 97 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. 4d ago First seen · 97 lines · 33 tokens per session scan A c16d12f16a1c

Subscribe to this mod's changes

dynamic-image-http is a cursor rule published in the GitHub repository golid-ai/golid (40 stars, last pushed 2mo ago), licensed MIT. It adds 33 tokens to every session and 820 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-30.