|
| 1 | +# Next.js Production Generator - Reference Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Generates **complete production-grade Next.js 15 applications** with design system integration, Shadcn/ui components, Framer Motion animations, and Monaco Editor. |
| 6 | + |
| 7 | +## Token Efficiency |
| 8 | + |
| 9 | +- **Without Skill**: ~15,000 tokens (load Next.js docs, React docs, Tailwind docs, Framer Motion docs) |
| 10 | +- **With Skill**: ~150 tokens (SKILL.md + result) |
| 11 | +- **Reduction**: 99% |
| 12 | + |
| 13 | +## Architecture |
| 14 | + |
| 15 | +### Input Files |
| 16 | + |
| 17 | +1. **design-system.json** (Required): |
| 18 | + - Color palette (primary, secondary, accent, semantic, neutral) |
| 19 | + - Typography system (fonts, sizes, weights, line heights) |
| 20 | + - Spacing scale (4px/8px grid) |
| 21 | + - Animation presets (durations, easings, springs) |
| 22 | + - Component variants (button, input, card styles) |
| 23 | + |
| 24 | +2. **pages-structure.yaml** (Optional): |
| 25 | + - Page definitions and routes |
| 26 | + - Section layouts |
| 27 | + - Component composition |
| 28 | + |
| 29 | +### Output Structure |
| 30 | + |
| 31 | +``` |
| 32 | +frontend/ |
| 33 | +├── app/ |
| 34 | +│ ├── layout.tsx # Root layout with theme provider |
| 35 | +│ ├── page.tsx # Landing page with hero section |
| 36 | +│ ├── globals.css # Tailwind + design tokens |
| 37 | +│ ├── (auth)/ |
| 38 | +│ │ ├── login/page.tsx # Login page |
| 39 | +│ │ └── register/page.tsx # Register page |
| 40 | +│ ├── dashboard/page.tsx # Dashboard with charts |
| 41 | +│ ├── chat/page.tsx # AI chat interface |
| 42 | +│ └── practice/page.tsx # Code editor with Monaco |
| 43 | +├── components/ |
| 44 | +│ ├── ui/ # Shadcn/ui components (40+) |
| 45 | +│ ├── animations/ # Framer Motion wrappers |
| 46 | +│ └── features/ # Feature-specific components |
| 47 | +├── lib/ |
| 48 | +│ ├── design-tokens.ts # Generated from design-system.json |
| 49 | +│ ├── animation-presets.ts # Framer Motion configurations |
| 50 | +│ └── utils.ts # Utility functions (cn, etc.) |
| 51 | +├── package.json # Dependencies |
| 52 | +├── tsconfig.json # TypeScript strict mode |
| 53 | +├── tailwind.config.ts # Generated from design system |
| 54 | +├── postcss.config.js # PostCSS configuration |
| 55 | +└── next.config.js # Next.js optimization |
| 56 | +``` |
| 57 | + |
| 58 | +## Generated Features |
| 59 | + |
| 60 | +### Design System Integration |
| 61 | + |
| 62 | +- **Colors**: All colors from design-system.json imported to Tailwind config |
| 63 | +- **Typography**: Font families, sizes, weights applied consistently |
| 64 | +- **Spacing**: 4px/8px grid system enforced |
| 65 | +- **Animations**: Framer Motion presets (fadeIn, slideUp, scaleIn, stagger) |
| 66 | +- **Components**: Button, Input, Card variants with design tokens |
| 67 | + |
| 68 | +### Performance Optimization |
| 69 | + |
| 70 | +- **Code Splitting**: Automatic route-based splitting |
| 71 | +- **Dynamic Imports**: Monaco Editor, Chart libraries lazy-loaded |
| 72 | +- **Image Optimization**: Next.js Image component with WebP/AVIF |
| 73 | +- **Font Loading**: Variable fonts with font-display: swap |
| 74 | +- **Bundle Size**: Optimized imports for lucide-react, framer-motion |
| 75 | + |
| 76 | +### TypeScript Configuration |
| 77 | + |
| 78 | +- **Strict Mode**: Enabled for type safety |
| 79 | +- **Path Aliases**: `@/*` for clean imports |
| 80 | +- **No Any Types**: Enforced through strict mode |
| 81 | +- **Type Checking**: Pre-commit hook ready |
| 82 | + |
| 83 | +### Accessibility |
| 84 | + |
| 85 | +- **Semantic HTML**: Proper heading hierarchy, landmarks |
| 86 | +- **ARIA Labels**: All interactive elements labeled |
| 87 | +- **Keyboard Navigation**: Tab order, focus indicators |
| 88 | +- **Color Contrast**: 4.5:1 minimum (from design system) |
| 89 | + |
| 90 | +## Usage Examples |
| 91 | + |
| 92 | +### Basic Generation |
| 93 | + |
| 94 | +```bash |
| 95 | +python3 scripts/generate_complete_app.py \ |
| 96 | + --design-system ../../design-system.json \ |
| 97 | + --output frontend/ |
| 98 | +``` |
| 99 | + |
| 100 | +### With Custom Pages |
| 101 | + |
| 102 | +```bash |
| 103 | +# Create pages-structure.yaml |
| 104 | +cat > pages-structure.yaml << EOF |
| 105 | +pages: |
| 106 | + - name: landing |
| 107 | + route: / |
| 108 | + sections: [hero, features, testimonials, pricing] |
| 109 | + - name: dashboard |
| 110 | + route: /dashboard |
| 111 | + sections: [stats, progress, activity] |
| 112 | +EOF |
| 113 | + |
| 114 | +# Generate with custom structure |
| 115 | +python3 scripts/generate_complete_app.py \ |
| 116 | + --design-system ../../design-system.json \ |
| 117 | + --pages pages-structure.yaml \ |
| 118 | + --output frontend/ |
| 119 | +``` |
| 120 | + |
| 121 | +### Development Workflow |
| 122 | + |
| 123 | +```bash |
| 124 | +# 1. Generate application |
| 125 | +python3 scripts/generate_complete_app.py \ |
| 126 | + --design-system design-system.json \ |
| 127 | + --output frontend/ |
| 128 | + |
| 129 | +# 2. Install dependencies |
| 130 | +cd frontend && npm install |
| 131 | + |
| 132 | +# 3. Start development server |
| 133 | +npm run dev |
| 134 | + |
| 135 | +# 4. Build for production |
| 136 | +npm run build |
| 137 | + |
| 138 | +# 5. Run type checking |
| 139 | +npm run type-check |
| 140 | +``` |
| 141 | + |
| 142 | +## Design System Requirements |
| 143 | + |
| 144 | +### Minimum Required Sections |
| 145 | + |
| 146 | +```json |
| 147 | +{ |
| 148 | + "colors": { |
| 149 | + "brand": { "primary": {...}, "secondary": {...}, "accent": {...} }, |
| 150 | + "semantic": { "success": {...}, "warning": {...}, "error": {...} }, |
| 151 | + "neutral": { "50": "...", "100": "...", ..., "950": "..." } |
| 152 | + }, |
| 153 | + "typography": { |
| 154 | + "fontFamily": { "sans": "...", "mono": "..." }, |
| 155 | + "fontSize": { "xs": "...", "sm": "...", ..., "9xl": "..." } |
| 156 | + }, |
| 157 | + "spacing": { |
| 158 | + "scale": { "0": "0px", "1": "4px", ..., "64": "256px" } |
| 159 | + }, |
| 160 | + "animations": { |
| 161 | + "durations": { "fast": 150, "normal": 300, "slow": 500 }, |
| 162 | + "easings": { "easeIn": "...", "easeOut": "...", "spring": "..." }, |
| 163 | + "presets": { "fadeIn": {...}, "slideUp": {...}, "scaleIn": {...} } |
| 164 | + } |
| 165 | +} |
| 166 | +``` |
| 167 | + |
| 168 | +## Customization |
| 169 | + |
| 170 | +### Adding New Pages |
| 171 | + |
| 172 | +1. Create page component in `app/` directory |
| 173 | +2. Use design tokens from `lib/design-tokens.ts` |
| 174 | +3. Apply animations from `lib/animation-presets.ts` |
| 175 | +4. Follow existing patterns for consistency |
| 176 | + |
| 177 | +### Adding New Components |
| 178 | + |
| 179 | +1. Create component in `components/` directory |
| 180 | +2. Import design tokens: `import { designTokens } from '@/lib/design-tokens'` |
| 181 | +3. Use Framer Motion: `import { motion } from 'framer-motion'` |
| 182 | +4. Apply animations: `import { animations } from '@/lib/animation-presets'` |
| 183 | + |
| 184 | +### Modifying Design System |
| 185 | + |
| 186 | +1. Update `design-system.json` |
| 187 | +2. Regenerate application: `python3 scripts/generate_complete_app.py ...` |
| 188 | +3. All components automatically use new tokens |
| 189 | + |
| 190 | +## Performance Targets |
| 191 | + |
| 192 | +- **Lighthouse Performance**: ≥95 |
| 193 | +- **First Contentful Paint**: <1.2s |
| 194 | +- **Time to Interactive**: <3s |
| 195 | +- **Largest Contentful Paint**: <2.5s |
| 196 | +- **Cumulative Layout Shift**: <0.1 |
| 197 | +- **Bundle Size**: JS <250KB, CSS <50KB (gzipped) |
| 198 | + |
| 199 | +## Troubleshooting |
| 200 | + |
| 201 | +### Build Errors |
| 202 | + |
| 203 | +**Issue**: TypeScript compilation errors |
| 204 | +**Solution**: Run `npm run type-check` to see detailed errors. Ensure all imports are correct. |
| 205 | + |
| 206 | +**Issue**: Tailwind classes not working |
| 207 | +**Solution**: Verify `tailwind.config.ts` includes all content paths. Run `npm run dev` to regenerate. |
| 208 | + |
| 209 | +### Runtime Errors |
| 210 | + |
| 211 | +**Issue**: Hydration mismatch |
| 212 | +**Solution**: Ensure client-only components use `'use client'` directive. Check for SSR-incompatible code. |
| 213 | + |
| 214 | +**Issue**: Monaco Editor not loading |
| 215 | +**Solution**: Verify dynamic import with `ssr: false`. Check browser console for errors. |
| 216 | + |
| 217 | +### Performance Issues |
| 218 | + |
| 219 | +**Issue**: Large bundle size |
| 220 | +**Solution**: Run `npm run build` and check `.next/analyze`. Ensure dynamic imports for heavy components. |
| 221 | + |
| 222 | +**Issue**: Slow page loads |
| 223 | +**Solution**: Check image optimization. Ensure WebP/AVIF formats. Use `priority` prop for above-fold images. |
| 224 | + |
| 225 | +## Integration with Other Skills |
| 226 | + |
| 227 | +### With `fastapi-dapr-agent` |
| 228 | + |
| 229 | +```bash |
| 230 | +# Generate backend |
| 231 | +python3 .claude/skills/fastapi-dapr-agent/scripts/generate_complete_agent.py triage backend/triage_agent |
| 232 | + |
| 233 | +# Generate frontend |
| 234 | +python3 .claude/skills/nextjs-production-gen/scripts/generate_complete_app.py \ |
| 235 | + --design-system design-system.json \ |
| 236 | + --output frontend/ |
| 237 | + |
| 238 | +# Frontend automatically configured to call backend at http://localhost:8000 |
| 239 | +``` |
| 240 | + |
| 241 | +### With `performance-optimizer` |
| 242 | + |
| 243 | +```bash |
| 244 | +# Generate application |
| 245 | +python3 scripts/generate_complete_app.py ... |
| 246 | + |
| 247 | +# Optimize |
| 248 | +python3 .claude/skills/performance-optimizer/scripts/optimize.py \ |
| 249 | + --app-path frontend/ \ |
| 250 | + --target lighthouse-95 |
| 251 | +``` |
| 252 | + |
| 253 | +### With `accessibility-validator` |
| 254 | + |
| 255 | +```bash |
| 256 | +# Generate application |
| 257 | +python3 scripts/generate_complete_app.py ... |
| 258 | + |
| 259 | +# Validate |
| 260 | +python3 .claude/skills/accessibility-validator/scripts/validate.py \ |
| 261 | + --url http://localhost:3000 \ |
| 262 | + --standard wcag22-aa |
| 263 | +``` |
| 264 | + |
| 265 | +## Best Practices |
| 266 | + |
| 267 | +1. **Design System First**: Create comprehensive design-system.json before generation |
| 268 | +2. **Consistent Tokens**: Never hardcode colors, spacing, or animation values |
| 269 | +3. **Type Safety**: Enable TypeScript strict mode, avoid `any` types |
| 270 | +4. **Performance**: Use dynamic imports for heavy components (Monaco, Charts) |
| 271 | +5. **Accessibility**: Test with keyboard navigation, screen readers |
| 272 | +6. **Responsive**: Test on mobile (375px), tablet (768px), desktop (1440px) |
| 273 | + |
| 274 | +## Limitations |
| 275 | + |
| 276 | +- **Subjective Design**: Cannot make aesthetic decisions (color palette selection, visual hierarchy) |
| 277 | +- **Content Creation**: Does not generate marketing copy, images, or videos |
| 278 | +- **Custom Logic**: Complex business logic requires manual implementation |
| 279 | +- **Third-Party APIs**: Integration with external services requires manual configuration |
| 280 | + |
| 281 | +## Version History |
| 282 | + |
| 283 | +- **v1.0.0** (2026-01-06): Initial release with design system integration |
| 284 | + - Next.js 15 with App Router |
| 285 | + - Shadcn/ui components |
| 286 | + - Framer Motion animations |
| 287 | + - Monaco Editor integration |
| 288 | + - TypeScript strict mode |
| 289 | + - Performance optimization |
0 commit comments