dynamic-image-endpoints

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

Rules for backend endpoints that generate image or PDF bytes from request data, such as social previews, badges, and invoices.

In plain words
What is it for?
Use them when adding endpoints for dynamic previews, badges, QR codes, receipts, invoices, or other generated image responses.
Why use it?
They require repeatable output and cache versioning so rendered results are testable and updated images do not remain stale in browsers or CDNs.

Cursor rule for Cursor

Written for Cursor: installed under .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-endpoints
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-endpoints

README.md
[![agentmods](https://agentmods.dev/badge/rules/golid-ai/golid/dynamic-image-endpoints.svg)](https://agentmods.dev/rules/golid-ai/golid/dynamic-image-endpoints)
Your own site
<a href="https://agentmods.dev/rules/golid-ai/golid/dynamic-image-endpoints"><img src="https://agentmods.dev/badge/rules/golid-ai/golid/dynamic-image-endpoints.svg" alt="Measured on agentmods" height="20"></a>
Per session 37 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,184 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.1 $0.00037 $0.01184
Opus 5 $0.00018 $0.00592
Sonnet 5 $0.00007 $0.00237
Haiku 4.5 $0.00004 $0.00118

Measured 6d ago against content hash e493836bfe63, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

dynamic-image-endpoints 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 6d 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-endpoints.mdc · 139 lines

How it starts

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

Dynamic Image Endpoints

Thesis: Dynamic image endpoints must be (1) pure deterministic renderers — same input always produces identical bytes — and (2) include a renderer version constant in their ETag hash so visual changes invalidate downstream caches on deploy. Without (1), the render is slow, untestable, and depends on external runtimes; without (2), browser/CDN/conditional-GET caches keep serving the old bytes for the full max-age window after every renderer change.

Refrain: Pure function in → deterministic bytes out → version the renderer in the ETag

When this applies

  • OG/social-card preview images (/api/v1/profiles/:slug/og-image)
  • Badge/credential PNGs (e.g. Labs certifications)
  • QR code endpoints with branded chrome
  • Invoice/receipt PDF generation
  • Any endpoint that returns image bytes computed from request input

Does NOT apply to:

  • Static image assets served from frontend/public/images/ (Vite hashes filenames; no dynamic rendering)
  • User-uploaded images (no rendering; just storage proxy)
  • Avatar/thumbnail resizing (use a dedicated image-proxy library)

Rule 1: Pure renderer functions

The renderer must be a pure Go function: input struct → []byte PNG output, no I/O, no network, no browser, no embedded language runtime.

BAD: Node/browser/screenshot pipeline

// Headless Chrome screenshot: second runtime, non-deterministic pixels.
func RenderOGImage(profile *Profile) ([]byte, error) {
    return chromiumScreenshot("https://localhost/render-og?slug=" + profile.Slug)
}

GOOD: Pure Go renderer

// Pure function: same input → same bytes; testable in 50ms via `go test`.
func RenderPublicProfileOGImage(ctx context.Context, profile *PublicStudentProfile) (*PublicProfileOGImage, error) {
    img := image.NewRGBA(...)
    drawProofCardSurface(img, ...)
    drawText(img, name, ...)
    // ... pure draw calls only
    return &PublicProfileOGImage{PNG: bytes, ETag: computeETag(profile)}, nil
}

Read the full file on GitHub · 139 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. 6d ago First seen · 139 lines · 37 tokens per session scan A e493836bfe63

Subscribe to this mod's changes

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