nextjs-scaffold — команда для Claude Code: что делает и как установить
Разворачивает каркас приложения Next.js с готовой структурой папок, App Router, правилами ESLint и базовой защитой.
npx claude-code-templates@latest --command nextjs-vercel/nextjs-scaffoldЧто делает nextjs-scaffold
Команда анализирует рабочую папку и проверяет версии Node.js и npm. Дальше она создаёт каркас Next.js с App Router. Внутрь попадают заготовки layout.tsx и page.tsx с подключением шрифта Inter.
Конфигурационный файл next.config.js получает заголовки X-Frame-Options и X-Content-Type-Options. Туда же добавляется оптимизация картинок для форматов WebP и AVIF. При передаче флагов шаблон настраивает TypeScript и Tailwind CSS.
В системе обязательно нужны Node.js и npm. После генерации шаблон сразу запускает сборку npm run build и валидацию типов через tsc --noEmit.
Какие задачи решает
- сгенерировать файловую структуру проекта Next.js с App Router
- прописать базовые заголовки безопасности и правила оптимизации картинок
- подключить конфигурации TypeScript, Tailwind CSS и ESLint
- подготовить шаблоны переменных окружения
.env.localи.env.example
Примеры запросов агенту
- /nextjs-scaffold
my-portal --typescript --tailwind --app-router - /nextjs-scaffold
landing-page --tailwind - /nextjs-scaffold
internal-tool --typescript
Как установить nextjs-scaffold
1Через claude-code-templates
npx claude-code-templates@latest --command nextjs-vercel/nextjs-scaffold2Вручную: положить файлы
.claude/commands/nextjs-scaffold.mdВызов — /nextjs-scaffold. Для всех проектов — ~/.claude/commands/
Вручную: положить файлы
~/.codex/prompts/nextjs-scaffold.mdВызов — /prompts:nextjs-scaffold. В Codex этот формат помечен устаревшим, замена — скиллы
Вручную: положить файлы
.github/prompts/nextjs-scaffold.prompt.mdВручную: положить файлы
.gemini/commands/nextjs-scaffold.tomlGemini хранит команды в TOML: текст запроса — в поле prompt
Вопросы о nextjs-scaffold
Как установить nextjs-scaffold в Claude Code?
Выполните команду npx claude-code-templates@latest --command nextjs-vercel/nextjs-scaffold или сохраните файл команды по пути .claude/commands/nextjs-scaffold.md.
Что делает команда nextjs-scaffold?
Она автоматизирует начальную настройку приложения Next.js, генерируя файлы структуры, базовые компоненты и сценарии сборки в package.json.
Какие инструменты задействует команда?
Шаблону требуется доступ к инструментам Read, Write, Edit и вызовам командной строки через Bash.
Исходный текст
nextjs-scaffold.md · MIT
---
allowed-tools: Read, Write, Edit, Bash
argument-hint: "[project-name] [--typescript] [--tailwind] [--app-router]"
description: Create a new Next.js application with best practices and optimal configuration
---
## Next.js Application Scaffolding
**Project Name**: $ARGUMENTS
## Environment Analysis
- Current directory: !`pwd`
- Node.js version: !`node --version`
- npm version: !`npm --version`
- Existing package.json: @package.json (if exists)
## Scaffolding Requirements
### 1. Project Initialization
Based on provided arguments, determine setup options:
- **TypeScript**: Check for `--typescript` flag or detect existing TS config
- **Tailwind CSS**: Check for `--tailwind` flag or detect existing config
- **App Router**: Check for `--app-router` flag (default for new projects)
- **ESLint/Prettier**: Always include for code quality
### 2. Next.js Configuration
Create optimized `next.config.js` with:
```javascript
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
optimizePackageImports: ['lucide-react', '@heroicons/react'],
},
images: {
formats: ['image/webp', 'image/avif'],
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
},
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'X-Frame-Options',
value: 'DENY',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
],
},
];
},
};
```
### 3. Essential Dependencies
Install core dependencies:
- **Production**: `next`, `react`, `react-dom`
- **Development**: `eslint`, `eslint-config-next`, `typescript` (if TS), `@types/*` (if TS)
- **Optional**: `tailwindcss`, `prettier`, `husky`, `lint-staged`
### 4. Project Structure
Create optimal directory structure:
```
project-name/
├── app/ # App Router (Next.js 13+)
│ ├── globals.css
│ ├── layout.tsx
│ ├── page.tsx
│ └── api/
├── components/ # Reusable components
│ └── ui/ # UI primitives
├── lib/ # Utilities and configurations
├── public/ # Static assets
├── types/ # TypeScript type definitions
├── .env.local # Environment variables
├── .env.example # Environment template
├── .gitignore
├── next.config.js
├── package.json
├── README.md
└── tsconfig.json # If TypeScript
```
### 5. Configuration Files
#### ESLint Configuration
```json
{
"extends": ["next/core-web-vitals"],
"rules": {
"@next/next/no-img-element": "error",
"@next/next/no-html-link-for-pages": "error"
}
}
```
#### TypeScript Configuration (if applicable)
```json
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "es6"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
```
### 6. Starter Components
#### Root Layout
```typescript
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
import './globals.css';
const inter = Inter({ subsets: ['latin'] });
export const metadata: Metadata = {
title: 'Project Name',
description: 'Generated with Claude Code Next.js scaffolding',
};
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
);
}
```
#### Home Page
```typescript
export default function Home() {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<div className="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm">
<h1 className="text-4xl font-bold">Welcome to Your Next.js App</h1>
<p className="mt-4 text-lg">
Built with Claude Code scaffolding
</p>
</div>
</main>
);
}
```
### 7. Development Scripts
Update package.json with optimized scripts:
```json
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"type-check": "tsc --noEmit",
"format": "prettier --write .",
"format:check": "prettier --check ."
}
}
```
### 8. Documentation
Create comprehensive README.md with:
- Project overview and features
- Installation and setup instructions
- Development workflow
- Deployment guidelines
- Contributing guidelines
## Implementation Steps
1. **Initialize Project**: Create project directory and basic structure
2. **Install Dependencies**: Set up Next.js with chosen options
3. **Configure TypeScript**: Set up TypeScript if requested
4. **Setup Tailwind**: Configure Tailwind CSS if requested
5. **Create Components**: Generate starter components and layouts
6. **Setup Development Tools**: Configure ESLint, Prettier, and scripts
7. **Environment Configuration**: Create .env files and examples
8. **Generate Documentation**: Create README and setup guides
## Quality Checklist
- [ ] Next.js configured with App Router
- [ ] TypeScript setup (if requested)
- [ ] Tailwind CSS configured (if requested)
- [ ] ESLint and Prettier configured
- [ ] Security headers configured
- [ ] Image optimization enabled
- [ ] Development scripts working
- [ ] Environment variables template created
- [ ] README documentation complete
- [ ] Project builds successfully
## Post-Scaffolding Tasks
After scaffolding, run these commands to verify setup:
```bash
cd [project-name]
npm install
npm run build
npm run lint
npm run type-check # If TypeScript
```
Provide specific next steps based on the project requirements and any additional features needed.
© davila7 · MIT · davila7/claude-code-templates