A comprehensive guide and skill for implementing secure multi-factor authentication using the Better Auth framework and its twoFactor plugin.
The fastest way to install a skill directly from the registry.
npx clawhub@latest install twofactor
Copy the skill folder to one of these locations
~/.openclaw/skills/ <project>/skills/ Priority: Workspace > Local > Bundled
Copy this prompt to OpenClaw to install it automatically.
Help me install twofactor using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).
Get the raw skill files in a ZIP archive.
This skill provides the technical foundation for integrating two-factor authentication (2FA) into applications powered by Better Auth. It covers the full lifecycle of identity verification, from initial server-side configuration to client-side redirection and verification UI logic. By leveraging this implementation via Openclaw Skills, developers can deploy industry-standard security measures including TOTP authenticator support and fallback OTP methods.
The framework prioritizes security by ensuring that 2FA is only considered active once a user successfully verifies their first code, preventing lockout scenarios caused by misconfiguration. It also manages complex states like temporary 2FA session cookies and trusted device persistence, allowing for a balance between high security and user convenience.
To begin using this skill, install the core Better Auth packages and configure your server. First, run the migration tool to update your database:
npx @better-auth/cli migrate
Next, register the plugin in your authentication configuration:
import { betterAuth } from "better-auth";
import { twoFactor } from "better-auth/plugins";
export const auth = betterAuth({
plugins: [twoFactor({ issuer: "YourAppName" })]
});
The implementation manages several key data points to ensure secure authentication flows. Openclaw Skills recommends reviewing the following metadata structure:
| Property | Description | Storage Type |
|---|---|---|
twoFactorEnabled |
Indicates if the user has completed 2FA setup. | Boolean |
totpSecret |
The secret key used for generating TOTP codes. | Encrypted String |
backupCodes |
A list of single-use recovery strings. | Encrypted Array |
trustedDevices |
Records of verified devices and their expiry. | JSON/Table |
otpCode |
The current active one-time password. | Plain/Hashed/Encrypted |
Loading
A structured framework enabling autonomous agents to transition from reactive responses to proactive, productive building and shipping.

A productivity framework that transforms autonomous agent idle time into structured sessions for building, researching, and shipping code.

A sophisticated academic analysis tool that generates both deep technical reports and concise logical summaries for any scientific paper.

A lightweight, zero-dependency Node.js HTTP client for making resilient API requests with automatic retries and graceful error handling.

A self-improvement skill that extracts learnings from conversations and permanently encodes them into agent definitions to ensure mistakes are never repeated.

Reflect is a self-improvement skill that analyzes conversations to extract learnings and permanently encodes them into agent definitions.








































