two-factor-authentication-best-practices

two-factor-authentication-best-practices is a skill for Claude Code from pleaseai/claude-code-plugins. It costs 69 tokens per session (1,935 once invoked), scanned A, original, MIT.

A guide for adding two-factor authentication, which asks users for a second proof of identity during sign-in, with Better Auth. It covers authenticator-app codes, codes sent by email or SMS, backup codes, trusted devices, and related sign-in flows.

In plain words
What is it for?
Use it to configure Better Auth's two-factor plugin, database changes, authenticator-app setup, one-time password codes, backup codes, trusted devices, and two-factor redirects.
Why use it?
It helps add an extra sign-in check beyond a password and avoids overlooking the server, client, database, and recovery pieces involved. It also describes the setup needed for authenticator apps and backup codes.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: installed under .agents/ (shared by several agents).

Part of the better-auth plugin — 7 skills shipped together

Good fit Use it to configure Better Auth's two-factor plugin, database changes, authenticator-app setup, one-time password codes, backup codes, trusted devices, and two-factor redirects.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/pleaseai/claude-code-plugins/two-factor-authentication-best-practices
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add pleaseai/claude-code-plugins --skill two-factor-authentication-best-practices
Clone the repo
git clone --depth 1 https://github.com/pleaseai/claude-code-plugins

Made for: Claude Code.

Or install better-auth, the plugin that ships this one along with the rest of its 7 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for two-factor-authentication-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/skills/pleaseai/claude-code-plugins/two-factor-authentication-best-practices/github.svg)](https://agentmods.dev/skills/pleaseai/claude-code-plugins/two-factor-authentication-best-practices)
Your own site
<a href="https://agentmods.dev/skills/pleaseai/claude-code-plugins/two-factor-authentication-best-practices"><img src="https://agentmods.dev/badge/skills/pleaseai/claude-code-plugins/two-factor-authentication-best-practices/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for two-factor-authentication-best-practices

Your own site · 80×15
<a href="https://agentmods.dev/skills/pleaseai/claude-code-plugins/two-factor-authentication-best-practices"><img src="https://agentmods.dev/badge/skills/pleaseai/claude-code-plugins/two-factor-authentication-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 69 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,935 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium MCP Rug Pull · line 10
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00069 $0.01935
Opus 5.5 $0.00028 $0.00774
Sonnet 5.5 $0.00014 $0.00387
Haiku 4.5 $0.00007 $0.00194

Measured 2mo ago against content hash a9d80a07fced, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

two-factor-authentication-best-practices scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/better-auth/.agents/skills/two-factor-authentication-best-practices/SKILL.md · 332 lines

How it starts

The opening of the file, as written. The whole thing — 332 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Setup

  1. Add twoFactor() plugin to server config with issuer
  2. Add twoFactorClient() plugin to client config
  3. Run npx auth@latest migrate (built-in adapter) or generate + push for Drizzle/Prisma
  4. Verify: check that twoFactorSecret column exists on user table
import { betterAuth } from "better-auth";
import { twoFactor } from "better-auth/plugins";

export const auth = betterAuth({
  appName: "My App",
  plugins: [
    twoFactor({
      issuer: "My App",
    }),
  ],
});

Client-Side Setup

import { createAuthClient } from "better-auth/client";
import { twoFactorClient } from "better-auth/client/plugins";

export const authClient = createAuthClient({
  plugins: [
    twoFactorClient({
      onTwoFactorRedirect() {
        window.location.href = "/2fa";
      },
    }),
  ],
});

Enabling 2FA for Users

Requires password verification. Returns TOTP URI (for QR code) and backup codes.

const enable2FA = async (password: string) => {
  const { data, error } = await authClient.twoFactor.enable({
    password,
  });

  if (data) {
    // data.totpURI — generate a QR code from this
    // data.backupCodes — display to user
  }
};

twoFactorEnabled is not set to true until first TOTP verification succeeds. Override with skipVerificationOnEnable: true (not recommended).

TOTP (Authenticator App)

Displaying the QR Code

import QRCode from "react-qr-code";

const TotpSetup = ({ totpURI }: { totpURI: string }) => {
  return <QRCode value={totpURI} />;
};

Verifying TOTP Codes

Accepts codes from one period before/after current time:

const verifyTotp = async (code: string) => {
  const { data, error } = await authClient.twoFactor.verifyTotp({
    code,
    trustDevice: true,
  });
};

TOTP Configuration Options

twoFactor({
  totpOptions: {
    digits: 6, // 6 or 8 digits (default: 6)
    period: 30, // Code validity period in seconds (default: 30)
  },
});

OTP (Email/SMS)

Read the full file on GitHub · 332 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago Changed a9d80a07fced
  2. 3mo ago First seen · 332 lines · 69 tokens per session scan A 90f344853d17

Subscribe to this mod's changes

two-factor-authentication-best-practices is a skill published in the GitHub repository pleaseai/claude-code-plugins (17 stars, last pushed yesterday), licensed MIT. It adds 69 tokens to every session and 1,935 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

two-factor-authentication-best-practices compared with skills from other repositories

two-factor-authentication-best-practices next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
two-factor-authentication-best-practicespleaseai/claude-code-pluginsSkill17yesterdayMITA69Claude Code
imagegenopenai/codexSkill137ktodayApache-2.0A113Codex
playwright-climicrosoft/playwrightSkill101ktodayApache-2.0A19Claude Code
browser-automationopenclaw/openclawSkill395ktodayMITA36Claude Code
systematic-debuggingobra/superpowersSkill331k3d agoMITA21Claude Code
free-llm-apismnfst/awesome-free-llm-apisSkill15ktodayCC0-1.0A113Claude Code, Codex
next-cache-components-adoptionvercel/next.jsSkill144ktodayMITA95Claude Code