Admin Page for Next.js Sites
Use When
- Building a new Next.js admin console.
- Expanding
/admin without duplicating capability.
- Merging multiple admin systems into one cockpit.
- Hardening privileged flows (refunds, moderation, impersonation, retries).
THE EXACT PROMPTS
1) Build/Expand
Design and implement a cohesive admin cockpit for this Next.js SaaS codebase.
Requirements:
1. Inventory `/admin` pages, APIs, permissions, data sources, jobs.
2. Build a harmonized IA (Overview, Users, Billing, Support, Moderation, Content, Analytics, Experiments, Operations, Compliance, Health).
3. Integrate non-duplicative features via shared primitives (shell, filters, tables, permissions, audit, response envelope).
4. Implement vertical slices with explicit acceptance criteria and no parallel systems.
5. Add tests for high-risk mutations and operator flows.
Output:
- route map, API/contracts plan, data model deltas
- phased rollout plan + concrete code changes
2) Consolidation/Audit
Audit this Next.js admin system for fragmentation, risk, and missing operator workflows.
Return:
1. Overlapping capabilities to merge.
2. High-risk endpoints missing permission + audit controls.
3. Read-only dashboards that should become action queues.
4. Missing operational controls (job retries, provider health, stale-data indicators).
5. Prioritized remediation slices with acceptance criteria.
3) Security + Audit Deep Dive
Use references/CASS-PROMPT-ARCHETYPES.md (Archetype 6).
4) Admin API Integrity Sweep
Use references/CASS-PROMPT-ARCHETYPES.md (Archetype 5).
5) Moderation Queue Slice Prompt
Use references/CASS-PROMPT-ARCHETYPES.md (Archetype 3).
6) Cross-Repo Pattern Mining Prompt
Use references/CASS-PROMPT-ARCHETYPES.md (Archetype 2).
7) World-Class Enhancement Plan Prompt
Use references/CASS-PROMPT-ARCHETYPES.md (Archetype 7).
Cass Grounding Loop (Use Before Large Admin Work)
cass status --json && cass index --json
cass search "*" --workspace /data/projects/<repo> --aggregate agent,date --limit 1 --json
cass search "admin" --workspace /data/projects/<repo> --fields minimal --limit 80 --json \
| jq '[.hits[] | select(.line_number <= 3)]'
# Follow best hits:
cass view <source_path> -n <line> -C 20
- Treat repeated prompt families as operating playbooks.
- Reuse real prompt skeletons, then generalize names/paths/constraints.
- Prefer prompts with explicit deliverables, acceptance criteria, and bug-report format.
Quick Start
rg --files src/app | rg '/admin|api/admin'
rg -n "requireAdmin|isAdmin|permission|audit|role" src
rg -n "job|queue|retry|webhook|health" src/app src/lib src/services
# Build EXISTING/PARTIAL/MISSING map via FEATURE-CATALOG
# Start with shell + permissions + audit + query patterns
Workflow (Harmonization)
- Mine cass first: collect 3-5 relevant prompt archetypes; adapt, do not invent blindly.
- Map state: pages/APIs/mutations/permissions; tag
EXISTING|PARTIAL|MISSING.
- Define IA once: one route tree, grouped nav, no parallel sections.
- Shared primitives:
AdminShell, filters/date range, cards/toolbars, table primitives.
- Unified contracts: response envelope, error codes, validation.
- Permissions: domain-action keys (
users.read, billing.adjust, ops.retry) at page/API boundaries.
- Audit high-risk actions: actor/action/target/reason/before-after/request-context.
- Operator workflows first: queues + transitions, not chart-only pages.
- Observability: jobs, failed queues + retry, provider health, freshness timestamps.
- Vertical slices: Foundation -> Users -> Billing/Ops -> Support/Moderation -> Analytics/Experiments -> Content/Comms.
- Harden before breadth: integration/E2E for dangerous flows.
Hard Invariants
- One admin shell (single nav + context).
- One permission registry (no ad-hoc inline checks).
- One audit pipeline (all privileged mutations).
- One query-key strategy (central keys + TanStack hooks).
- One mutation contract (validated input, deterministic responses).
- One ops model (status, retries, last error for async jobs).
Deliverables
- Unified route map.
- Permission matrix by domain/action.
- Admin API contract map (read + mutation).
- Audit event taxonomy.
- Phased rollout with acceptance criteria.
- Test plan for high-risk flows.
Anti-Patterns
- Many dashboards, few actions.
- Duplicate capability under different section names.
- UI-only auth checks without API enforcement.
- Privileged mutations without reason + audit.
- Ad-hoc fetches instead of shared query hooks.
- Breadth expansion before foundation hardening.
References
- Feature inventory: FEATURE-CATALOG.md
- Architecture blueprint: IMPLEMENTATION-BLUEPRINT.md
- Phased rollout: PHASED-ROLL-OUT.md
- Build/review checklist: CHECKLIST.md
- Copy-paste templates: TEMPLATES.md
- Failure modes: FAILURE-MODES.md
- Operator UX standards: OPERATOR-UX-STANDARDS.md
- Cass prompt archetypes: CASS-PROMPT-ARCHETYPES.md
Reference Index
| Need |
Open |
| Capability map |
FEATURE-CATALOG.md |
| Architecture |
IMPLEMENTATION-BLUEPRINT.md |
| Rollout |
PHASED-ROLL-OUT.md |
| Quality gates |
CHECKLIST.md |
| Templates |
TEMPLATES.md |
| Failures |
FAILURE-MODES.md |
| Operator UX |
OPERATOR-UX-STANDARDS.md |
| Cass archetypes |
CASS-PROMPT-ARCHETYPES.md |
1---2name: admin-page-for-nextjs-sites3description: Design cohesive Next.js SaaS admin cockpits. Use when building or expanding `/admin` and `/api/admin` with unified IA, permissions, audit, analytics, ops, moderation, billing, and user-management.4---56<!-- TOC: Core | Use When | Exact Prompts | Quick Start | Workflow | Invariants | Deliverables | Anti-Patterns | References -->78# Admin Page for Next.js Sites910## Use When11- Building a new Next.js admin console.12- Expanding `/admin` without duplicating capability.13- Merging multiple admin systems into one cockpit.14- Hardening privileged flows (refunds, moderation, impersonation, retries).1516## THE EXACT PROMPTS1718### 1) Build/Expand19```text20Design and implement a cohesive admin cockpit for this Next.js SaaS codebase.2122Requirements:231. Inventory `/admin` pages, APIs, permissions, data sources, jobs.242. Build a harmonized IA (Overview, Users, Billing, Support, Moderation, Content, Analytics, Experiments, Operations, Compliance, Health).253. Integrate non-duplicative features via shared primitives (shell, filters, tables, permissions, audit, response envelope).264. Implement vertical slices with explicit acceptance criteria and no parallel systems.275. Add tests for high-risk mutations and operator flows.2829Output:30- route map, API/contracts plan, data model deltas31- phased rollout plan + concrete code changes32```3334### 2) Consolidation/Audit35```text36Audit this Next.js admin system for fragmentation, risk, and missing operator workflows.3738Return:391. Overlapping capabilities to merge.402. High-risk endpoints missing permission + audit controls.413. Read-only dashboards that should become action queues.424. Missing operational controls (job retries, provider health, stale-data indicators).435. Prioritized remediation slices with acceptance criteria.44```4546### 3) Security + Audit Deep Dive47Use `references/CASS-PROMPT-ARCHETYPES.md` (Archetype 6).4849### 4) Admin API Integrity Sweep50Use `references/CASS-PROMPT-ARCHETYPES.md` (Archetype 5).5152### 5) Moderation Queue Slice Prompt53Use `references/CASS-PROMPT-ARCHETYPES.md` (Archetype 3).5455### 6) Cross-Repo Pattern Mining Prompt56Use `references/CASS-PROMPT-ARCHETYPES.md` (Archetype 2).5758### 7) World-Class Enhancement Plan Prompt59Use `references/CASS-PROMPT-ARCHETYPES.md` (Archetype 7).6061## Cass Grounding Loop (Use Before Large Admin Work)62```bash63cass status --json && cass index --json64cass search "*" --workspace /data/projects/<repo> --aggregate agent,date --limit 1 --json65cass search "admin" --workspace /data/projects/<repo> --fields minimal --limit 80 --json \66 | jq '[.hits[] | select(.line_number <= 3)]'67# Follow best hits:68cass view <source_path> -n <line> -C 2069```70- Treat repeated prompt families as operating playbooks.71- Reuse real prompt skeletons, then generalize names/paths/constraints.72- Prefer prompts with explicit deliverables, acceptance criteria, and bug-report format.7374## Quick Start75```bash76rg --files src/app | rg '/admin|api/admin'77rg -n "requireAdmin|isAdmin|permission|audit|role" src78rg -n "job|queue|retry|webhook|health" src/app src/lib src/services79# Build EXISTING/PARTIAL/MISSING map via FEATURE-CATALOG80# Start with shell + permissions + audit + query patterns81```8283## Workflow (Harmonization)841. **Mine cass first**: collect 3-5 relevant prompt archetypes; adapt, do not invent blindly.852. **Map state**: pages/APIs/mutations/permissions; tag `EXISTING|PARTIAL|MISSING`.863. **Define IA once**: one route tree, grouped nav, no parallel sections.874. **Shared primitives**: `AdminShell`, filters/date range, cards/toolbars, table primitives.885. **Unified contracts**: response envelope, error codes, validation.896. **Permissions**: domain-action keys (`users.read`, `billing.adjust`, `ops.retry`) at page/API boundaries.907. **Audit high-risk actions**: actor/action/target/reason/before-after/request-context.918. **Operator workflows first**: queues + transitions, not chart-only pages.929. **Observability**: jobs, failed queues + retry, provider health, freshness timestamps.9310. **Vertical slices**: Foundation -> Users -> Billing/Ops -> Support/Moderation -> Analytics/Experiments -> Content/Comms.9411. **Harden before breadth**: integration/E2E for dangerous flows.9596## Hard Invariants97- **One admin shell** (single nav + context).98- **One permission registry** (no ad-hoc inline checks).99- **One audit pipeline** (all privileged mutations).100- **One query-key strategy** (central keys + TanStack hooks).101- **One mutation contract** (validated input, deterministic responses).102- **One ops model** (status, retries, last error for async jobs).103104## Deliverables105- Unified route map.106- Permission matrix by domain/action.107- Admin API contract map (read + mutation).108- Audit event taxonomy.109- Phased rollout with acceptance criteria.110- Test plan for high-risk flows.111112## Anti-Patterns113- Many dashboards, few actions.114- Duplicate capability under different section names.115- UI-only auth checks without API enforcement.116- Privileged mutations without reason + audit.117- Ad-hoc fetches instead of shared query hooks.118- Breadth expansion before foundation hardening.119120## References121- Feature inventory: [FEATURE-CATALOG.md](references/FEATURE-CATALOG.md)122- Architecture blueprint: [IMPLEMENTATION-BLUEPRINT.md](references/IMPLEMENTATION-BLUEPRINT.md)123- Phased rollout: [PHASED-ROLL-OUT.md](references/PHASED-ROLL-OUT.md)124- Build/review checklist: [CHECKLIST.md](references/CHECKLIST.md)125- Copy-paste templates: [TEMPLATES.md](references/TEMPLATES.md)126- Failure modes: [FAILURE-MODES.md](references/FAILURE-MODES.md)127- Operator UX standards: [OPERATOR-UX-STANDARDS.md](references/OPERATOR-UX-STANDARDS.md)128- Cass prompt archetypes: [CASS-PROMPT-ARCHETYPES.md](references/CASS-PROMPT-ARCHETYPES.md)129130## Reference Index131132| Need | Open |133|------|------|134| Capability map | [FEATURE-CATALOG.md](references/FEATURE-CATALOG.md) |135| Architecture | [IMPLEMENTATION-BLUEPRINT.md](references/IMPLEMENTATION-BLUEPRINT.md) |136| Rollout | [PHASED-ROLL-OUT.md](references/PHASED-ROLL-OUT.md) |137| Quality gates | [CHECKLIST.md](references/CHECKLIST.md) |138| Templates | [TEMPLATES.md](references/TEMPLATES.md) |139| Failures | [FAILURE-MODES.md](references/FAILURE-MODES.md) |140| Operator UX | [OPERATOR-UX-STANDARDS.md](references/OPERATOR-UX-STANDARDS.md) |141| Cass archetypes | [CASS-PROMPT-ARCHETYPES.md](references/CASS-PROMPT-ARCHETYPES.md) |