commit bb896ebcde4346bc55de2d99404af2624d178c0f Author: Zhongwei Li Date: Sat Nov 29 18:01:07 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..131fb4e --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "auth-skills", + "description": "Create and update auth layer for JavaScript/TypeScript projects", + "version": "0.0.0-2025.11.28", + "author": { + "name": "Alex Yang", + "email": "alex@better-auth.com" + }, + "skills": [ + "./skills/create-auth" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..60ca3a2 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# auth-skills + +Create and update auth layer for JavaScript/TypeScript projects diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..786b970 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,48 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:better-auth/skills:auth-skills", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "19df054d5b60bfacc8c06f79920aca7ebc099350", + "treeHash": "d0ee2b033129e137d45eb9d8c9bd7c6d4e41fb445c73321ed8f1bf4713af7b5a", + "generatedAt": "2025-11-28T10:14:15.609023Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "auth-skills", + "description": "Create and update auth layer for JavaScript/TypeScript projects" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "d1100c356b80611ae451ec7859bbf9cb1aa975548d0f5b0ac47b3f332c1ccf5f" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "dd94f6a357ac29926309d6d220addcd4443c2797cdeefb278fc1f4350cb65fd0" + }, + { + "path": "skills/create-auth/reference.md", + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "path": "skills/create-auth/SKILL.md", + "sha256": "d4b339157d4cf533bb128aa723c1edb7a5577e9511633801ff81fb597655c1fc" + } + ], + "dirSha256": "d0ee2b033129e137d45eb9d8c9bd7c6d4e41fb445c73321ed8f1bf4713af7b5a" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/create-auth/SKILL.md b/skills/create-auth/SKILL.md new file mode 100644 index 0000000..9bb4928 --- /dev/null +++ b/skills/create-auth/SKILL.md @@ -0,0 +1,81 @@ +--- +name: Create Auth Skill +description: A skill to create auth service for new applications. +--- + +# Create auth layer for your TypeScript/JavaScript applications + +## Overview + +A user could ask you to create authentication and authorization layers for their TypeScript/JavaScript applications. + +## Decision Tree: Choosing Your Approach + +``` +User task -> Do we start from a empty project? + ├─ Yes → Create a new project with authentication scaffolding + │ ├─ Choose web framework: React, Next.js, Express, etc. + │ ├─ Select database: PostgreSQL, MongoDB, etc. + │ ├─ Set up auth using @better-auth/cli + │ └─ Customize auth flows as per user requirements, like OAuth, JWT, Organization, Admin... + │ + └─ No → Is the existing project already have authentication? + ├─ Yes → Review existing auth implementation + │ ├─ Identify gaps or improvements needed + │ ├─ Read document for missing features from `better-auth` + │ └─ Test and validate the updated auth flows + │ + └─ No → Analyze the existing project structure + ├─ Choose appropriate auth strategy + ├─ Integrate `better-auth` into the existing codebase + └─ Implement and test the new authentication flows +``` + +## Example: Next.js app with Better Auth + +You can read [templates/nextjs](https://github.com/better-auth/examples/tree/main/nextjs-mcp) +to see a complete example of a Next.js app integrated with Better Auth. + +In this example, you can see the most two essential files, auth.ts and auth-client.ts. + +```ts +import { betterAuth } from 'better-auth' +import Database from 'better-sqlite3' + +export const auth = betterAuth({ + database: new Database('./auth.db'), + baseURL: 'http://localhost:3000', + plugins: [], + emailAndPassword: { + enabled: true + } +}) +``` + +```ts +import { createAuthClient } from "better-auth/react"; + +export const authClient = createAuthClient(); +``` + +In this example, it doesn't include any plugins, but you can easily add plugins by importing them from +`better-auth/plugins` and adding them to the `plugins` array in the `betterAuth` configuration. + +Also you will need to update auth client to make sure client-side plugins are included. + +You can refer to the [plugins](https://www.better-auth.com/docs/concepts/plugins) for more details on how +to set up and customize your authentication flows. + +## Dependencies + +To use better-auth, install these dependencies only if they aren't already present in package.json: + +```bash +npm install better-auth +``` + +## Advanced features + +**@better-auth/cli**: See [cli](https://www.better-auth.com/docs/concepts/cli) for details on how to use the CLI tool. +**Examples**: See [examples](https://github.com/better-auth/examples) for complete example projects using better-auth, +including astro, browser-extension, next.js, nuxt, svelte and tanstack. diff --git a/skills/create-auth/reference.md b/skills/create-auth/reference.md new file mode 100644 index 0000000..e69de29