Skip to content
Back to skills

gremlin

ASecurity

Attack the user's RUNNING local app like an impatient user (double-click, rage-click, timeout + retry, resubmit after the back button) and report duplicate records with HTTP evidence. Use when the user wants to test for double submits, duplicate orders, double charges, duplicate signups/invites/emails, retry or idempotency bugs, race conditions on create endpoints, or asks things like "will my checkout break if users double-click?" or "is my payment endpoint idempotent?".

  • 2 stars
  • 0 votes
  • 1 copy
  • 9 views
  • Added November 29, 2026
developmentgobashsqlnextjsnodeexpressdjangoflaskrailsdocker

Works with

  • terminal
  • cli
  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add SHARAJ379/Gremlin --skill gremlin --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of gremlin?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for gremlin
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/sharaj379-gremlin/badge)](https://www.skillsdirectory.com/skills/sharaj379-gremlin)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: gremlin
description: Attack the user's RUNNING local app like an impatient user (double-click, rage-click, timeout + retry, resubmit after the back button) and report duplicate records with HTTP evidence. Use when the user wants to test for double submits, duplicate orders, double charges, duplicate signups/invites/emails, retry or idempotency bugs, race conditions on create endpoints, or asks things like "will my checkout break if users double-click?" or "is my payment endpoint idempotent?".
---

# Gremlin

You find state-changing endpoints in the user's code, write a plan, run the bundled engine against
the user's local app, and explain every failure. The engine makes real HTTP requests and decides
PASS/FAIL/WARN by counting records before and after each attack.

**Hard rules**
- Never state that an endpoint is safe or buggy from reading code. Verdicts come only from the engine.
- Never run against a non-local URL, and never pass `--i-know-this-is-not-production` yourself.
- Never guess credentials, and **never ask for a password, token or cookie in the chat** or write one
  into the plan. Prefer a fresh throwaway test user; otherwise use `{env:NAME}` (Step 4).
- Always show the plan and wait for the user's OK before running.

Files in this skill's directory, `${CLAUDE_SKILL_DIR}` (the folder containing this file):
`scripts/gremlin.mjs` (engine, Node 18+, no deps), `references/plan-format.md` (every plan field,
auth and CSRF recipes per stack — **read it before writing the plan**), `references/fixes.md`.

## Step 1: Can this app run locally? Stop early if not

Find the stack and start command (`package.json` scripts, `docker-compose.yml`, `Procfile`,
`manage.py`, `pyproject.toml`, README) and the port (`PORT`, `.env`, framework default).

Gremlin needs the API to run on this machine with a local/dev database. **Stop and explain** (do not
write a plan) when it can't:
- **Supabase** with only a hosted project URL (`*.supabase.co`) and no `supabase/config.toml`:
  writes go straight from the browser to Supabase. Supported only with the local stack
  (`supabase start`, API on `localhost:54321`). Offer that, or testing their own API routes if any.
- **Firebase/Firestore** without the emulator (`firebase.json` has no `emulators`): same reason.
- **Serverless-only** (Lambda/Cloud Functions with no `serverless-offline`, SAM, `vercel dev`,
  `netlify dev` or similar): no local server to attack.
- **Hosted auth with no local login** (Clerk, Auth0, Cognito, OAuth-only NextAuth): ask the user to
  sign in to the local app in a browser and put the session cookie or token in an environment
  variable (not the chat), used as `{env:NAME}`. If they can't, stop.
- **Next.js Server Actions are testable** (not a reason to stop): use `"action": "<exportName>"` in
  the plan. IDs come from the running build's `.next/server/server-reference-manifest.json`, so
  test `next build && next start` (or dev after opening the pages), and rebuild if actions changed.
  Tell the user it tests the **server**: client guards (a disabled button) are out of scope.

Say plainly what Gremlin can't test, rather than writing a plan that can't work.

If the app isn't running (`curl -s -o /dev/null -w "%{http_code}" http://localhost:<port>/`), start
it in the background if that's simple and safe; otherwise ask the user to start it.

**Use the same database engine as production.** Never swap Postgres/MySQL for SQLite to "make it run":
SQLite serializes writes, so concurrent duplicates fail with lock errors and real bugs look like
passes. If Docker isn't available, a local Postgres via `npx embedded-postgres` or a native install works.

## Step 2: Make sure it is NOT production

Check `.env*`, config and the start command. **Stop and ask** if the database or services look
real: a hosted DB URL that isn't clearly dev/test (`prod`, `production`, `live`), `sk_live_`/
`pk_live_` keys, live email/SMS credentials. Gremlin creates about 11 real records per target and
triggers real side effects (charges, emails) if the app is wired to real services. Tell the user.

## Step 3: Find risky endpoints

Search for POST/PUT/PATCH handlers (`app.post(`, `router.post(`, `export async function POST`,
`@app.post`, `@router.post`, `methods=["POST"]`, `path(` + `CreateView`, `resources :`), and
Next.js Server Actions (`"use server"` files; note each action's argument list).
Rank: 1) payments, checkout, credits; 2) orders, bookings; 3) signups, invites, team members;
4) anything that sends email/SMS or posts messages/comments; 5) other creates.
Pick the top 1-5. Note each handler's `file:line`. Read its validation schema so the body is valid.

## Step 4: Detect auth and CSRF (recipes in references/plan-format.md)

**Credentials (in this order):**
1. **Fresh throwaway test user** if the app has signup: `login.register` with
   `gremlin-{runBase}@example.test` and a made-up password. It's created per run, needs no secret, and
   gets clean state (e.g. a full wallet).
2. **Seeded demo user** documented in the repo (seed script/README): fine to use as written.
3. **Existing test account or token:** ask the user to set an environment variable in the terminal that
   will run Gremlin (e.g. `GREMLIN_TEST_PASSWORD`, `GREMLIN_TEST_TOKEN`) and put `{env:NAME}` in the
   plan. **Never ask for the value itself** or echo it. The engine reads it at run time and redacts it.

**Auth:** identify the mechanism:
- Cookie session (`express-session`, `cookie-session`, `passport-local`, Django/Flask/Rails login):
  `login` block, no `tokenPath`. Cookies are kept automatically.
- JWT/bearer (`jsonwebtoken`, `jose`, `Authorization` header in the client): `login` +
  `tokenPath` + `tokenFormat` (`Bearer {token}`, or `Token {token}` for Conduit-style APIs).
- NextAuth/Auth.js Credentials: `csrf` from `/api/auth/csrf`, form login to
  `/api/auth/callback/credentials`. OAuth-only: session cookie via `{env:NAME}` (Step 1).
- Supabase local: login against `http://localhost:54321/auth/v1/token?grant_type=password` with the
  `apikey` header (local anon key from `supabase status`).
- No login route but a dev token exists: `"headers": { "Authorization": "Bearer {env:GREMLIN_TEST_TOKEN}" }`.
- OAuth-only / hosted auth: ask the user to put the session cookie in an env variable, then
  `"Cookie": "{env:GREMLIN_SESSION_COOKIE}"`. Never ask them to paste it into the chat.

`login.register` tolerates a 4xx "already exists" on reruns. If a target
needs a parent record (comment → article), create it in `setup` and `save` its id/slug into a
variable (e.g. `{slug}`); name it with `{runBase}` so reruns don't collide. A redirect back to the
login page means the login failed; the engine detects that.

**CSRF:** search for `csurf`, `csrf-csrf`, `lusca`, `CsrfViewMiddleware`, `CSRFProtect`/`Flask-WTF`,
`protect_from_forgery`, `VerifyCsrfToken`, NextAuth. Configure the `csrf` block (where the token
comes from: cookie, header, json or html; where it goes: `header` or `bodyField`). If the app checks
`Origin`/`Referer`, add them to `headers`. Mobile/JSON APIs with bearer tokens usually need none.

## Step 5: Choose how to count

Recommended default: **filter count with a `{runId}` marker.** Put `gremlin-{runId}` in a field the
record stores (title, name, note, email local part) and filter the list on it:

```json
"request": { "method": "POST", "path": "/api/orders", "body": { "item": "gremlin-{runId}", "qty": 1 } },
"count":   { "method": "GET",  "path": "/api/orders", "filter": { "field": "item", "equals": "gremlin-{runId}" } }
```

`{runId}` is unique per attack, so existing data and earlier attacks never affect the count, and
unique fields (emails, slugs, usernames) don't collide across attacks.
- Nested list: add `itemsPath` (e.g. `"articles"`, `"data.items"`).
- Paginated list: prefer a server-side filter in `path` (`?search=gremlin-{runId}`) with
  `totalPath`, or a large page size. The engine warns if a list returns exactly 10/20/25/50/100 items.
- No usable list endpoint (server-rendered HTML, signups): `count.command` with a local DB count
  filtered on the marker. Use the project's own DB client when there's no CLI, e.g.
  `node -e "...require('@prisma/client')..."` or `node -e "...require('sqlite3')..."`.
  Local targets only. Otherwise ask before adding a dev-only list route.
  **Commands may only use `{runId}` and `{runBase}`** (the engine refuses saved values and `{env:...}`
  there, to prevent command injection): filter on a marker or the run's test user, not on a saved id.
- Check what the list returns *for the logged-in test user* (some apps hide other users' records).

If the client sends an idempotency key (search for `Idempotency-Key`, `idempotency`), set
`idempotencyHeader` to that header name. Otherwise leave it out.

**Money and other side effects:** if an action charges a wallet, decrements stock or sends credits,
add a `measures` entry with the change one intended action should cause (e.g. wallet `-10`).
A double-click that charges twice is a FAIL even if the record count looks fine.
If the app is a production build that hides errors (Next.js), set `serverLog` to the file the
server's output goes to, so a hidden 500 can be classified (lock timeout vs unique constraint).

## Step 6: Write the plan, show it, wait

Write `gremlin.plan.json` in the project root (schema: references/plan-format.md). Show it and say
what it will create and where. **Wait for the OK.** Suggest adding `gremlin-report.md` to `.gitignore`.

## Step 7: Run the engine

```bash
node "${CLAUDE_SKILL_DIR}/scripts/gremlin.mjs" --plan gremlin.plan.json --out gremlin-report.md
```

Exit 0 = no FAIL, 1 = at least one FAIL, 2 = could not run. On exit 2, the one-line message says
what to change in the plan (login failed, CSRF token not found, count path not found, ...). Fix
it and rerun; never report results from a run that exited 2. Read `gremlin-report.md` for evidence.

| Attack | What it does | Duplicate = |
|---|---|---|
| double-click | 2 identical requests at once | FAIL |
| rage-click | 5 identical requests at once | FAIL |
| timeout-retry | abort client after 150ms, resend immediately | FAIL (WARN if it answered < 150ms: no timeout happened) |
| resubmit | wait for success, send again | WARN (repeat orders may be intended) |

**Sanity-check before reporting:**
- WARN "no record counted": the request failed or the count missed it. Fix the plan; it's not a pass.
- WARN "error message hidden": a production 500 without a cause. Set `serverLog` and rerun.
- WARN "Inconclusive ... database lock/timeout": the DB was too busy to create the duplicate. Rerun
  on the production DB engine before concluding anything.
- Pagination WARN: the count is unreliable until fixed.
- PASS with "5xx" note: a unique constraint stopped the duplicate, but the user got a 500. Report it
  as a UX bug (should return the existing record or a clean 409/422), not as a duplicate.
- PASS with "repeats were rejected": read the statuses/bodies and say what protected it.

## Step 8: Explain and fix

Show the engine's table unchanged. For each FAIL:
1. **Where:** the handler's `file:line`.
2. **Why, in plain words:** e.g. "Both clicks arrive while the first is still waiting on the payment
   call. Nothing checks for an existing order with the same key, so both insert." Name the gap: no
   idempotency key, check-then-insert race, no unique constraint, key stored after the slow work.
3. **Fix:** the matching pattern from `references/fixes.md`, adapted to their stack. Fix it on the
   server; disabling the button is only an extra.
4. **Offer to apply it.** If accepted: change, restart, **rerun the same plan**, show before/after.

For a resubmit WARN, ask whether repeat submissions are intended. Finally, remind the user that test
records (marked `gremlin-...`) are in their dev database, and offer cleanup.

Files in this skill

  • SKILL.md10.5 KB
  • references/fixes.md9.1 KB
  • references/plan-format.md11 KB
  • scripts/gremlin.mjs46.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.