Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

two-factor-authentication-best-practices — Claude Code skill: 2FA

Walks an agent through adding two-factor auth to a Better Auth app: TOTP, codes by email or SMS, backup codes, trusted devices.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add better-auth/skills --skill two-factor-authentication-best-practices -a claude-code
npx skills add better-auth/skills --skill twoFactor -a claude-code
Open on GitHub

What two-factor-authentication-best-practices does

The skill hands the agent the setup order for Better Auth's twoFactor plugin: register it on the server with an issuer, add twoFactorClient() on the client, then run npx auth@latest migrate or generate and push the schema for Drizzle and Prisma. The check at the end is that a twoFactorSecret column now sits on the user table.

From there it covers four flows: TOTP with a QR code, codes sent by email or SMS, single-use backup codes, and remembering a device. Your agent gets the actual calls. twoFactor.enable wants the password, verifyTotp takes a code plus trustDevice, and the sign-in handler watches for twoFactorRedirect before a session is created.

One limit worth knowing before you plan the schema: 2FA can only be turned on for credential accounts. Social-only sign-in sits outside this flow, so decide how those users get through before you build around it.

What it helps with

  • add TOTP to an authenticator app and render the QR code
  • send one-time codes over email or SMS
  • issue backup codes so a lost phone does not lock anyone out
  • remember a device between sign-ins
  • catch twoFactorRedirect after a password sign-in and route to verification

Example prompts for the agent

  • Add 2FA to my Better Auth app with the `twoFactor` plugin: TOTP plus backup codes
  • Why is no session created after `authClient.signIn.email`? Handle `twoFactorRedirect` and add a `/2fa` page
  • Wire OTP delivery through our email helper and store codes hashed

How to install two-factor-authentication-best-practices

1Skills CLI (Vercel)

npx skills add better-auth/skills --skill two-factor-authentication-best-practices -a claude-code
npx skills add better-auth/skills --skill twoFactor -a claude-code

2Manually: put the files in place

~/.claude/skills/twoFactor/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/twoFactor/

From the same set5

The whole set →

Similar

mcp-security-audit official github Audits MCP server configurations for exposed secrets, shell injection, mutable package references, and unapproved servers. Use it before changing .mcp.json. GitHub Copilot 1,100installs arize-ai-provider-integration official arize Manage Arize AI integrations for language model providers: create connections, inspect their settings, and update or remove them. Use it when configuring models for Arize evaluators or other Arize features. GitHub Copilot 1,100installs agent-supply-chain official github Checks AI agent plugins, tools, and dependencies with SHA-256 manifests. Use it before promoting a plugin or auditing its files. GitHub Copilot 1,100installs fuzzing-dictionary trailofbits Generates and connects token dictionaries for parsers and protocols in libFuzzer or AFL++ when coverage stalls on initial checks. Claude Code CX Codex Cursor +1 5,300installs semgrep-rule-variant-creator trailofbits Ports completed Semgrep rules to selected languages and creates separate rule and test directories. Use it when you already have a rule to adapt. Claude Code CX Codex Cursor +1 5,300installs fuzzing-obstacles trailofbits Patches anti-fuzzing patterns like checksums and time-seeded PRNGs in C, C++, and Rust. Useful when fuzzers get stuck on early validation checks. Claude Code CX Codex Cursor +1 5,300installs git-guardrails-claude-code Matt Pocock This skill adds a Claude Code hook that stops risky Git commands before they run. Use it when an agent must not push or discard working-tree changes. Claude Code 499,069installs ponytail-review DietrichGebert ponytail-review reviews a change beyond the diff, checking connected code, bugs, risks, load, tests, speed, and unnecessary code. Use it for PRs and commits. Claude Code CX Codex Cursor +1 56,300installs

Questions about two-factor-authentication-best-practices

How do I install two-factor-authentication-best-practices in Claude Code?

Run npx skills add better-auth/skills --skill two-factor-authentication-best-practices -a claude-code. The skill lands at ~/.claude/skills/twoFactor/SKILL.md.

What does this skill do?

It documents adding two-factor authentication through Better Auth's twoFactor plugin: TOTP, OTP over email or SMS, backup codes, trusted devices, and the second step during sign-in.

Which accounts can enable 2FA?

Only credential accounts, meaning email and password. That restriction comes from the plugin itself, so plan the sign-in schema with it in mind.

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor