Generate complete feature structures based on your project patterns with full continuity
I'll create complete feature structures based on your project patterns, with full continuity across sessions.
Arguments: $ARGUMENTS - feature name or component to scaffold
Target: 65% reduction (3,500-5,000 → 1,200-2,000 tokens) Status: ✅ Optimized (Phase 2 Batch 3D-F, 2026-01-26)
1. Template-Based Scaffolding
# Instead of analyzing 20 files for patterns:
Glob "src/features/*/index.ts" → Find 5 existing features
Read ONLY one representative feature → Extract pattern
Reuse pattern for new scaffolding → Generate with heredocs
Before: 15,000 tokens (read all features)
After: 1,500 tokens (read one, reuse pattern)
Savings: 90%
2. Framework Detection Caching
/understand.claude/cache/understand/project-analysis.jsonframework: React/Vue/Angular/Sveltestructure: File organization patternconventions: Naming and export patternstestFramework: Jest/Vitest/Mocha3. Project Conventions Caching
.claude/cache/scaffold/conventions.json{
"naming": "kebab-case|PascalCase|camelCase",
"fileStructure": "feature-folders|type-folders|flat",
"imports": "absolute|relative",
"exports": "named|default",
"testLocation": "adjacent|__tests__|separate"
}
4. Bash-Based File Generation
cat > src/features/user/index.ts <<'EOF'
export * from './UserProfile'
export * from './types'
EOF
cat > src/features/user/UserProfile.tsx <<'EOF'
import React from 'react'
// Component code generated from template
EOF
5. Incremental Scaffolding
scaffold/state.json tracks completed files{
"feature": "UserProfile",
"created": ["index.ts", "types.ts", "UserProfile.tsx"],
"pending": ["UserProfile.test.tsx", "UserProfile.stories.tsx"],
"lastFile": "UserProfile.tsx"
}
6. Git Diff Before Scaffolding
git ls-files src/features/user/ # Check if feature exists
Phase 1: Pattern Discovery (500-800 tokens)
Phase 2: Planning (200-400 tokens)
Phase 3: File Generation (500-800 tokens)
Resume Session (300-600 tokens)
Token Savings:
Cost Comparison:
Before Optimization:
- New feature: 4,000 tokens × $0.003 = $0.012
- Resume: 3,500 tokens × $0.003 = $0.0105
- Annual (50 scaffolds): $0.60
After Optimization:
- New feature: 1,500 tokens × $0.003 = $0.0045
- Resume: 500 tokens × $0.003 = $0.0015
- Annual (50 scaffolds): $0.21
Savings: $0.39/year per developer (65% reduction)
Cache Locations:
scaffold/ in project rootplan.md: Scaffolding plan and file liststate.json: Progress tracking and created files.claude/cache/understand//understand, /implement, /boilerplate.claude/cache/scaffold/conventions.json: Project-specific patternstemplates/: Cached feature templatesCache Invalidation:
new commandShared Caches:
/understand: Framework and structure analysis/implement: Project patterns and dependencies/boilerplate: Framework-specific templates/types-generate: Type generation patternsOptimized Flow (1,200-2,000 tokens):
# First scaffolding in project
claude "scaffold UserProfile"
Step 1: Check session (50 tokens)
Step 2: Load framework cache (100 tokens, cache hit)
Step 3: Find template features (150 tokens, Glob)
Step 4: Read one template (500 tokens)
Step 5: Generate plan (200 tokens)
Step 6: Create files with heredocs (600 tokens)
Total: 1,600 tokens
Resume Flow (300-600 tokens):
# Continue scaffolding
claude "scaffold resume"
Step 1: Read state.json (100 tokens)
Step 2: Load cached conventions (50 tokens)
Step 3: Generate remaining files (400 tokens)
Total: 550 tokens (85% savings)
Specific Type Flow (800-1,500 tokens):
# Scaffold specific component type
claude "scaffold --api-route users"
Step 1: Check session (50 tokens)
Step 2: Load route template (200 tokens)
Step 3: Generate route files (500 tokens)
Total: 750 tokens (75% savings)
Critical Optimizations:
/understand skillAnti-Patterns to Avoid:
Quality Assurance:
I'll maintain scaffolding progress across sessions:
Session Files (in current project directory):
scaffold/plan.md - Scaffolding plan and component listscaffold/state.json - Created files and progressIMPORTANT: Session files are stored in a scaffold folder in your current project root
Auto-Detection:
resume, status, newMANDATORY FIRST STEPS:
scaffold directory exists in current working directoryscaffold/state.jsonscaffold/plan.mdNote: Always look for session files in the current project's scaffold/ folder, not ../../../scaffold/ or absolute paths
I'll discover your project patterns:
Pattern Analysis:
Smart Detection:
Based on patterns, I'll create a scaffolding plan:
Component Structure:
I'll write this plan to scaffold/plan.md with:
I'll generate files matching your patterns:
Pattern Matching:
Content Generation:
I'll create files systematically:
Execution Process:
Progress Tracking:
After scaffolding:
Session Resume:
When you return and run /scaffold or /scaffold resume:
Progress Example:
RESUMING SCAFFOLDING
├── Feature: UserDashboard
├── Created: 5 of 8 files
├── Last: components/UserStats.tsx
└── Next: tests/UserStats.test.tsx
Continuing scaffolding...
Start Scaffolding:
/scaffold UserProfile # Create user profile feature
/scaffold "auth module" # Create authentication module
/scaffold PaymentService # Create payment service
Session Control:
/scaffold resume # Continue existing scaffolding
/scaffold status # Check what's been created
/scaffold new # Start fresh scaffolding
Protection Measures:
Important: I will NEVER:
I'll maintain complete continuity between sessions, always resuming exactly where we left off with consistent pattern application.