--- name: preview-mode description: > Show-before-commit previews — after completing work, present what changed as a live dev-server URL or a concise plain-language description so the user can confirm or request changes with confidence. Use when delivering visible changes (pages, components, styling) to a running project. user-invocable: false # internal — model-invoked via toh-* commands, not a user /command --- # 👁ïļ Preview Mode Skill > **Purpose:** Show users what will change before applying > **Version:** 1.0.0 > **Author:** Toh Framework Team ## Overview This skill enables AI to show previews of changes before applying them, giving users confidence in what's being created. ## Core Principle ``` AI completes work ↓ Show preview (description + URL if available) ↓ User confirms or requests changes ↓ Apply changes (or iterate) ``` **SEE BEFORE COMMIT** --- ## Preview Types ### Type 1: Dev Server Preview (Live) When dev server is running: ```markdown ✅ **āļŠāļĢāđ‰āļēāļ‡ Dashboard āđ€āļŠāļĢāđ‡āļˆāđāļĨāđ‰āļ§!** 👁ïļ **Preview:** 🌐 http://localhost:3000/dashboard ðŸ“ļ **āļŠāļīāđˆāļ‡āļ—āļĩāđˆāļŠāļĢāđ‰āļēāļ‡:** - Header āļžāļĢāđ‰āļ­āļĄ navigation - Stats cards (4 āļ•āļąāļ§) - Sales chart - Recent orders table āđ€āļ›āļīāļ” URL āļ”āđ‰āļēāļ™āļšāļ™āđ€āļžāļ·āđˆāļ­āļ”āļđ preview āđ„āļ”āđ‰āđ€āļĨāļĒāļ„āļĢāļąāļš! ðŸ’Ą āļ•āđ‰āļ­āļ‡āļāļēāļĢāđāļāđ‰āđ„āļ‚āļ­āļ°āđ„āļĢāđ„āļŦāļĄāļ„āļĢāļąāļš? ``` ### Type 2: Description Preview (No Server) When dev server isn't running: ```markdown ✅ **āđ€āļ•āļĢāļĩāļĒāļĄ Dashboard āļžāļĢāđ‰āļ­āļĄāđāļĨāđ‰āļ§!** 📋 **Preview āļŠāļīāđˆāļ‡āļ—āļĩāđˆāļˆāļ°āļŠāļĢāđ‰āļēāļ‡:** **Layout:** ┌─────────────────────────────────────┐ │ ðŸ”ĩ Header (Logo + Nav + Profile) │ ├─────────────────────────────────────â”Ī │ 📊 Stats Cards (4 columns) │ │ ┌───┐ ┌───┐ ┌───┐ ┌───┐ │ │ │ $ │ │ ðŸ“Ķ│ │ ðŸ‘Ĩ│ │ 📈│ │ │ └───┘ └───┘ └───┘ └───┘ │ ├─────────────────────────────────────â”Ī │ 📈 Sales Chart (Line/Bar) │ │ [Chart area] │ ├─────────────────────────────────────â”Ī │ 📋 Recent Orders Table │ │ ID | Customer | Amount | Status │ └─────────────────────────────────────┘ **Components:** - StatsCard.tsx (reusable) - SalesChart.tsx (with Recharts) - OrdersTable.tsx (with pagination) āļŠāļĢāđ‰āļēāļ‡āđ€āļĨāļĒāđ„āļŦāļĄāļ„āļĢāļąāļš? āļŦāļĢāļ·āļ­āļ•āđ‰āļ­āļ‡āļāļēāļĢāļ›āļĢāļąāļšāļ­āļ°āđ„āļĢāļāđˆāļ­āļ™? ``` ### Type 3: Before/After Preview (Modifications) When modifying existing code: ```markdown 🔄 **Preview āļāļēāļĢāđ€āļ›āļĨāļĩāđˆāļĒāļ™āđāļ›āļĨāļ‡:** **Before:** ```tsx ``` **After:** ```tsx ``` **Changes:** - ✅ āđ€āļžāļīāđˆāļĄ onClick handler - ✅ āđ€āļžāļīāđˆāļĄ loading state - ✅ āđ€āļžāļīāđˆāļĄ Spinner component Apply āļāļēāļĢāđ€āļ›āļĨāļĩāđˆāļĒāļ™āđāļ›āļĨāļ‡āļ™āļĩāđ‰āđ„āļŦāļĄāļ„āļĢāļąāļš? ``` --- ## Auto Dev Server Detection AI should detect if dev server is running: ```javascript // Check if localhost:3000 is accessible // If yes → Provide live URL // If no → Provide description preview ``` ### With Dev Server ```markdown 👁ïļ **Live Preview āļžāļĢāđ‰āļ­āļĄāđāļĨāđ‰āļ§:** 🌐 http://localhost:3000/[path] (āđ€āļ›āļīāļ”āļ”āļđāđ„āļ”āđ‰āđ€āļĨāļĒāļ„āļĢāļąāļš!) ``` ### Without Dev Server ```markdown ðŸ’Ą **āđ€āļ›āļīāļ” preview āđ„āļ”āđ‰āđ‚āļ”āļĒ:** ```bash npm run dev ``` āđāļĨāđ‰āļ§āđ„āļ›āļ—āļĩāđˆ http://localhost:3000/[path] ``` --- ## Preview Confirmation Flow ### Standard Flow ``` 1. AI creates/modifies files 2. AI shows preview 3. User reviews 4. Options: - "OK" / "āđ„āļ”āđ‰āđ€āļĨāļĒ" → Continue - "āđāļāđ‰āđ„āļ‚ [detail]" → AI modifies - "āļĒāļāđ€āļĨāļīāļ" → AI reverts ``` ### Quick Flow (For Simple Changes) ``` 1. AI shows preview inline 2. Applies immediately 3. User can undo if needed ``` --- ## Preview Templates by Task Type ### New Page Preview ```markdown 📄 **New Page: /dashboard** **Layout:** [ASCII art layout] **Features:** - [Feature list] **Components Used:** - [Component list] **Files to Create:** - app/dashboard/page.tsx - components/dashboard/StatsCard.tsx - components/dashboard/SalesChart.tsx āļŠāļĢāđ‰āļēāļ‡āđ€āļĨāļĒāđ„āļŦāļĄāļ„āļĢāļąāļš? ``` ### New Component Preview ```markdown ðŸ§Đ **New Component: ProductCard** **Preview:** ┌─────────────────┐ │ [Image] │ │ Product Name │ │ āļŋ199 │ │ [Add to Cart] │ └─────────────────┘ **Props:** - product: Product - onAddToCart: () => void **Features:** - Responsive - Hover effect - Loading state āļŠāļĢāđ‰āļēāļ‡āđ€āļĨāļĒāđ„āļŦāļĄāļ„āļĢāļąāļš? ``` ### Design Change Preview ```markdown âœĻ **Design Changes:** **Color Palette:** - Primary: #3B82F6 → #2563EB (darker) - Background: #F9FAFB → #F3F4F6 (warmer) **Typography:** - Headings: font-semibold → font-bold - Body: text-gray-600 → text-gray-700 **Spacing:** - Cards: p-4 → p-6 (more breathing room) - Sections: gap-4 → gap-6 **Before/After:** [Side by side comparison if possible] Apply changes āđ„āļŦāļĄāļ„āļĢāļąāļš? ``` ### Logic Change Preview ```markdown ⚙ïļ **Logic Changes: handleSubmit** **What changes:** 1. Add validation before submit 2. Add loading state 3. Add success/error toast 4. Clear form on success **Flow:** ``` User clicks Submit ↓ Validate form (Zod) ↓ Show loading state ↓ Call API ↓ Success? → Show toast + Clear form Error? → Show error message ``` Apply changes āđ„āļŦāļĄāļ„āļĢāļąāļš? ``` --- ## Multi-File Change Preview When changes span multiple files: ```markdown 📁 **Files to Change:** **Create:** - components/checkout/PaymentForm.tsx - lib/stripe.ts - app/api/checkout/route.ts **Modify:** - app/cart/page.tsx (add checkout button) - types/index.ts (add PaymentIntent type) **Total:** 3 new files, 2 modified āļ”āļđ diff āđāļ•āđˆāļĨāļ°āđ„āļŸāļĨāđŒāđ„āļŦāļĄāļ„āļĢāļąāļš? āļŦāļĢāļ·āļ­ apply āđ€āļĨāļĒ? ``` --- ## Preview for Destructive Actions Extra confirmation for risky operations: ```markdown ⚠ïļ **Warning: Destructive Action** **āļˆāļ°āļĨāļš:** - app/old-dashboard/ (3 files) - components/old-chart/ (2 files) **Total:** 5 files āļˆāļ°āļ–āļđāļāļĨāļš âšĄ āļāđˆāļ­āļ™āļĨāļš: - [x] āļŠāļĢāđ‰āļēāļ‡ backup checkpoint āđāļĨāđ‰āļ§ - [x] āđ„āļŸāļĨāđŒāđƒāļŦāļĄāđˆāļžāļĢāđ‰āļ­āļĄāđƒāļŠāđ‰āđāļ—āļ™āđāļĨāđ‰āļ§ āļžāļīāļĄāļžāđŒ 'confirm' āđ€āļžāļ·āđˆāļ­āļĒāļ·āļ™āļĒāļąāļ™āļāļēāļĢāļĨāļš āļŦāļĢāļ·āļ­ 'cancel' āđ€āļžāļ·āđˆāļ­āļĒāļāđ€āļĨāļīāļ ``` --- ## Preview Settings User can configure preview behavior: ```markdown /toh-settings preview **Preview Mode:** - [x] Always show preview (default) - [ ] Quick mode (apply without preview) - [ ] Ask each time **Preview Detail:** - [ ] Minimal (layout only) - [x] Normal (layout + components) - [ ] Verbose (everything) ``` --- ## Integration with Other Skills | Skill | Integration | |-------|-------------| | Version Control | Auto-checkpoint before apply | | Error Handling | Preview potential issues | | Smart Suggestions | Suggest improvements in preview | | Progress Tracking | Show progress after apply | --- ## Best Practices ### DO: - ✅ Always show preview for major changes - ✅ Provide live URL when possible - ✅ Use ASCII art for layout preview - ✅ List all files that will change - ✅ Highlight breaking changes ### DON'T: - ❌ Skip preview for destructive actions - ❌ Show too much technical detail - ❌ Assume user wants to proceed - ❌ Apply without any confirmation for major changes --- ## ASCII Art Templates ### Dashboard Layout ``` ┌─────────────────────────────────────────┐ │ Header │ ├─────────┮───────────────────────────────â”Ī │ Sidebar │ Main Content │ │ │ │ │ Nav │ Cards / Charts / Tables │ │ Items │ │ │ │ │ └─────────â”ī───────────────────────────────┘ ``` ### Card Grid ``` ┌───────┐ ┌───────┐ ┌───────┐ │ Card │ │ Card │ │ Card │ │ 1 │ │ 2 │ │ 3 │ └───────┘ └───────┘ └───────┘ ``` ### Form Layout ``` ┌─────────────────────────────┐ │ Form Title │ ├─────────────────────────────â”Ī │ Label [Input ] │ │ Label [Input ] │ │ Label [Textarea ] │ │ [ ] │ ├─────────────────────────────â”Ī │ [Cancel] [Submit] │ └─────────────────────────────┘ ``` ### Table Layout ``` ┌────┮──────────┮────────┮────────┐ │ ID │ Name │ Amount │ Status │ ├────┾──────────┾────────┾────────â”Ī │ 1 │ Item 1 │ āļŋ100 │ ✅ │ │ 2 │ Item 2 │ āļŋ200 │ âģ │ └────â”ī──────────â”ī────────â”ī────────┘ ``` --- *Last Updated: 2024-12-03*