agentsclimarketplace

Nextauth local e2e session

Skill bokuwalily/claude-code-skills/skills/nextauth-local-e2e-session

75 battle-tested Claude Code skills from shipping 20+ apps solo — macOS, Next.js, Vercel, iOS/Expo, Cloudflare, Phaser, local AI media & more

Install
npx -y skills add bokuwalily/claude-code-skills --skill nextauth-local-e2e-session

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

next-auth(v5/JWT)+Google OAuthのみのNext.jsアプリを、本番DBに触れずローカルdevでログイン済みE2E検証したいとき。セッションCookieを自作mintし、TURSO等のDB env をfile DBに差し替えて Playwright で通す手順。

SKILL.md

3.0 KB, as published. Nobody here has run it

Procedure

  1. DB隔離: Next.js はランタイム環境変数が .env.local より優先される。起動時に上書きして本番DBを遮断する:
    TURSO_DATABASE_URL="file:/tmp/<app>-e2e.db" TURSO_AUTH_TOKEN="" \
    AUTH_SECRET="<使い捨てdev文字列>" AUTH_TRUST_HOST=true \
    npx next dev -p 3105 > /tmp/dev.log 2>&1   # run_in_background
    
    注意: TURSO_AUTH_TOKEN="" は空文字(falsy判定でfile DBに落とすコードが多い)。URL側を空文字にすると url ?? fallback を素通りして壊れる。
  2. セッションCookie mint: プロジェクト内に一時 .mjs を置き(bare import解決のため)、同じ AUTH_SECRET で:
    import { encode } from "next-auth/jwt";
    const token = await encode({
      token: { email: "...", name: "E2E", sub: "e2e" },
      secret: process.env.AUTH_SECRET,
      salt: "authjs.session-token",   // v5: salt = cookie名 (httpsなら __Secure- 接頭辞)
      maxAge: 3600,
    });
    
    Cookie名は authjs.session-token(http/localhost)。signIn callbackはセッション読取時には走らないので、Googleプロバイダ無効でも auth() は通る。
  3. Playwright: context.addCookies([{ name: "authjs.session-token", value, domain: "localhost", path: "/", httpOnly: true, sameSite: "Lax" }]) → 認証必須ページ・API が全部動く。
  4. 検証後: 一時mintスクリプト削除、pkill -f "next dev -p <port>"/tmp のDB破棄。

Pitfalls

  • Next dev overlayの[role=dialog]: dev modeはhiddenなエラーoverlay dialogをDOMに常駐させる。モーダルのdetach待ちは [aria-label*='...'] などアプリ固有セレクタで行う。[role=dialog] は永久にdetachしない。
  • page.once("dialog", ...) の残骸: 「念のためaccept」を仕掛けて発火しないと、後続テストのconfirmを横取りする。confirm検証前に page.removeAllListeners("dialog")
  • playwright未インストールのプロジェクトでは /tmpnpm i playwright した使い捨てprojectから実行(対象repoのpackage.jsonを汚さない)。ブラウザバイナリは ~/Library/Caches/ms-playwright に共有キャッシュ済みのことが多い。
  • 検証アサートの月表示等は実レンダリング文字列(例: "2026年 6月" のスペース)に合わせる。

Verification

  • curl -H "Cookie: authjs.session-token=$TOKEN" http://localhost:<port>/api/<protected> が200で実データを返す
  • /tmp/<app>-e2e.db が生成・成長している(=本番DB非接続の証拠)
  • 書き込み系フロー(保存→一覧反映)をPlaywrightで通し、スクショを /tmp に保存

Gives 0 of the 12 instructions most e2e browser skills give

Counted across 407 of the 410 authors here whose files we hold, read 2026-08-06

  • use page object model patternin 35 of 407, across 25 files
  • Snapshot to get element refsin 24 of 407, across 14 files
  • keep tests independentin 23 of 407, across 18 files
  • Interact using refs from the latest snapshotin 23 of 407, across 11 files
  • clean up test data after each testin 21 of 407, across 15 files
  • test user behavior not implementationin 20 of 407, across 14 files
  • quarantine flaky tests explicitlyin 19 of 407, across 10 files
  • wait for specific network conditionsin 18 of 407, across 8 files
  • re-snapshot after navigation or dom changesin 17 of 407, across 10 files
  • Detect running dev servers before writing test codein 17 of 407, across 7 files
  • use web-first assertionsin 17 of 407, across 14 files
  • capture screenshots or videos on test failurein 17 of 407, across 14 files

Said here and by no other author read

  • override runtime env vars to isolate the db
  • run next dev on a dedicated port
  • mint a session cookie with the same auth secret
  • name the cookie authjs.session-token
  • inject the session cookie via playwright
  • remove temporary mint script after verification

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.