better-auth-add-plugin
Add a better-auth plugin to an existing project. Configures server and client plugins with proper imports.
Interactive Vitest setup wizard for Cloudflare Workers testing. Configures @cloudflare/vitest-pool-workers, mocks bindings, and creates example tests.
$ npx -y skills add secondsky/claude-skills --agent claude-codeHow it fires
How this command gets triggered: by you, by Claude, or both.
/workers-test-setupContext preview
What this command does when you run it.
Interactive Vitest setup wizard for Cloudflare Workers testing. Configures @cloudflare/vitest-pool-workers, mocks bindings, and creates example tests.
name: cloudflare-workers:test-setup description: Interactive Vitest setup wizard for Cloudflare Workers testing. Configures @cloudflare/vitest-pool-workers, mocks bindings, and creates example tests. allowed-tools: - Read - Write - Bash - AskUserQuestion - Grep - Glob
Set up comprehensive testing for Cloudflare Workers using Vitest and @cloudflare/vitest-pool-workers.
Read the project to understand its current state:
1. Check if `package.json` exists 2. Check if `vitest.config.ts` or `vitest.config.js` exists 3. Check if `wrangler.jsonc` or `wrangler.toml` exists 4. Detect bindings used in the Worker (D1, KV, R2, DO, Queues, AI) 5. Check if any tests already exist (`**/*.test.ts`, `**/*.spec.ts`)
Store findings for later phases.
Use AskUserQuestion to gather preferences:
**Question 1**: "What type of tests do you want to set up?"
**Question 2**: "Which bindings do you need to mock?"
**Question 3**: "Do you want code coverage reporting?"
Before proceeding, validate:
1. **Node.js/Bun installed**: Run `node --version` or `bun --version`
2. **package.json exists**:
3. **Wrangler configured**:
4. **No existing vitest.config**:
**Error Handling**: Abort on first validation failure. Do not proceed if prerequisites aren't met.
Determine package manager (prefer bun, then npm):
# Check which package manager to use if command -v bun &> /dev/null; then PM="bun" elif command -v npm &> /dev/null; then PM="npm" else echo "Error: No package manager found" exit 1 fi
Install required packages:
**Core testing dependencies**:
$PM add -D vitest@latest $PM add -D @cloudflare/vitest-pool-workers@latest $PM add -D @cloudflare/workers-types@latest
**If coverage enabled**:
$PM add -D @vitest/coverage-v8@latest
**Binding-specific mocks** (based on user selection):
Create `vitest.config.ts` with appropriate configuration:
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';
export default defineWorkersConfig({
test: {
poolOptions: {
workers: {
wrangler: { configPath: './wrangler.jsonc' },
},
},
{{COVERAGE_CONFIG}}
},
});**If coverage enabled with thresholds**:
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
thresholds: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},**If coverage enabled without thresholds**:
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
},Based on user's test type preference, create example test(s):
**If unit tests or both**: Create `test/unit/example.test.ts`:
import { describe, it, expect } from 'vitest';
import { Env } from '../src/index';
describe('Example Unit Test', () => {
it('should pass basic assertion', () => {
expect(true).toBe(true);
});
it('should test Worker logic', () => {
// Example: Test a pure function from your Worker
const result = someFunction('input');
expect(result).toBe('expected output');
});
});**If integration tests or both**: Create `test/integration/worker.test.ts`:
import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
import { describe, it, expect } from 'vitest';
import worker from '../../src/index';
describe('Worker Integration Test', () => {
it('should respond to HTTP requests', async () => {
const request = new Request('http://example.com/');
const ctx = createExecutionContext();
const response = await worker.fetch(request, env, ctx);
await waitOnExecutionContext(ctx);
expect(response.status).toBe(200);
const text = await response.text();
expect(text).toBeDefined();
});
{{BINDING_TESTS}}
});**Binding-specific test examples** (based on selections):
**D1**:
it('should query D1 database', async () => {
const result = await env.DB.prepare('SELECT 1 as value').first();
expect(result).toEqual({ value: 1 });
});**KV**:
it('should read/write to KV', async () => {
await env.KV.put('test-key', 'test-value');
const value = await env.KV.get('test-key');
expect(value).toBe('test-value');
});**R2**:
it('should upload to R2', async () => {
await env.BUCKET.put('test.txt', 'Hello World');
const object = await env.BUCKET.get('test.txt');
expect(await object?.text()).toBe('Hello World');
});###
145 production-ready skills for Claude Code CLI 🔌 Platform / Harness Support These plugins ship as Claude Code marketplace plugins (.claude-plugin/ manifests) and Codex CLI plugins (.codex-plugin/ manifests).
Repo: secondsky/claude-skills
Add a better-auth plugin to an existing project. Configures server and client plugins with proper imports.
Interactive setup wizard for better-auth authentication. Guides through database, framework, OAuth providers, and plugin configuration.
Explain Better Auth error codes and provide solutions with code examples
Display Better Auth available authentication providers and their configuration