/loxihart-engineering:hardening-client-side-keysfrom loxihart-engineering
Removes provider API keys from browser / client-side tools by putting a fail-closed edge proxy (Cloudflare Worker) in front of the LLM or API call, then rewiring the tool to call the proxy instead of the provider. Use when the user mentions: API key in the browser, client-side key, key in the frontend bundle, secret in client code, de-key a tool, harden the client-side-key tools, browser calls the Anthropic / OpenAI / Google API directly, anthropic-dangerous-direct-browser-access, BYOK hardening, move keys server-side, server-side proxy for an LLM call, Cloudflare Worker proxy, Turnstile gate on an API, harden a single-file HTML tool, stop shipping secrets to the client, keys pasted in a browser modal. NOT for rotating a leaked credential (use managing-credential-lifecycle) or building a full app from scratch (use kyle-vibe-coding).
Ships in loxihart-engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Move provider API keys out of the browser and behind a fail-closed edge proxy, then rewire the tool to call the proxy. Production-seed: the proxy in templates/worker/ is TypeScript-strict, fail-closed, and ships with 12 passing unit tests.
Use when — a browser/HTML tool embeds a provider key, calls a provider API directly from the client (fetch("https://api.anthropic.com/...")), sets anthropic-dangerous-direct-browser-access, or is BYOK and you want the key off the client. "Harden the client-side-key tools", "the browser is holding my OpenAI key", "de-key this HTML app".
Do NOT use when — rotating a leaked credential (that's managing-credential-lifecycle); building a new app from scratch (kyle-vibe-coding); or the "key" is a publishable/anon key designed to be public (Supabase anon, Stripe publishable, PostHog project key) — those belong client-side and moving them proxies nothing. A service_role, secret, or provider API key never belongs in the client.
The only correct fix is a fail-closed server-side proxy. Two traps to refuse: (1) an open proxy holding your keys is an uncapped wallet — worse than BYOK; (2) a static bearer token shipped to a public page is extractable — security theater. Pick the auth mode by public-vs-private. Keep a paid core (image/3D/video generation) BYOK if proxying would put its per-call cost on the operator's bill — flag that, don't silently absorb it.
Who calls the proxy?
├─ A PUBLIC browser tool (anyone can load the page)
│ → Turnstile mode: the browser proves human+origin, no reusable secret shipped
│ + origin allowlist + model allowlist + max_tokens cap + body cap + per-IP rate + daily spend cap
├─ A PRIVATE tool (you / a known set of people)
│ → Cloudflare Access in front of the Worker (real identity gate, session cookie not a static secret)
└─ A SERVER-TO-SERVER caller only (no browser)
→ Bearer token (FF_PROXY_TOKEN). NEVER embed this in client HTML.
| Option | Verdict |
|---|---|
| A. Open proxy holding your keys | ❌ Uncapped wallet; anyone spends your key. Worse than BYOK. |
| B. Static bearer token in the browser | ❌ Extractable from any public page. Theater. |
| C. Fail-closed edge proxy | ✅ Auth (Turnstile / Access / bearer) + origin lock + model allowlist + max_tokens cap + body-size cap + per-IP rate limit + global daily spend cap + upstream timeout + no secret logging. |
Model the boundaries before writing code: browser → proxy → provider. The browser holds no provider key; the proxy holds keys as Worker secrets and is the only thing that talks to providers.
grep -nE "api\.(anthropic|openai)\.com|generativelanguage|<keyVarNames>|dangerous-direct-browser-access" tool.html. Note every call site and every retired model string.templates/worker/ — it is fail-closed by construction. Set ALLOWED_MODELS in src/lib.ts to current IDs; delete retired ones (this doubles as the model-deprecation fix).fetch to ${PROXY_BASE}/v1/<provider>, delete provider keys + auth headers, add the Turnstile token in the body (_turnstile), and make provider availability depend on PROXY_BASE, not on browser keys. Remove the now-dead key inputs. Full before/after recipe in references/rewiring-browser-tools.md.<script> blocks, node --check).npm test and npx tsc --noEmit both green before hand-off.PROXY_BASE + Turnstile sitekey in the tool, ALLOWED_ORIGINS + KV id in wrangler.toml, wrangler secret put the provider keys + TURNSTILE_SECRET, then wrangler deploy. You (the operator) run deploy — the skill never holds cloud creds.templates/worker/ is the drop-in. Controls, all on by default:
503. Never runs open.403.src/lib.ts) — unknown/retired model → 400. Single source of truth for the model-deprecation fix.max_tokens cap, body-size cap, per-IP rate limit, global daily spend cap (KV) → 429/413.502. No secret or user-content logging.wrangler secret put), never in code, wrangler.toml, or git.Pure logic is factored into src/lib.ts and covered by test/lib.test.ts (runs under plain Vitest, no Workers runtime needed).
.dev.vars is gitignored; .dev.vars.example carries placeholders.wrangler.toml, source, or a committed .env.SHOULD trigger
SHOULD NOT trigger
managing-credential-lifecycle (credential lifecycle, not a proxy build).npm test + tsc --noEmit green; inline JS syntax-checks.references/auth-mode-decision.md (opens in a new tab)references/rewiring-browser-tools.md (opens in a new tab)templates/worker/README.md (opens in a new tab)templates/worker/package.json (opens in a new tab)templates/worker/src/index.ts (opens in a new tab)templates/worker/src/lib.ts (opens in a new tab)templates/worker/test/lib.test.ts (opens in a new tab)templates/worker/tsconfig.json (opens in a new tab)templates/worker/wrangler.toml (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
22 skills in this plugin
/administering-supabaseManages Supabase database operations for FlashFusion's production stack — schema design, Row Level Security policies, migrations, Edge Functions, and debugging. Active project: flashnframe-app (etctmappdhpjuwptdbeb). Use when the user mentions: Supabase, RLS, row level security, migration, schema, database, table, Edge Function, auth, policies, Postgres, supabase query, database admin, add a column, create a table, why is my query blocked, or any task involving the Supabase project or database structure.
/auditing-logicAudits code for logical errors before they become bugs — control flow gaps, data contract violations, schema/type drift, business logic inconsistencies, and silent failure paths. Produces a severity-rated issue list with a one-line diagnosis and one-line fix per finding. Use this skill whenever code is pasted with a review request, or when the user says "audit this", "check the logic", "does this make sense", "any issues with this", "logic audit", "what's wrong here", "review this function", "is this correct", or hands you any code file and wants a critical eye. Even if the user does not say "logic" — if code is present and they want feedback, use this skill. Also triggers on: "find the bug", "something feels off", "is this right", "sanity check this", "does this hold", "validate my logic", "code review", "PR review", "review this PR".
npx claudepluginhub krosebrook/loxihart-skills --plugin loxihart-engineering