← Admin ConsoleArrows or space · F for fullscreen · Print to saveTalks

CLAUDE CODE BUILD NIGHT · PART 11

Admin
Console

Tonight, the controls. Every night stands on its own.

Ship AI · TalksAdmin Console01/21

Who's hosting

How you do anything is how you do everything.

Santos Hernandez
Santos HernandezFounder, Ship AI
$25k+/moggbucks, built with agents
$0 to $12MARR at ZBD
EU firstMiCAR approval
THE COMMUNITY

Ship AI

Free workshops and talks in Phoenix.

shipai.club
THE STUDIO

Ship AI Studio

AI built into your business, in two weeks.

shipaistudio.com

Ship AI · TalksAdmin Console02/21

Join the room

SHIP AI DISCORD

Scan it now.
Prompts later.

Open the Discord invite

Ship AI · TalksAdmin Console03/21

Our partner

Ship AIWorkuityAI Exchange

Building Phoenix's AI community, together. Workuity hosts tonight, and we present Founder Weekend side by side.

Ship AI · TalksAdmin Console04/21

THE IDEA

Every app has a second app.
The one you run it with.

Ship AI · TalksAdmin Console05/21

Stop editing production by hand

FIX IT IN PROD

"I'll just edit the database."

ADMIN CONSOLE

Roles, checks, a record.
Every action leaves a trail.

Ship AI · TalksAdmin Console06/21

Tonight

01

Roles

02

Pages

03

Actions

04

Audit

Ship AI · TalksAdmin Console07/21

Tonight's example

ADMIN.md
Roles

admin and user. The first admin comes from the terminal.

Rules

The server decides. Every action is logged.

Pages

Metrics, users, support, dinners, audit log.

Done when

A normal user gets nothing from /admin

Every action shows up in the audit log

Ship AI · TalksAdmin Console08/21

Write ADMIN.md first

claude · ~/whats-for-dinner

claudeWhat do you need to do for a user today?

youFind them, see their dinners, ban a spammer.

claudeShould banning ask for a reason?

✓ Wrote ADMIN.md: 2 roles, 5 pages, 10 audit events

Copy · the ADMIN.md interview
Interview me about the admin jobs, roles and metrics, then write ADMIN.md with rules, pages, actions, audit events and Done when. Wait for my OK.

Full prompt

Copy this entire prompt into Claude Code.

Read SPEC.md and look at the current database schema and auth setup. We're adding an internal admin console at /admin inside this same Next.js app.

Interview me one question at a time and wait for each answer:
- Which jobs do I do for users today, by hand or in the database?
- Which of those are destructive and need a confirmation and a reason?
- Who needs admin access, and who doesn't?
- Which three numbers I want to see every morning (use GROWTH.md if it exists)

Then write ADMIN.md with these sections: Rules, Roles, Pages, Actions (a table with who, confirm and audit event), Audit log, Metrics, Done when.

The Rules section must say: least privilege; every page and action checks the role on the server; every admin action writes an audit row; no secrets in the browser; destructive actions confirm; impersonation is logged.

Stop and wait for my OK before writing any code.

Ship AI · TalksAdmin Console09/21

Roles with Better Auth's admin plugin

claude · ~/whats-for-dinner

✓ admin() on the server, adminClient() on the client

✓ role, banned, banReason, banExpires on user

✓ impersonatedBy on session

claudeYour turn: create the first admin in your terminal.

Copy · add the admin plugin
Add Better Auth's admin plugin on server and client, add its columns, then stop so I can create the first admin in my terminal.

Full prompt

Copy this entire prompt into Claude Code.

Read ADMIN.md. Add roles with Better Auth's admin plugin. Check the current docs at better-auth.com/docs/plugins/admin before writing code. Stop after each step.

1. Add admin() from better-auth/plugins to the server auth config and adminClient() from better-auth/client/plugins to the auth client. Keep the default roles: admin and user, with user as the default for new sign-ups.
2. Add the plugin's database columns the way Better Auth's docs say for this project's setup (npx auth@latest migrate or generate). Show me what changes before applying it.
3. Tell me to create the first admin myself in my terminal with:
   npx auth@latest create-admin --email <my email> --name "<my name>" --role admin
   Wait until I tell you it's done.

Don't build any admin pages yet. Never put my password or any secret in a file or in chat.

better-auth.com/docs/plugins/admin

Ship AI · TalksAdmin Console10/21

Lock the door on the server

claude · ~/whats-for-dinner

✓ requireAdmin() in the /admin layout and every action

✓ e2e/admin-access.spec.ts

3 passed: signed out, normal user, admin

claudeA normal user gets a 404 and no data.

Copy · server checks and the Playwright test
Write requireAdmin() and call it in the layout, every page, action and route. Then a Playwright test that a normal user gets nothing.

Full prompt

Copy this entire prompt into Claude Code.

Read ADMIN.md. Lock /admin down on the server before building any page. Stop after each step.

1. Write one server-only helper, requireAdmin(), that reads the Better Auth session from the request headers and returns the user only if their role is admin. Otherwise it stops the request (notFound or a 403) before any data is loaded. Part 9 forced row level security on dinners, favorites and plans, so every admin data path runs after requireAdmin() through lib/db-privileged.ts, the server-only connection from Part 9, never lib/db-as-user.ts. If that file doesn't exist yet, read SECURITY.md, section Data, and ask me before creating it.
2. Call it in app/admin/layout.tsx, and also at the top of every admin page, server action and route handler. Don't rely on the layout alone, and don't rely on hiding links.
3. Check for playwright.config.ts (Part 4 created it). If it exists, reuse it. If it doesn't, tell me to run npm init playwright@latest myself and wait until I tell you it's done.
4. Write e2e/admin-access.spec.ts with three tests: signed out, /admin shows no admin content; signed in as a normal test user, /admin and one admin server action return no data; signed in as an admin, /admin loads. Read test account emails and passwords from environment variables I'll add to .env.local myself; never write real credentials into the test.
5. Run npx playwright test and show me the result.

playwright.dev/docs/auth

Ship AI · TalksAdmin Console11/21

Hidden is not locked

HIDE THE LINK

No Admin button in the nav.

CHECK ON THE SERVER

Every page. Every action.
No role, no data.

Ship AI · TalksAdmin Console12/21

A users table you can search

claude · ~/whats-for-dinner

youSearch "gmail", banned only, newest first.

✓ listUsers: searchValue, filterField, sortBy

claudeBan asks for a reason, then writes user.ban.

✓ 1 row in admin_audit_log

Copy · the users table and the audit log
Create admin_audit_log and logAdminAction(), then a shadcn data table on listUsers with search, filter, sort and confirmed, logged actions.

Full prompt

Copy this entire prompt into Claude Code.

Read ADMIN.md. Build the audit log first, then the users table. Stop after each step.

1. Create the admin_audit_log table from ADMIN.md (id, actor_id, action, target_type, target_id, reason, metadata JSON, created_at). Write one server-only function, logAdminAction(), that inserts a row. Nothing in the code may update or delete audit rows.
2. Check for components.json. If it doesn't exist, tell me to run npx shadcn@latest init in my own terminal, because it asks questions, and wait until I tell you it's done. Then add the components this console uses: npx shadcn@latest add table button dropdown-menu input dialog textarea, and npm install @tanstack/react-table. Follow the data table guide on ui.shadcn.com.
3. Build /admin/users. Load users on the server with Better Auth's listUsers, passing the request headers, and use its search (email or name), filter (role, banned) and sort (created date) options, with pagination.
4. Add a row actions menu: set role, ban, unban. Each one is a server action that calls requireAdmin(), asks for confirmation in a dialog (ban also asks for a reason), calls the admin plugin, then calls logAdminAction(). An admin can't ban or demote themselves.
5. Show me the page at desktop width and one audit row after a test ban.

ui.shadcn.com/docs/components/radix/data-table

Ship AI · TalksAdmin Console13/21

Hide a bad recipe

claude · ~/whats-for-dinner

youThis recipe says to bake lettuce for an hour.

claudeHide it? It needs a reason.

youUnsafe cooking step.

✓ Hidden from the user · recipe.hide logged

Copy · the dinners view
Propose the schema change to hide one recipe, build /admin/dinners, add confirmed and logged Hide and Unhide, and hide it from the user's dinners and Favorites.

Full prompt

Copy this entire prompt into Claude Code.

Read ADMIN.md. Build /admin/dinners. Stop after each step.

1. Propose the smallest schema change that lets an admin hide one recipe inside a dinner result, with who hid it, when and why. Wait for my OK, then apply it.
2. Build the page: newest dinners first, with the user's email, the ingredients and the three recipe names. Opening one shows the full recipes.
3. Add Hide and Unhide as server actions: requireAdmin(), a confirmation dialog with a required reason, the change, then logAdminAction() with recipe.hide or recipe.unhide.
4. Update the user-facing app so hidden recipes no longer show anywhere: in that user's dinners and in Favorites (favorites from Part 4 point at dinner_id and recipe_index, so filter those out too). Keep the favorites rows so Unhide brings them back. Show me both sides: the admin view and the user's view, including Favorites.

Ship AI · TalksAdmin Console14/21

Support in one page

claude · ~/whats-for-dinner

youLook up maria@example.com.

✓ 2 sessions · 6 dinners this week

claudeSend a reset link or sign her out everywhere?

✓ user.password_reset_sent logged

Copy · the support view
Build /admin/users/[id]: profile, recent dinners, sessions, plus revoke, password reset and impersonate, each confirmed and logged, with a banner while impersonating.

Full prompt

Copy this entire prompt into Claude Code.

Read ADMIN.md. Build the support view at /admin/users/[id]. Stop after each step.

1. Show the user's profile (email, name, role, created date, banned and why), their 10 most recent dinners, and their active sessions. Load it all on the server after requireAdmin().
2. Add three actions, each with a confirmation and logAdminAction():
   - Revoke sessions, with the admin plugin's revokeUserSessions
   - Send password reset, with Better Auth's requestPasswordReset. If the auth config has no sendResetPassword function yet, tell me and skip this one instead of adding an email provider.
   - Impersonate, with impersonateUser, asking for a reason
3. While impersonating, show a banner across the app with a Stop button that calls stopImpersonating. Log user.impersonate_start and user.impersonate_stop, using the session's impersonatedBy field to know who the admin is.
4. Show me the page, then the banner while impersonating a test user.

Ship AI · TalksAdmin Console15/21

Three numbers every morning

claude · ~/whats-for-dinner

Signups this week: 41

Activated in 24 hours: 26 (63%)

Weekly active: 118

claudeSame definitions as GROWTH.md.

Copy · the metrics page
Build /admin with signups, activated users and weekly active from server-side queries, using GROWTH.md's definitions if they exist. Show me the SQL.

Full prompt

Copy this entire prompt into Claude Code.

Read ADMIN.md, and GROWTH.md from Part 7 if it exists. Build /admin, the metrics page.

1. Write the queries on the server through lib/db-privileged.ts, after requireAdmin(): signups (new users per week), activated (new users whose first three dinners were found within 24 hours of signing up, the same definition as GROWTH.md) and weekly active (users who found dinners at least once that week). If GROWTH.md has changed since Part 7, use its current definitions and tell me.
2. Show each number with last week's number beside it, and an eight-week table under each one. No charts library unless one is already installed.
3. Call requireAdmin() first. No analytics keys or database URLs in client components.
4. Show me the page, and the SQL behind each number so I can check it.

Ship AI · TalksAdmin Console16/21

One AI assist

whats-for-dinner · /admin/users/maria

youSummarize this user

claudeActive 5 of 7 days. Mostly eggs and spinach.

claudeHit two errors Tuesday, then stopped.

✓ ai.summarize_user logged

Copy · the AI summary
Add a Summarize button: a server action sends the user's recent activity, minus personal data, to Claude through AI Gateway and logs the call.

Full prompt

Copy this entire prompt into Claude Code.

Read ADMIN.md. Add one AI assist to the support view: a Summarize button on /admin/users/[id].

1. A server action calls requireAdmin(), loads the user's last 30 days of dinners and errors, and sends only what's needed (no email, no password hashes, no session tokens) to a Claude model through the AI SDK and Vercel AI Gateway with a "provider/model" string. Check the AI Gateway model list for the current Claude Sonnet model ID instead of guessing.
2. Ask for four short lines: how often they use it, what they cook, anything that went wrong, and one suggested next step for support. It must not invent facts that aren't in the data.
3. Use the existing AI_GATEWAY_API_KEY in .env.local; never send it to the browser. 15-second timeout, and a plain error message on failure.
4. Log ai.summarize_user with logAdminAction(). Show me the summary for a test user.

vercel.com/docs/ai-gateway

Ship AI · TalksAdmin Console17/21

Ship the console

claude · ~/whats-for-dinner

✓ 5 of 5 checks under Done when

✓ npx playwright test: all passed

✓ 10 audit events, no client-side secrets

claudeDeployed. /admin is live and locked.

Copy · check and ship
Check every admin route and action for requireAdmin(), hunt for client-side secrets, confirm every audit event, run the tests, then ship.

Full prompt

Copy this entire prompt into Claude Code.

Read ADMIN.md. Before we ship, review the admin console like an attacker would.

1. List every file under app/admin and every admin server action and route handler, and confirm each one calls requireAdmin() before loading or changing data. Fix any that don't.
2. Search client components for secrets or server-only imports (database URLs, AI keys, auth secrets). Fix anything you find.
3. Confirm every action in the Actions table writes its audit event. Show me the audit log after one of each.
4. Run npx playwright test and every check under Done when, and tell me which pass.
5. Commit and push so Vercel deploys. Ask me before any step that needs my login, and give me the live /admin URL when it's done.

Also in the series: Part 12, AI Ops Team. A live team of Grok Bots to run it with you.

Ship AI · TalksAdmin Console18/21

Take it home

THE TALK PAGE

Every prompt,
and this deck.

Open the talk page

Ship AI · TalksAdmin Console19/21

Founder Weekend

FEB 6‑7, 2027 · FREE

Tonight was one hour.
Take a weekend.

An Arizona AI hackathon. Teams of 1-4.

See the hackathon

Ship AI · TalksAdmin Console20/21

SHIP AI DISCORD

Free and open.
Build with us.

Scan to join

Ship AI · TalksAdmin Console21/21
01/21