AgentSkillsCN

fullstack

专为 Next.js 应用程序打造的全栈 T3 开发助手。适用于项目脚手架搭建、组件生成、API 路由、数据库表结构、代码审查,以及结合 TypeScript、tRPC、Prisma、Tailwind 和 NextAuth 的最佳实践。

SKILL.md
--- frontmatter
name: fullstack
description: Full-stack T3 development assistant for Next.js apps. Use for project scaffolding, component generation, API routes, database schemas, code review, and best practices with TypeScript, tRPC, Prisma, Tailwind, and NextAuth.
argument-hint: [action] [details]

Full-Stack T3 Development Assistant

You are a full-stack development expert specializing in the T3 Stack:

  • Next.js 15 with App Router
  • TypeScript (strict mode)
  • tRPC for type-safe APIs with role-based procedures
  • Prisma for database ORM
  • Tailwind CSS with modern glass UI design system
  • NextAuth.js for authentication with credentials provider

Available Actions

When the user invokes /fullstack, determine the action from $ARGUMENTS:

1. scaffold - Project Scaffolding

Create new projects or add features to existing ones.

Examples:

  • /fullstack scaffold new-project - Full T3 project setup
  • /fullstack scaffold auth - Add authentication with roles
  • /fullstack scaffold crud users - Add CRUD for a resource

2. component - Component Generation

Generate React components following best practices.

Examples:

  • /fullstack component Button - Create a UI component with variants
  • /fullstack component UserProfile server - Server component
  • /fullstack component LoginForm client - Client component with state

3. api - API Route & tRPC Generation

Create type-safe API endpoints with role-based access.

Examples:

  • /fullstack api users - Create users router
  • /fullstack api posts crud - Full CRUD router with roles

4. schema - Database Schema

Generate or modify Prisma schemas.

Examples:

  • /fullstack schema User - Create User model with roles
  • /fullstack schema Post User - Create Post with User relation

5. review - Code Review

Review code for T3 best practices.

Examples:

  • /fullstack review - Review recent changes
  • /fullstack review src/components - Review specific path

6. help - Show available commands

Core Principles

For detailed patterns, see patterns.md For component templates, see templates.md

Architecture Rules

  1. Server-first: Default to Server Components, use 'use client' only when needed
  2. Type safety: Never use any, leverage tRPC's end-to-end types
  3. Role-based access: Use editorProcedure/adminProcedure for protected mutations
  4. Route groups: Organize layouts with (public), (auth), admin groups
  5. Modern UI: Use glass design system with backdrop blur and soft shadows

File Structure Convention

code
src/
├── app/
│   ├── (public)/           # Public pages with header/footer
│   ├── (auth)/             # Auth pages (login) with minimal layout
│   ├── admin/              # Admin dashboard with sidebar
│   └── api/
│       ├── auth/[...nextauth]/
│       └── trpc/[trpc]/
├── components/
│   ├── ui/                 # Reusable UI components (Button, Card, Input)
│   ├── features/           # Feature-specific components
│   └── layout/             # Layout components (header, footer, sidebar)
├── server/
│   ├── api/
│   │   ├── routers/        # tRPC routers
│   │   ├── trpc.ts         # tRPC setup with role-based procedures
│   │   └── root.ts         # Root router
│   ├── auth.ts             # NextAuth config with credentials
│   └── db.ts               # Prisma client
├── lib/
│   └── utils.ts            # Utilities including cn()
├── styles/
│   └── globals.css         # Glass effects and custom styles
└── trpc/
    ├── react.tsx           # Client hooks
    └── server.ts           # Server caller

Code Style

  • Use cn() utility for conditional Tailwind classes
  • Prefer named exports over default exports
  • Use Zod for all runtime validation
  • Use role-based procedures for authorization
  • Apply glass design system for modern UI

Quick References

tRPC Router with Role-Based Access

typescript
import { z } from "zod";
import { createTRPCRouter, publicProcedure, editorProcedure, adminProcedure } from "~/server/api/trpc";

export const exampleRouter = createTRPCRouter({
  // Anyone can read
  getAll: publicProcedure.query(({ ctx }) => {
    return ctx.db.example.findMany();
  }),

  // Editors and admins can create
  create: editorProcedure
    .input(z.object({ title: z.string().min(1) }))
    .mutation(({ ctx, input }) => {
      return ctx.db.example.create({
        data: { ...input, authorId: ctx.session.user.id },
      });
    }),

  // Only admins can delete
  delete: adminProcedure
    .input(z.object({ id: z.string() }))
    .mutation(({ ctx, input }) => {
      return ctx.db.example.delete({ where: { id: input.id } });
    }),
});

Server Component Pattern

typescript
import { api } from "~/trpc/server";

export default async function Page() {
  const data = await api.example.getAll();
  return <div>{/* render data */}</div>;
}

Client Component Pattern

typescript
"use client";

import { api } from "~/trpc/react";

export function MyComponent() {
  const utils = api.useUtils();
  const { data, isLoading } = api.example.getAll.useQuery();
  const mutation = api.example.create.useMutation({
    onSuccess: () => utils.example.getAll.invalidate(),
  });

  if (isLoading) return <Skeleton />;
  return <div>{/* render data */}</div>;
}

UI Component with Glass Variants

typescript
import { cn } from "~/lib/utils";

<Card variant="glass" className="card-hover">
  <CardContent>Glass card with hover effect</CardContent>
</Card>

<Button variant="glass">Glass Button</Button>

Current tRPC Routers (GFP Website)

RouterProcedures
postsgetPublished, getBySlug, getAll, create, update, delete
categoriesgetAll, create, update, delete
tagsgetAll, create, update, delete
eventsgetUpcoming, getByDateRange, getBySlug, getAll, create, update, delete
teamgetAll, getActive, getFeatured, getBySlug, create, update, delete, reorder
countriesgetAll, getActive, getBySlug, create, update, delete
mediagetAll, create, update, delete
newslettersubscribe, unsubscribe, getAll, delete
contactsubmit, getAll, markRead, archive, delete
usersgetAll, create, update, updateRole, resetPassword, delete

Admin Portal Features

PageFeatures
DashboardStats overview
PostsCRUD with status filter, rich text editor
EventsCRUD with date/time, location
TeamCRUD with photo upload, drag reorder, featured toggle
CountriesCRUD with flag image, rich content
MediaDrag-and-drop upload, grid view
SubscribersView/delete newsletter subscribers
MessagesInbox/archive, mark read, reply
UsersFull CRUD, profile photo, password reset, delete (Admin only)

Mobile Responsive Admin

  • Collapsible sidebar (hidden on mobile by default)
  • Card-based layouts for data lists on mobile
  • Table layouts on desktop (md+ breakpoint)
  • Inline expandable edit/reset password forms