Skip to content

Commit 1f4df15

Browse files
committed
add skills
1 parent 0e7def2 commit 1f4df15

425 files changed

Lines changed: 67772 additions & 18 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

create-agentic-app/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

create-agentic-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-agentic-app",
3-
"version": "1.1.47",
3+
"version": "1.1.48",
44
"description": "Scaffold a new agentic AI application with Next.js, Better Auth, and AI SDK",
55
"type": "module",
66
"bin": {

create-agentic-app/scripts/sync-templates.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ async function copyWithExclusions(src, dest) {
6161
if (entry.isDirectory()) {
6262
await copyWithExclusions(srcPath, destPath);
6363
} else {
64-
await fs.copy(srcPath, destPath, { overwrite: true });
64+
// dereference: true follows symlinks (e.g. .claude/skills/* → .agents/skills/*)
65+
// and copies the target as real files. Without this, the copy would try to
66+
// recreate the symlink, which fails on Windows without admin/Developer Mode.
67+
await fs.copy(srcPath, destPath, { overwrite: true, dereference: true });
6568
}
6669
}
6770
}
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
---
2+
name: better-auth-best-practices
3+
description: Configure Better Auth server and client, set up database adapters, manage sessions, add plugins, and handle environment variables. Use when users mention Better Auth, betterauth, auth.ts, or need to set up TypeScript authentication with email/password, OAuth, or plugin configuration.
4+
---
5+
6+
# Better Auth Integration Guide
7+
8+
**Always consult [better-auth.com/docs](https://better-auth.com/docs) for code examples and latest API.**
9+
10+
---
11+
12+
## Setup Workflow
13+
14+
1. Install: `npm install better-auth`
15+
2. Set env vars: `BETTER_AUTH_SECRET` and `BETTER_AUTH_URL`
16+
3. Create `auth.ts` with database + config
17+
4. Create route handler for your framework
18+
5. Run `npx @better-auth/cli@latest migrate`
19+
6. Verify: call `GET /api/auth/ok` — should return `{ status: "ok" }`
20+
21+
---
22+
23+
## Quick Reference
24+
25+
### Environment Variables
26+
- `BETTER_AUTH_SECRET` - Encryption secret (min 32 chars). Generate: `openssl rand -base64 32`
27+
- `BETTER_AUTH_URL` - Base URL (e.g., `https://example.com`)
28+
29+
Only define `baseURL`/`secret` in config if env vars are NOT set.
30+
31+
### File Location
32+
CLI looks for `auth.ts` in: `./`, `./lib`, `./utils`, or under `./src`. Use `--config` for custom path.
33+
34+
### CLI Commands
35+
- `npx @better-auth/cli@latest migrate` - Apply schema (built-in adapter)
36+
- `npx @better-auth/cli@latest generate` - Generate schema for Prisma/Drizzle
37+
- `npx @better-auth/cli mcp --cursor` - Add MCP to AI tools
38+
39+
**Re-run after adding/changing plugins.**
40+
41+
---
42+
43+
## Core Config Options
44+
45+
| Option | Notes |
46+
|--------|-------|
47+
| `appName` | Optional display name |
48+
| `baseURL` | Only if `BETTER_AUTH_URL` not set |
49+
| `basePath` | Default `/api/auth`. Set `/` for root. |
50+
| `secret` | Only if `BETTER_AUTH_SECRET` not set |
51+
| `database` | Required for most features. See adapters docs. |
52+
| `secondaryStorage` | Redis/KV for sessions & rate limits |
53+
| `emailAndPassword` | `{ enabled: true }` to activate |
54+
| `socialProviders` | `{ google: { clientId, clientSecret }, ... }` |
55+
| `plugins` | Array of plugins |
56+
| `trustedOrigins` | CSRF whitelist |
57+
58+
---
59+
60+
## Database
61+
62+
**Direct connections:** Pass `pg.Pool`, `mysql2` pool, `better-sqlite3`, or `bun:sqlite` instance.
63+
64+
**ORM adapters:** Import from `better-auth/adapters/drizzle`, `better-auth/adapters/prisma`, `better-auth/adapters/mongodb`.
65+
66+
**Critical:** Better Auth uses adapter model names, NOT underlying table names. If Prisma model is `User` mapping to table `users`, use `modelName: "user"` (Prisma reference), not `"users"`.
67+
68+
---
69+
70+
## Session Management
71+
72+
**Storage priority:**
73+
1. If `secondaryStorage` defined → sessions go there (not DB)
74+
2. Set `session.storeSessionInDatabase: true` to also persist to DB
75+
3. No database + `cookieCache` → fully stateless mode
76+
77+
**Cookie cache strategies:**
78+
- `compact` (default) - Base64url + HMAC. Smallest.
79+
- `jwt` - Standard JWT. Readable but signed.
80+
- `jwe` - Encrypted. Maximum security.
81+
82+
**Key options:** `session.expiresIn` (default 7 days), `session.updateAge` (refresh interval), `session.cookieCache.maxAge`, `session.cookieCache.version` (change to invalidate all sessions).
83+
84+
---
85+
86+
## User & Account Config
87+
88+
**User:** `user.modelName`, `user.fields` (column mapping), `user.additionalFields`, `user.changeEmail.enabled` (disabled by default), `user.deleteUser.enabled` (disabled by default).
89+
90+
**Account:** `account.modelName`, `account.accountLinking.enabled`, `account.storeAccountCookie` (for stateless OAuth).
91+
92+
**Required for registration:** `email` and `name` fields.
93+
94+
---
95+
96+
## Email Flows
97+
98+
- `emailVerification.sendVerificationEmail` - Must be defined for verification to work
99+
- `emailVerification.sendOnSignUp` / `sendOnSignIn` - Auto-send triggers
100+
- `emailAndPassword.sendResetPassword` - Password reset email handler
101+
102+
---
103+
104+
## Security
105+
106+
**In `advanced`:**
107+
- `useSecureCookies` - Force HTTPS cookies
108+
- `disableCSRFCheck` - ⚠️ Security risk
109+
- `disableOriginCheck` - ⚠️ Security risk
110+
- `crossSubDomainCookies.enabled` - Share cookies across subdomains
111+
- `ipAddress.ipAddressHeaders` - Custom IP headers for proxies
112+
- `database.generateId` - Custom ID generation or `"serial"`/`"uuid"`/`false`
113+
114+
**Rate limiting:** `rateLimit.enabled`, `rateLimit.window`, `rateLimit.max`, `rateLimit.storage` ("memory" | "database" | "secondary-storage").
115+
116+
---
117+
118+
## Hooks
119+
120+
**Endpoint hooks:** `hooks.before` / `hooks.after` - Array of `{ matcher, handler }`. Use `createAuthMiddleware`. Access `ctx.path`, `ctx.context.returned` (after), `ctx.context.session`.
121+
122+
**Database hooks:** `databaseHooks.user.create.before/after`, same for `session`, `account`. Useful for adding default values or post-creation actions.
123+
124+
**Hook context (`ctx.context`):** `session`, `secret`, `authCookies`, `password.hash()`/`verify()`, `adapter`, `internalAdapter`, `generateId()`, `tables`, `baseURL`.
125+
126+
---
127+
128+
## Plugins
129+
130+
**Import from dedicated paths for tree-shaking:**
131+
```
132+
import { twoFactor } from "better-auth/plugins/two-factor"
133+
```
134+
NOT `from "better-auth/plugins"`.
135+
136+
**Popular plugins:** `twoFactor`, `organization`, `passkey`, `magicLink`, `emailOtp`, `username`, `phoneNumber`, `admin`, `apiKey`, `bearer`, `jwt`, `multiSession`, `sso`, `oauthProvider`, `oidcProvider`, `openAPI`, `genericOAuth`.
137+
138+
Client plugins go in `createAuthClient({ plugins: [...] })`.
139+
140+
---
141+
142+
## Client
143+
144+
Import from: `better-auth/client` (vanilla), `better-auth/react`, `better-auth/vue`, `better-auth/svelte`, `better-auth/solid`.
145+
146+
Key methods: `signUp.email()`, `signIn.email()`, `signIn.social()`, `signOut()`, `useSession()`, `getSession()`, `revokeSession()`, `revokeSessions()`.
147+
148+
---
149+
150+
## Type Safety
151+
152+
Infer types: `typeof auth.$Infer.Session`, `typeof auth.$Infer.Session.user`.
153+
154+
For separate client/server projects: `createAuthClient<typeof auth>()`.
155+
156+
---
157+
158+
## Common Gotchas
159+
160+
1. **Model vs table name** - Config uses ORM model name, not DB table name
161+
2. **Plugin schema** - Re-run CLI after adding plugins
162+
3. **Secondary storage** - Sessions go there by default, not DB
163+
4. **Cookie cache** - Custom session fields NOT cached, always re-fetched
164+
5. **Stateless mode** - No DB = session in cookie only, logout on cache expiry
165+
6. **Change email flow** - Sends to current email first, then new email
166+
167+
---
168+
169+
## Resources
170+
171+
- [Docs](https://better-auth.com/docs)
172+
- [Options Reference](https://better-auth.com/docs/reference/options)
173+
- [LLMs.txt](https://better-auth.com/llms.txt)
174+
- [GitHub](https://github.com/better-auth/better-auth)
175+
- [Init Options Source](https://github.com/better-auth/better-auth/blob/main/packages/core/src/types/init-options.ts)
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
name: brainstorming
3+
description: "You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation."
4+
---
5+
6+
# Brainstorming Ideas Into Designs
7+
8+
Help turn ideas into fully formed designs and specs through natural collaborative dialogue.
9+
10+
Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design and get user approval.
11+
12+
<HARD-GATE>
13+
Do NOT invoke any implementation skill, write any code, scaffold any project, or take any implementation action until you have presented a design and the user has approved it. This applies to EVERY project regardless of perceived simplicity.
14+
</HARD-GATE>
15+
16+
## Anti-Pattern: "This Is Too Simple To Need A Design"
17+
18+
Every project goes through this process. A todo list, a single-function utility, a config change — all of them. "Simple" projects are where unexamined assumptions cause the most wasted work. The design can be short (a few sentences for truly simple projects), but you MUST present it and get approval.
19+
20+
## Checklist
21+
22+
You MUST create a task for each of these items and complete them in order:
23+
24+
1. **Explore project context** — check files, docs, recent commits
25+
2. **Offer visual companion** (if topic will involve visual questions) — this is its own message, not combined with a clarifying question. See the Visual Companion section below.
26+
3. **Ask clarifying questions** — one at a time, understand purpose/constraints/success criteria
27+
4. **Propose 2-3 approaches** — with trade-offs and your recommendation
28+
5. **Present design** — in sections scaled to their complexity, get user approval after each section
29+
6. **Write design doc** — save to `docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md` and commit
30+
7. **Spec self-review** — quick inline check for placeholders, contradictions, ambiguity, scope (see below)
31+
8. **User reviews written spec** — ask user to review the spec file before proceeding
32+
9. **Transition to implementation** — invoke writing-plans skill to create implementation plan
33+
34+
## Process Flow
35+
36+
```dot
37+
digraph brainstorming {
38+
"Explore project context" [shape=box];
39+
"Visual questions ahead?" [shape=diamond];
40+
"Offer Visual Companion\n(own message, no other content)" [shape=box];
41+
"Ask clarifying questions" [shape=box];
42+
"Propose 2-3 approaches" [shape=box];
43+
"Present design sections" [shape=box];
44+
"User approves design?" [shape=diamond];
45+
"Write design doc" [shape=box];
46+
"Spec self-review\n(fix inline)" [shape=box];
47+
"User reviews spec?" [shape=diamond];
48+
"Invoke writing-plans skill" [shape=doublecircle];
49+
50+
"Explore project context" -> "Visual questions ahead?";
51+
"Visual questions ahead?" -> "Offer Visual Companion\n(own message, no other content)" [label="yes"];
52+
"Visual questions ahead?" -> "Ask clarifying questions" [label="no"];
53+
"Offer Visual Companion\n(own message, no other content)" -> "Ask clarifying questions";
54+
"Ask clarifying questions" -> "Propose 2-3 approaches";
55+
"Propose 2-3 approaches" -> "Present design sections";
56+
"Present design sections" -> "User approves design?";
57+
"User approves design?" -> "Present design sections" [label="no, revise"];
58+
"User approves design?" -> "Write design doc" [label="yes"];
59+
"Write design doc" -> "Spec self-review\n(fix inline)";
60+
"Spec self-review\n(fix inline)" -> "User reviews spec?";
61+
"User reviews spec?" -> "Write design doc" [label="changes requested"];
62+
"User reviews spec?" -> "Invoke writing-plans skill" [label="approved"];
63+
}
64+
```
65+
66+
**The terminal state is invoking writing-plans.** Do NOT invoke frontend-design, mcp-builder, or any other implementation skill. The ONLY skill you invoke after brainstorming is writing-plans.
67+
68+
## The Process
69+
70+
**Understanding the idea:**
71+
72+
- Check out the current project state first (files, docs, recent commits)
73+
- Before asking detailed questions, assess scope: if the request describes multiple independent subsystems (e.g., "build a platform with chat, file storage, billing, and analytics"), flag this immediately. Don't spend questions refining details of a project that needs to be decomposed first.
74+
- If the project is too large for a single spec, help the user decompose into sub-projects: what are the independent pieces, how do they relate, what order should they be built? Then brainstorm the first sub-project through the normal design flow. Each sub-project gets its own spec → plan → implementation cycle.
75+
- For appropriately-scoped projects, ask questions one at a time to refine the idea
76+
- Prefer multiple choice questions when possible, but open-ended is fine too
77+
- Only one question per message - if a topic needs more exploration, break it into multiple questions
78+
- Focus on understanding: purpose, constraints, success criteria
79+
80+
**Exploring approaches:**
81+
82+
- Propose 2-3 different approaches with trade-offs
83+
- Present options conversationally with your recommendation and reasoning
84+
- Lead with your recommended option and explain why
85+
86+
**Presenting the design:**
87+
88+
- Once you believe you understand what you're building, present the design
89+
- Scale each section to its complexity: a few sentences if straightforward, up to 200-300 words if nuanced
90+
- Ask after each section whether it looks right so far
91+
- Cover: architecture, components, data flow, error handling, testing
92+
- Be ready to go back and clarify if something doesn't make sense
93+
94+
**Design for isolation and clarity:**
95+
96+
- Break the system into smaller units that each have one clear purpose, communicate through well-defined interfaces, and can be understood and tested independently
97+
- For each unit, you should be able to answer: what does it do, how do you use it, and what does it depend on?
98+
- Can someone understand what a unit does without reading its internals? Can you change the internals without breaking consumers? If not, the boundaries need work.
99+
- Smaller, well-bounded units are also easier for you to work with - you reason better about code you can hold in context at once, and your edits are more reliable when files are focused. When a file grows large, that's often a signal that it's doing too much.
100+
101+
**Working in existing codebases:**
102+
103+
- Explore the current structure before proposing changes. Follow existing patterns.
104+
- Where existing code has problems that affect the work (e.g., a file that's grown too large, unclear boundaries, tangled responsibilities), include targeted improvements as part of the design - the way a good developer improves code they're working in.
105+
- Don't propose unrelated refactoring. Stay focused on what serves the current goal.
106+
107+
## After the Design
108+
109+
**Documentation:**
110+
111+
- Write the validated design (spec) to `docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md`
112+
- (User preferences for spec location override this default)
113+
- Use elements-of-style:writing-clearly-and-concisely skill if available
114+
- Commit the design document to git
115+
116+
**Spec Self-Review:**
117+
After writing the spec document, look at it with fresh eyes:
118+
119+
1. **Placeholder scan:** Any "TBD", "TODO", incomplete sections, or vague requirements? Fix them.
120+
2. **Internal consistency:** Do any sections contradict each other? Does the architecture match the feature descriptions?
121+
3. **Scope check:** Is this focused enough for a single implementation plan, or does it need decomposition?
122+
4. **Ambiguity check:** Could any requirement be interpreted two different ways? If so, pick one and make it explicit.
123+
124+
Fix any issues inline. No need to re-review — just fix and move on.
125+
126+
**User Review Gate:**
127+
After the spec review loop passes, ask the user to review the written spec before proceeding:
128+
129+
> "Spec written and committed to `<path>`. Please review it and let me know if you want to make any changes before we start writing out the implementation plan."
130+
131+
Wait for the user's response. If they request changes, make them and re-run the spec review loop. Only proceed once the user approves.
132+
133+
**Implementation:**
134+
135+
- Invoke the writing-plans skill to create a detailed implementation plan
136+
- Do NOT invoke any other skill. writing-plans is the next step.
137+
138+
## Key Principles
139+
140+
- **One question at a time** - Don't overwhelm with multiple questions
141+
- **Multiple choice preferred** - Easier to answer than open-ended when possible
142+
- **YAGNI ruthlessly** - Remove unnecessary features from all designs
143+
- **Explore alternatives** - Always propose 2-3 approaches before settling
144+
- **Incremental validation** - Present design, get approval before moving on
145+
- **Be flexible** - Go back and clarify when something doesn't make sense
146+
147+
## Visual Companion
148+
149+
A browser-based companion for showing mockups, diagrams, and visual options during brainstorming. Available as a tool — not a mode. Accepting the companion means it's available for questions that benefit from visual treatment; it does NOT mean every question goes through the browser.
150+
151+
**Offering the companion:** When you anticipate that upcoming questions will involve visual content (mockups, layouts, diagrams), offer it once for consent:
152+
> "Some of what we're working on might be easier to explain if I can show it to you in a web browser. I can put together mockups, diagrams, comparisons, and other visuals as we go. This feature is still new and can be token-intensive. Want to try it? (Requires opening a local URL)"
153+
154+
**This offer MUST be its own message.** Do not combine it with clarifying questions, context summaries, or any other content. The message should contain ONLY the offer above and nothing else. Wait for the user's response before continuing. If they decline, proceed with text-only brainstorming.
155+
156+
**Per-question decision:** Even after the user accepts, decide FOR EACH QUESTION whether to use the browser or the terminal. The test: **would the user understand this better by seeing it than reading it?**
157+
158+
- **Use the browser** for content that IS visual — mockups, wireframes, layout comparisons, architecture diagrams, side-by-side visual designs
159+
- **Use the terminal** for content that is text — requirements questions, conceptual choices, tradeoff lists, A/B/C/D text options, scope decisions
160+
161+
A question about a UI topic is not automatically a visual question. "What does personality mean in this context?" is a conceptual question — use the terminal. "Which wizard layout works better?" is a visual question — use the browser.
162+
163+
If they agree to the companion, read the detailed guide before proceeding:
164+
`skills/brainstorming/visual-companion.md`

0 commit comments

Comments
 (0)