Redis rate limiter
Greenfield: you're directing an AI agent to build an API rate limiter as Express middleware in TypeScript, backed by Redis, enforcing per-API-key limits (e.g. 100 req/min) across a horizontally-scaled fleet. Lay out the build plan: the algorithm choice (fixed window vs. sliding window vs. token bucket), how you keep it atomic across instances, response headers, and acceptance criteria. What does a careless 'add rate limiting' prompt get wrong in a multi-instance deployment?
decide_rate_limit(instance_ids: list[str], request_ms: list[int], limit: int, window_ms: int, shared_counter: bool) → list[str][["a","b","c","a"],[0,10,20,30],3,1000,true]out["allow|2","allow|1","allow|0","deny|970"][["a","b","c","a"],[0,10,20,30],3,1000,false]out["allow|2","allow|2","allow|2","allow|1"]Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.
Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.