Created
February 25, 2026 14:29
-
-
Save imderek/6ef27064d6ea2627550b2591ee7f1852 to your computer and use it in GitHub Desktop.
Generate and verify new Next.js App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # π Generate New Next.js App | |
| ## What This Command Does | |
| - Creates a new Next.js application using the latest version | |
| - Configures TypeScript, Tailwind CSS, ESLint, and App Router | |
| - Sets up the project structure with best practices | |
| - Performs automatic verification of the setup | |
| - Provides manual validation instructions | |
| ## Where to Run This Command | |
| Run this command from your **home directory** (`~/`). The command will create the new Next.js app in `~/apps/[APP_NAME]`. | |
| ## Instructions for the Agent | |
| You are creating a new Next.js application from scratch. Use the latest Next.js with TypeScript, Tailwind CSS, ESLint, and the App Router. | |
| ### Step 1: Ask for app name | |
| Ask the user what they want to name the new project. This will be used as the directory name. | |
| If not provided, suggest they provide a name before proceeding. | |
| ### Step 2: Ensure ~/apps directory exists | |
| Create the apps directory if it doesn't exist: | |
| ```bash | |
| mkdir -p ~/apps | |
| ``` | |
| ### Step 3: Safety check - verify app directory doesn't exist | |
| Before creating anything, check if the target directory already exists: | |
| ```bash | |
| if [ -d ~/apps/[APP_NAME] ]; then | |
| echo "β Error: ~/apps/[APP_NAME] already exists" | |
| echo "Please choose a different name or remove the existing directory" | |
| exit 1 | |
| fi | |
| ``` | |
| Replace `[APP_NAME]` with the actual app name from Step 1. | |
| If the directory exists, stop immediately and inform the user. Do not proceed with generation. | |
| ### Step 4: Generate the Next.js app | |
| Run the create-next-app command in the ~/apps directory: | |
| ```bash | |
| cd ~/apps | |
| npx create-next-app@latest test-app --typescript --tailwind --eslint --app --no-src-dir --import-alias "@/*" --yes | |
| ``` | |
| Replace `[APP_NAME]` with the actual app name from Step 1. | |
| ### Step 5: Navigate to the new app directory | |
| ```bash | |
| cd ~/apps/[APP_NAME] | |
| ``` | |
| ### Step 6: Automatic Verification | |
| After generation, verify the following automatically: | |
| 1. **Check key files exist:** | |
| ```bash | |
| test -f package.json && echo "β package.json exists" || echo "β package.json missing" | |
| test -f tsconfig.json && echo "β tsconfig.json exists" || echo "β tsconfig.json missing" | |
| test -f tailwind.config.ts && echo "β tailwind.config.ts exists" || echo "β tailwind.config.ts missing" | |
| test -f next.config.js && echo "β next.config.js exists" || echo "β next.config.js missing" | |
| test -f .eslintrc.json && echo "β .eslintrc.json exists" || echo "β .eslintrc.json missing" | |
| test -d app && echo "β app directory exists" || echo "β app directory missing" | |
| ``` | |
| 2. **Verify package.json scripts:** | |
| ```bash | |
| grep -q '"dev"' package.json && echo "β dev script exists" || echo "β dev script missing" | |
| grep -q '"build"' package.json && echo "β build script exists" || echo "β build script missing" | |
| grep -q '"start"' package.json && echo "β start script exists" || echo "β start script missing" | |
| grep -q '"lint"' package.json && echo "β lint script exists" || echo "β lint script missing" | |
| ``` | |
| 3. **Check TypeScript configuration:** | |
| ```bash | |
| grep -q '"@/*"' tsconfig.json && echo "β path alias configured" || echo "β path alias missing" | |
| ``` | |
| 4. **Verify app structure:** | |
| ```bash | |
| test -f app/layout.tsx && echo "β app/layout.tsx exists" || echo "β app/layout.tsx missing" | |
| test -f app/page.tsx && echo "β app/page.tsx exists" || echo "β app/page.tsx missing" | |
| test -f app/globals.css && echo "β app/globals.css exists" || echo "β app/globals.css missing" | |
| ``` | |
| 5. **Check dependencies:** | |
| ```bash | |
| grep -q '"next"' package.json && echo "β next dependency exists" || echo "β next dependency missing" | |
| grep -q '"react"' package.json && echo "β react dependency exists" || echo "β react dependency missing" | |
| grep -q '"typescript"' package.json && echo "β typescript dependency exists" || echo "β typescript dependency missing" | |
| grep -q '"tailwindcss"' package.json && echo "β tailwindcss dependency exists" || echo "β tailwindcss dependency missing" | |
| ``` | |
| ### Step 7: Output Summary | |
| After verification, output a summary: | |
| ``` | |
| β Next.js app generation complete! | |
| π App directory: ~/apps/[APP_NAME] | |
| π¦ Package manager: npm | |
| βοΈ Configuration: | |
| - TypeScript: β | |
| - Tailwind CSS: β | |
| - ESLint: β | |
| - App Router: β | |
| - Import alias (@/*): β | |
| π Verification Results: | |
| [Output all verification results from Step 6] | |
| π― Next Steps: | |
| 1. In Cursor: File β Open Folder β ~/apps/[APP_NAME] | |
| 2. npm run dev | |
| 3. Open http://localhost:3000 in your browser | |
| ``` | |
| ### Step 8: Manual Validation Instructions | |
| Provide the user with these manual validation steps: | |
| ``` | |
| π Manual Validation Checklist: | |
| 1. **Open the new app in Cursor:** | |
| File β Open Folder β ~/apps/[APP_NAME] | |
| 2. **Start the development server:** | |
| npm run dev | |
| Expected: Server starts on http://localhost:3000 without errors | |
| 3. **Verify the homepage loads:** | |
| - Open http://localhost:3000 in your browser | |
| - Should see the default Next.js welcome page | |
| - Page should have Tailwind CSS styling applied | |
| 4. **Check TypeScript compilation:** | |
| - Look for any TypeScript errors in the terminal | |
| - Should compile without errors | |
| 5. **Verify file structure:** | |
| - app/layout.tsx should exist and export a RootLayout | |
| - app/page.tsx should exist and export a default component | |
| - app/globals.css should contain Tailwind directives | |
| 6. **Test hot reload:** | |
| - Edit app/page.tsx | |
| - Save the file | |
| - Browser should automatically refresh with changes | |
| 7. **Run linting:** | |
| npm run lint | |
| Expected: No linting errors (or only warnings) | |
| 8. **Test build:** | |
| npm run build | |
| Expected: Build completes successfully with no errors | |
| β If all checks pass, your Next.js app is ready to use! | |
| ``` | |
| ## Tags | |
| nextjs, setup, typescript, tailwind, app-router, verification |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment