skill · from the nextjs-expert plugin
/scaffold
Scaffold Next.js components following best practices
- nextjs-expert plugin
- Slash command
you ›install the nextjs-expert plugin
metaphor ›Installed nextjs-expert. /scaffold is ready.
you ›/scaffold
metaphor ›Loaded the scaffold skill. What should I work on?
What the agent is told
This is the skill's SKILL.md, exactly what Metaphor reads before the task.
You are scaffolding a Next.js component or page following App Router best practices.
Workflow
Step 1: Gather Requirements
Ask the user what they want to scaffold:
- Page: A new route with page.tsx
- Layout: A shared layout for routes
- Server Component: A data-fetching component
- Client Component: An interactive component
- API Route: A route handler
- Server Action: A mutation function
- Loading/Error: Loading and error states
Step 2: Analyze Existing Patterns
Before scaffolding, examine the codebase:
Check existing component structure:
- Look at
app/directory structure - Check
components/organization - Note existing patterns for server vs client
- Look at
Identify conventions:
- TypeScript patterns used
- Styling approach (Tailwind, CSS Modules, etc.)
- Data fetching patterns
- Error handling patterns
Step 3: Apply Skills
Based on what the user wants, apply the appropriate skill:
- For pages and routing: Use
app-routerskill - For component decisions: Use
server-componentsskill - For API routes: Use
route-handlersskill - For mutations: Use
server-actionsskill - For protected routes: Use
auth-patternsskill
Step 4: Generate Code
Create the component following:
- Next.js 15 conventions
- Async params/searchParams (Promise-based)
- Proper TypeScript types
- Existing project patterns
Step 5: Verify
After scaffolding:
- Ensure imports are correct
- Check TypeScript types
- Confirm file placement matches App Router conventions
Examples
Scaffold a Page
When user asks: "Create a blog post page"
- Create
app/blog/[slug]/page.tsx:
interface PageProps {
params: Promise<{ slug: string }>
}
export default async function BlogPostPage({ params }: PageProps) {
const { slug } = await params
// ... fetch and render
}
- Add
loading.tsxanderror.tsxif needed
Scaffold a Client Component
When user asks: "Create a search filter component"
- Create in
components/with 'use client' - Keep it minimal - only client code that needs state
- Follow existing naming conventions
Scaffold an API Route
When user asks: "Create a users API endpoint"
- Create
app/api/users/route.ts - Include GET, POST as needed
- Add proper error handling and validation
Questions
What is the scaffold skill?
Scaffold Next.js components following best practices
How do I use scaffold in Metaphor?
Install the nextjs-expert plugin by asking the agent "install the nextjs-expert plugin", then type /scaffold in the composer.
What is a skill?
A skill is a set of written instructions the agent reads before it starts a kind of task. It changes how the agent works, not what it is allowed to do.
More from nextjs-expert
- /add-authSkillAdd authentication to a Next.js applicationin nextjs-expert
- /app-routerSkillThis skill should be used when the user asks to "create a Next.js route", "add a page", "set up layouts", "implement loading states", "add error boundaries"…in nextjs-expert
- /auth-patternsSkillThis skill should be used when the user asks about "authentication in Next.js", "NextAuth", "Auth.js", "middleware auth", "protected routes", "session…in nextjs-expert
- /optimizeSkillAnalyze and optimize Next.js application performancein nextjs-expert
- /route-handlersSkillThis skill should be used when the user asks to "create an API route", "add an endpoint", "build a REST API", "handle POST requests", "create route handlers"…in nextjs-expert
- /server-actionsSkillThis skill should be used when the user asks about "Server Actions", "form handling in Next.js", "mutations", "useFormState", "useFormStatus"…in nextjs-expert