explain-error

A command for understanding Better Auth error codes and messages, with plain-English explanations, likely causes, fixes, and code examples. Better Auth is a TypeScript authentication library, and Cloudflare D1 is a managed SQL database.

In plain words
What is it for?
Use it to diagnose documented Better Auth errors, apply configuration or code fixes, handle errors in TypeScript, and check D1-specific solutions.
Why use it?
It reduces the time spent searching documentation and guessing whether an authentication error comes from configuration, code, or the database. It also helps decide whether an error should be retried and how to show it to users.

Command

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.

agentmods
npx agentmods add commands/secondsky/claude-skills/explain-error
Clone the repo
git clone --depth 1 https://github.com/secondsky/claude-skills
Per session 11 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 649 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00011 $0.00649
Opus 5 $0.00005 $0.00324
Sonnet 5 $0.00002 $0.00130
Haiku 4.5 $0.00001 $0.00065

Measured 2d ago against content hash 8a07f7a52ec1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

explain-error 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 2d 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/commands/explain-error.md · 103 lines

How it starts

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

Explain Better Auth Error

Provide a comprehensive explanation of the given Better Auth error code or error message.

Process

  1. Accept the error from arguments (error code or full error message)
  2. Check error catalog first:
    • Load references/error-catalog.md to see if this is one of the 15 documented errors
    • If found, use catalog as primary reference
  3. Explain in plain English what the error means
  4. List common causes specific to the error
  5. Provide solutions:
    • Configuration fixes
    • Code corrections
    • Cloudflare D1-specific solutions (if applicable)
  6. Generate error handling code showing:
    • How to catch this specific error
    • User-friendly error messages
    • Whether retry is appropriate
    • TypeScript type guards if applicable
  7. Mention related errors the developer should be aware of
  8. Link to documentation:

Common Better Auth Errors

If no specific error provided, list top 5 most common errors:

  1. d1Adapter is not exported - Use drizzleAdapter instead
  2. Schema generation fails - Use Drizzle Kit, not better-auth migrate
  3. CamelCase vs snake_case mismatch - Column naming issues
  4. CORS errors - Missing credentials or origin configuration
  5. OAuth redirect URI mismatch - Callback URL configuration

Error Categories

Database Errors:

  • D1 adapter issues
  • Schema migration problems
  • Connection failures

Authentication Errors:

  • Session validation failures
  • Token expiration
  • Invalid credentials

OAuth Errors:

  • Provider configuration
  • Redirect URI mismatches
  • Scope issues

CORS/Security Errors:

  • Origin blocking
  • Cookie not sent
  • CSRF token mismatch

Example Usage

User: /better-auth:explain-error "SESSION_NOT_FOUND"

Response:
Error: SESSION_NOT_FOUND

What it means:
The session token provided is not found in the database or has expired.

Common causes:
1. Session expired (default: 7 days)
2. Session manually deleted
3. Database connection issue
4. Cookie not sent with request

Solutions:
[Detailed solutions with code examples]

Error handling code:
[Production-ready code example]

Read the full file on GitHub · 103 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. 2d ago First seen · 103 lines · 11 tokens per session scan A 8a07f7a52ec1

Subscribe to this mod's changes

explain-error is a command published in the GitHub repository secondsky/claude-skills (212 stars, last pushed 3d ago), licensed MIT. It adds 11 tokens to every session and 649 once invoked, about $0.0001 per session on Opus 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.