---
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*