Skip to content

Commit b0728e8

Browse files
royangerclaude
andcommitted
feat(repo): ship AGENTS.md with each Clerk SDK
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 585b449 commit b0728e8

35 files changed

Lines changed: 601 additions & 4 deletions

‎.changeset/ship-sdk-agents-md.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@clerk/astro': patch
3+
'@clerk/backend': patch
4+
'@clerk/chrome-extension': patch
5+
'@clerk/clerk-js': patch
6+
'@clerk/electron': patch
7+
'@clerk/expo': patch
8+
'@clerk/express': patch
9+
'@clerk/fastify': patch
10+
'@clerk/hono': patch
11+
'@clerk/nextjs': patch
12+
'@clerk/nuxt': patch
13+
'@clerk/react': patch
14+
'@clerk/react-router': patch
15+
'@clerk/tanstack-react-start': patch
16+
'@clerk/vue': patch
17+
---
18+
19+
Ship an `AGENTS.md` file in the package. It lists the current APIs for this version and how to use the Clerk MCP server, so AI coding agents can read it from `node_modules` instead of relying on outdated training data.

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ jobs:
8585
- name: Check Dashboard links
8686
run: pnpm lint:dashboard-links
8787

88+
- name: Check SDK AGENTS.md
89+
run: pnpm lint:agents-md
90+
8891
- name: Verify localizations are generated
8992
run: |
9093
pnpm --filter @clerk/localizations generate

‎package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"license": "MIT",
66
"scripts": {
7+
"agents-md:sync": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON ./scripts/sync-agents-md.mjs",
78
"build": "FORCE_COLOR=1 turbo build --concurrency=${TURBO_CONCURRENCY:-80%}",
89
"build:declarations": "FORCE_COLOR=1 turbo build:declarations --concurrency=${TURBO_CONCURRENCY:-80%} --filter=@clerk/nextjs",
910
"bundlewatch": "turbo run bundlewatch",
@@ -20,6 +21,7 @@
2021
"preinstall": "npx only-allow pnpm",
2122
"integration:secrets": "node ./scripts/1password-keys.mjs",
2223
"lint": "node ./scripts/lint.mjs",
24+
"lint:agents-md": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON ./scripts/sync-agents-md.mjs --check",
2325
"lint:attw": "FORCE_COLOR=1 turbo lint:attw",
2426
"lint:dashboard-links": "node ./scripts/check-dashboard-links.mjs",
2527
"lint:fix": "FORCE_COLOR=1 turbo lint -- --fix",

‎packages/astro/AGENTS.md‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## Clerk + Astro
2+
3+
Read the installed `@clerk/astro` types before changing auth code. If a symbol is not in those types, it does not exist.
4+
5+
### Current APIs
6+
7+
- Register the default export of `@clerk/astro` in `integrations` in `astro.config`. `server` output needs an adapter.
8+
- Use `clerkMiddleware()` from `@clerk/astro/server` in `src/middleware.ts`.
9+
- `createRouteMatcher()` was removed. Check auth in each page or API route with `Astro.locals.auth()` or `locals.auth()`, then call `redirectToSignIn()` or return a 401.
10+
- `locals.currentUser()` returns the Backend `User` or `null`.
11+
- `<SignedIn>`, `<SignedOut>`, and `<Protect>` were removed. Import `<Show>` from `@clerk/astro/components` (or `@clerk/astro/react`). Its `when` prop is required, for example `<Show when="signed-in">`.
12+
- The `as` prop was removed from `<SignInButton>`, `<SignUpButton>`, and `<SignOutButton>`. Use `asChild` with a child element.
13+
- Clerk Elements is removed. Never use it.
14+
15+
<!-- BEGIN:clerk-mcp -->
16+
17+
### Clerk MCP server
18+
19+
Use this section when a `clerk` MCP server (`https://mcp.clerk.com/mcp`) is connected. If it is not connected, tell the user they can add it:
20+
https://clerk.com/docs/guides/ai/mcp/clerk-mcp-server
21+
22+
The server lists its own tools and describes what each one does. Follow these rules on top of those descriptions:
23+
24+
- Get Clerk code from the SDK snippet tools (`list_clerk_sdk_snippets`, `clerk_sdk_snippet`) instead of writing it from memory.
25+
- Check every import in a snippet against the installed `@clerk/astro` types. If they disagree, the installed types win.
26+
- Read the current application and instance config before you change anything.
27+
- Ask the user before calling any Clerk MCP tool that creates or changes something in their Clerk account. Run config changes as a dry run first and show the user the result.
28+
- The server never returns secret keys. Do not ask the user to paste one into chat. Point them to https://dashboard.clerk.com/~/api-keys.
29+
30+
### Docs
31+
32+
Start at https://clerk.com/docs/llms.txt. Add `.md` to any docs URL to get Markdown.
33+
34+
<!-- END:clerk-mcp -->

‎packages/astro/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"module": "./dist/index.js",
6868
"types": "./dist/index.d.ts",
6969
"files": [
70+
"AGENTS.md",
7071
"dist",
7172
"client",
7273
"server",

‎packages/backend/AGENTS.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Clerk + Backend
2+
3+
Read the installed `@clerk/backend` types before changing auth code. If a symbol is not in those types, it does not exist.
4+
5+
### Current APIs
6+
7+
- Create the client with `createClerkClient({ secretKey, publishableKey })` from `@clerk/backend`.
8+
- Authenticate a Fetch `Request` with `await clerkClient.authenticateRequest(request)`. Check `requestState.isAuthenticated`, not the deprecated `isSignedIn`, then read auth from `requestState.toAuth()`.
9+
- Verify machine tokens with `verify()`: `clerkClient.apiKeys.verify(secret)`, `clerkClient.m2m.verify(params)`, `clerkClient.idPOAuthAccessToken.verify(token)`. `verifySecret()`, `verifyAccessToken()`, and `m2m.verifyToken()` are removed. The top-level `verifyToken()` export still exists.
10+
- Verify webhooks with `verifyWebhook(request)` from `@clerk/backend/webhooks`. It reads `CLERK_WEBHOOK_SIGNING_SECRET` by default.
11+
- Clerk Elements is removed. Never use it.
12+
13+
<!-- BEGIN:clerk-mcp -->
14+
15+
### Clerk MCP server
16+
17+
Use this section when a `clerk` MCP server (`https://mcp.clerk.com/mcp`) is connected. If it is not connected, tell the user they can add it:
18+
https://clerk.com/docs/guides/ai/mcp/clerk-mcp-server
19+
20+
The server lists its own tools and describes what each one does. Follow these rules on top of those descriptions:
21+
22+
- Get Clerk code from the SDK snippet tools (`list_clerk_sdk_snippets`, `clerk_sdk_snippet`) instead of writing it from memory.
23+
- Check every import in a snippet against the installed `@clerk/backend` types. If they disagree, the installed types win.
24+
- Read the current application and instance config before you change anything.
25+
- Ask the user before calling any Clerk MCP tool that creates or changes something in their Clerk account. Run config changes as a dry run first and show the user the result.
26+
- The server never returns secret keys. Do not ask the user to paste one into chat. Point them to https://dashboard.clerk.com/~/api-keys.
27+
28+
### Docs
29+
30+
Start at https://clerk.com/docs/llms.txt. Add `.md` to any docs URL to get Markdown.
31+
32+
<!-- END:clerk-mcp -->

‎packages/backend/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
},
9090
"main": "./dist/index.js",
9191
"files": [
92+
"AGENTS.md",
9293
"dist",
9394
"errors",
9495
"internal",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Clerk + Chrome Extension
2+
3+
Read the installed `@clerk/chrome-extension` types before changing auth code. If a symbol is not in those types, it does not exist.
4+
5+
### Current APIs
6+
7+
- Pass `publishableKey` to `<ClerkProvider>`. There is no env var fallback. Pass `syncHost` to sync sessions with your web app.
8+
- In the background service worker, use `createClerkClient()` from `@clerk/chrome-extension/background`. `__unstable__createClerkClient` was renamed.
9+
- `<SignedIn>`, `<SignedOut>`, and `<Protect>` were removed. Use `<Show when="signed-in">` or `<Show when="signed-out">`.
10+
- `<GoogleOneTap>` renders nothing in extensions.
11+
- The root `useSignIn()` and `useSignUp()` are the Core 3 hooks. The old `isLoaded`-style hooks are in `@clerk/chrome-extension/legacy`.
12+
- Clerk Elements is removed. Never use it.
13+
14+
<!-- BEGIN:clerk-mcp -->
15+
16+
### Clerk MCP server
17+
18+
Use this section when a `clerk` MCP server (`https://mcp.clerk.com/mcp`) is connected. If it is not connected, tell the user they can add it:
19+
https://clerk.com/docs/guides/ai/mcp/clerk-mcp-server
20+
21+
The server lists its own tools and describes what each one does. Follow these rules on top of those descriptions:
22+
23+
- Get Clerk code from the SDK snippet tools (`list_clerk_sdk_snippets`, `clerk_sdk_snippet`) instead of writing it from memory.
24+
- Check every import in a snippet against the installed `@clerk/chrome-extension` types. If they disagree, the installed types win.
25+
- Read the current application and instance config before you change anything.
26+
- Ask the user before calling any Clerk MCP tool that creates or changes something in their Clerk account. Run config changes as a dry run first and show the user the result.
27+
- The server never returns secret keys. Do not ask the user to paste one into chat. Point them to https://dashboard.clerk.com/~/api-keys.
28+
29+
### Docs
30+
31+
Start at https://clerk.com/docs/llms.txt. Add `.md` to any docs URL to get Markdown.
32+
33+
<!-- END:clerk-mcp -->

‎packages/chrome-extension/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"module": "./dist/esm/index.js",
7272
"types": "./dist/types/index.d.ts",
7373
"files": [
74+
"AGENTS.md",
7475
"background",
7576
"client",
7677
"dist",

‎packages/clerk-js/AGENTS.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Clerk + ClerkJS
2+
3+
Read the installed `@clerk/clerk-js` types before changing auth code. If a symbol is not in those types, it does not exist.
4+
5+
### Current APIs
6+
7+
- Import `Clerk` from `@clerk/clerk-js` and `await clerk.load()` before using it.
8+
- Prebuilt UI components come from `@clerk/ui`, which loads from the Clerk CDN.
9+
- `client.activeSessions` was removed. Use `client.sessions`.
10+
- `setActive({ beforeEmit })` was replaced by `setActive({ navigate: ({ session }) => url })`.
11+
- `session.getToken()` throws `ClerkOfflineError` when offline. It no longer returns `null`.
12+
- Clerk Elements is removed. Never use it.
13+
14+
<!-- BEGIN:clerk-mcp -->
15+
16+
### Clerk MCP server
17+
18+
Use this section when a `clerk` MCP server (`https://mcp.clerk.com/mcp`) is connected. If it is not connected, tell the user they can add it:
19+
https://clerk.com/docs/guides/ai/mcp/clerk-mcp-server
20+
21+
The server lists its own tools and describes what each one does. Follow these rules on top of those descriptions:
22+
23+
- Get Clerk code from the SDK snippet tools (`list_clerk_sdk_snippets`, `clerk_sdk_snippet`) instead of writing it from memory.
24+
- Check every import in a snippet against the installed `@clerk/clerk-js` types. If they disagree, the installed types win.
25+
- Read the current application and instance config before you change anything.
26+
- Ask the user before calling any Clerk MCP tool that creates or changes something in their Clerk account. Run config changes as a dry run first and show the user the result.
27+
- The server never returns secret keys. Do not ask the user to paste one into chat. Point them to https://dashboard.clerk.com/~/api-keys.
28+
29+
### Docs
30+
31+
Start at https://clerk.com/docs/llms.txt. Add `.md` to any docs URL to get Markdown.
32+
33+
<!-- END:clerk-mcp -->

0 commit comments

Comments
 (0)