Pseudocode Logic
ASecurityThis is a per-key token bucket (`src/limits/middleware.ts` + `src/limits/bucket.ts`). ```text rateLimit(req) key = req["x-api-key"] header, else "anonymous" cost = GET → 1, else → 3 allow(key, cost) ? yes → pass request through no → 429 "slow down" allow(key, cost) bucket = buckets[key], or {tokens: 20, updatedAt: now} if new elapsed = now - bucket.updatedAt bucket.tokens = min(20, bucket.tokens + elapsed * 5/sec) # refill bucket.updatedAt = now if bucket.tokens < cost save bucket return ...
- 17 stars
- 0 votes
- 0 copies
- 0 views
- Added September 25, 2026
Works with
Security analysis
100/100Pro scans all 3 files and shows the line behind each finding
npx -y skills add bendrucker/claude --skill pseudocode-logic --agent claude-codeAre you the author of Pseudocode Logic?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/bendrucker-pseudocode-logic)This is a per-key token bucket (`src/limits/middleware.ts` + `src/limits/bucket.ts`).
```text
rateLimit(req)
key = req["x-api-key"] header, else "anonymous"
cost = GET → 1, else → 3
allow(key, cost) ?
yes → pass request through
no → 429 "slow down"
allow(key, cost)
bucket = buckets[key], or {tokens: 20, updatedAt: now} if new
elapsed = now - bucket.updatedAt
bucket.tokens = min(20, bucket.tokens + elapsed * 5/sec) # refill
bucket.updatedAt = now
if bucket.tokens < cost
save bucket
return false # denied, tokens unchanged
bucket.tokens -= cost
save bucket
return true # allowed, tokens spent
```
Key numbers: capacity **20 tokens**, refill **5/sec**, GET costs **1**, everything else costs **3**. Buckets are keyed by `x-api-key` (or the shared `"anonymous"` bucket if absent) and live in an in-memory `Map`, so limits reset on process restart and aren't shared across instances.
Files in this skill
- sonnet-plain.md
- sonnet-skill.md
Attribution
Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.