1{2 "skill_name": "clerk-astro-patterns",3 "evals": [4 {5 "id": 1,6 "prompt": "i'm adding clerk to my astro app. set up the middleware so the /dashboard and /settings routes are protected and redirect unauthenticated users to /sign-in.",7 "expected_output": "Creates src/middleware.ts with clerkMiddleware, createRouteMatcher matching /dashboard and /settings, redirects via auth().redirectToSignIn()",8 "scaffold": "astro-basic-auth",9 "expectations": [
10 "Creates src/middleware.ts that exports onRequest",
11 "Uses clerkMiddleware from @clerk/astro/server",
12 "Uses createRouteMatcher to match /dashboard and /settings routes",
13 "Calls auth().redirectToSignIn() when route is protected and user is not signed in",
14 "Calls next() for unprotected routes"
15 ]
16 },
17 {
18 "id": 2,
19 "prompt": "i have an astro SSR page at /dashboard. i need to get the current user's id and redirect to /sign-in if they're not authenticated.",
20 "expected_output": "Uses Astro.locals.auth() to get userId, calls Astro.redirect('/sign-in') when userId is falsy",
21 "scaffold": "astro-basic-auth",
22 "expectations": [
23 "Calls Astro.locals.auth() to get auth data in the frontmatter",
24 "Destructures userId from the auth result",
25 "Calls return Astro.redirect('/sign-in') when userId is falsy",
26 "Page has output: server or is not marked as prerender",
27 "Does NOT import auth from @clerk/nextjs/server"
28 ]
29 },
30 {
31 "id": 3,
32 "prompt": "i need to protect an Astro API route at /api/data.ts so only authenticated users can call it. return 401 if not authenticated.",
33 "expected_output": "API route reads Astro.locals.auth() to get userId, returns 401 Response when not authenticated",
34 "scaffold": "astro-basic-auth",
35 "expectations": [
36 "Reads Astro.locals.auth() in the GET or POST handler",
37 "Returns new Response('Unauthorized', { status: 401 }) when userId is falsy",
38 "Uses userId in the data fetching logic",
39 "Does NOT require auth in the static prerender path"
40 ]
41 },
42 {
43 "id": 4,
44 "prompt": "i want to show a sign-in button in my astro site's header when the user is not signed in, and a user menu when they are. this needs to work client-side.",
45 "expected_output": "Creates a React island component with client:load using useAuth and SignInButton/UserButton from @clerk/astro/react",
46 "scaffold": "astro-basic-auth",
47 "expectations": [
48 "Creates a React island component (Header.tsx or similar)",
49 "Imports useAuth from @clerk/astro/react",
50 "Shows UserButton when isSignedIn is true",
51 "Shows SignInButton when isSignedIn is false",
52 "Mounts the component with client:load directive in the .astro file"
53 ]
54 },
55 {
56 "id": 5,
57 "prompt": "i have a mix of static and dynamic pages in my astro app. how do i handle auth on pages that are statically prerendered?",
58 "expected_output": "Explains that static prerendered pages skip middleware, suggests using client-side auth in islands or converting the page to SSR with export const prerender = false",
59 "scaffold": "astro-basic-auth",
60 "expectations": [
61 "Notes that clerkMiddleware is skipped for prerendered pages",
62 "Suggests removing export const prerender = true for pages that need auth",
63 "OR suggests using client-side useAuth in island components for partially static pages",
64 "Does NOT suggest that Astro.locals.auth() works on prerendered pages",
65 "Explains the hybrid rendering approach (output: hybrid in astro.config.mjs)"
66 ]
67 },
68 {
69 "id": 6,
70 "prompt": "i need to show org-aware content in an astro SSR page. load the current org name from clerk and show it, or redirect to /select-org if no org is active.",
71 "expected_output": "Uses Astro.locals.auth() to get orgId, redirects to /select-org if orgId is missing, shows org data",
72 "scaffold": "astro-basic-auth",
73 "expectations": [
74 "Calls Astro.locals.auth() and destructures both userId and orgId",
75 "Returns Astro.redirect('/sign-in') when userId is falsy",
76 "Returns Astro.redirect('/select-org') when orgId is falsy",
77 "Uses orgId to fetch or display org-specific data",
78 "Handles both unauthenticated and no-org-selected states"
79 ]
80 },
81 {
82 "id": 7,
83 "prompt": "i want to use React components with Clerk in my Astro app. set up the React integration and create a header component that shows sign-in/sign-up for signed-out users and a user button for signed-in users. use it in an Astro layout.",
84 "expected_output": "Adds @astrojs/react, updates astro.config with react(), creates React header using Show/UserButton/SignInButton from @clerk/astro/react, mounts with client:load in Astro layout",
85 "scaffold": "astro-basic-auth",
86 "expectations": [
87 "Updates astro.config to include react() in integrations array alongside clerk()",
88 "Creates a React component (.tsx) importing from @clerk/astro/react (NOT @clerk/astro/components)",
89 "Uses Show when='signed-in' and Show when='signed-out' (or SignedIn/SignedOut) for conditional rendering",
90 "Includes UserButton and SignInButton from @clerk/astro/react",
91 "Mounts the React component in an .astro file with client:load directive",
92 "Does NOT forget client:load on the React component (would render as static HTML without it)"