name: lvt-analyze description: Analyze LiveTemplate app structure - examine schema, resources, relationships, complexity, and provide insights category: maintenance version: 1.0.0 keywords: ["lvt", "livetemplate", "lt"]
lvt:analyze
Comprehensive analysis of LiveTemplate application structure. Examines database schema, resources, relationships, code organization, and provides actionable insights.
๐ฏ ACTIVATION RULES
Context Detection
This skill typically runs in existing LiveTemplate projects (.lvtrc exists).
โ Context Established By:
- Project context -
.lvtrcexists (most common scenario) - Agent context - User is working with
lvt-assistantagent - Keyword context - User mentions "lvt", "livetemplate", or "lt"
Keyword matching (case-insensitive): lvt, livetemplate, lt
Trigger Patterns
With Context: โ Generic prompts related to this skill's purpose
Without Context (needs keywords): โ Must mention "lvt", "livetemplate", or "lt" โ Generic requests without keywords
User Prompts
When to use:
- "Analyze my app"
- "Show me my app structure"
- "What's in my application?"
- "Review my schema"
- "Tell me about my app's architecture"
Examples:
- "Analyze my blog app"
- "Show me the structure of my application"
- "Review my database schema"
- "What resources do I have?"
Analysis Components
1. Schema Analysis
Use lvt:resource-inspect to examine:
- All tables and their purposes
- Field counts and complexity
- Data types used
- Relationships (foreign keys)
- Indexes
Output format:
=== Schema Analysis ===
Resources: 5 tables found
Core Resources:
- users (7 fields) - User accounts and profiles
- posts (6 fields) - Blog posts with content
- comments (5 fields) - User comments on posts
Supporting Tables:
- sessions (4 fields) - User session management
- categories (3 fields) - Post categorization
Complexity: Medium (5 tables, 25 total fields)
2. Relationship Analysis
Detect and document:
- One-to-many relationships
- Many-to-many relationships
- Self-referencing relationships
- Missing relationships (potential gaps)
Output format:
=== Relationships ===
One-to-Many:
- posts โ comments (via post_id)
- users โ posts (via user_id)
- users โ sessions (via user_id)
Many-to-Many:
- (none detected)
Potential Missing Relationships:
- posts could relate to categories
- comments could relate to users
Foreign Key Analysis:
โ
All foreign keys use CASCADE delete
โ
Relationships properly indexed
3. Resource Complexity
Analyze each resource:
- Field count (simple: <5, medium: 5-10, complex: >10)
- Field types (diversity)
- Business logic hints
- UI complexity
Output format:
=== Resource Complexity ===
Simple Resources:
- categories (3 fields) - Basic lookup table
- sessions (4 fields) - Session tracking
Medium Resources:
- comments (5 fields) - Standard CRUD
- posts (6 fields) - Content management
Complex Resources:
- users (7 fields) - Auth + profile data
Average Complexity: 5 fields per resource
4. Code Organization
Check file structure:
=== Code Organization ===
App Structure:
โ
app/ - Handler organization
โ
database/ - Database layer
โ
shared/ - Shared utilities
Resources with Full Stack:
- posts (handler, template, tests)
- comments (handler, template, tests)
- users (auth system)
Views:
- home (landing page)
- about (static page)
Missing:
โ ๏ธ No E2E tests for posts
โ ๏ธ No custom middleware
5. Database Health
Analyze database structure:
- Migration count and history
- Index coverage
- Potential performance issues
- Schema consistency
Output format:
=== Database Health ===
Migrations: 5 applied
Latest: 20251104_create_comments.sql
Index Coverage:
โ
Primary keys on all tables
โ
Foreign keys indexed
โ ๏ธ High-volume table 'posts' missing index on created_at
Performance Recommendations:
- Add index on posts(created_at) for date sorting
- Add index on comments(post_id, created_at) for pagination
Schema Consistency:
โ
All timestamps use DATETIME
โ
Consistent naming (snake_case)
โ
ID fields use INTEGER PRIMARY KEY
6. Feature Detection
Identify features in use:
- Authentication (password, magic link, email confirm)
- Authorization (middleware, protected routes)
- CRUD operations
- Search/filter
- Pagination
- Sorting
Output format:
=== Features Detected ===
Authentication:
โ
Password authentication
โ
Magic link authentication
โ
Email confirmation
โ
Session management
โ
CSRF protection
CRUD Operations:
โ
posts - Full CRUD
โ
comments - Full CRUD
โ
categories - Full CRUD
Advanced Features:
โ
Pagination (infinite scroll)
โ ๏ธ No search functionality
โ ๏ธ No sorting controls
โ ๏ธ No filters
Checklist
- Run lvt resource list to get all tables
- For each resource, run lvt resource describe
- Analyze relationships and foreign keys
- Calculate complexity metrics
- Check code organization
- Review database migrations
- Detect features in use
- Identify missing indexes
- Suggest improvements
- Generate comprehensive report
Analysis Report Template
# Application Analysis Report
## Overview
- **App Name:** [name]
- **Resources:** [count] tables
- **Complexity:** [simple/medium/complex]
- **Features:** [auth, CRUD, pagination, etc.]
## Schema Summary
[List all resources with field counts]
## Relationships
[Document all foreign keys and relationships]
## Complexity Analysis
[Breakdown by resource]
## Database Health
- **Migrations:** [count]
- **Index Coverage:** [percentage]
- **Performance:** [issues/recommendations]
## Feature Coverage
[Which features are implemented]
## Recommendations
[Ordered list of suggestions]
## Next Steps
[Actionable items for improvement]
Example Analysis
Small Blog App
=== App Analysis ===
Overview:
- 3 core resources (posts, comments, users)
- Medium complexity (18 total fields)
- Basic CRUD + Auth
Strengths:
โ
Clean schema with proper relationships
โ
Full authentication system
โ
Consistent naming conventions
Opportunities:
โ ๏ธ Add categories for better organization
โ ๏ธ Add indexes for better performance
โ ๏ธ Add search functionality
Recommendation: Add categories and post_categories junction table
E-commerce App
=== App Analysis ===
Overview:
- 6 core resources (products, orders, customers, etc.)
- Complex (45 total fields)
- Full e-commerce features
Strengths:
โ
Complete order workflow
โ
Customer management
โ
Product catalog
Opportunities:
โ ๏ธ Missing inventory tracking
โ ๏ธ No product reviews
โ ๏ธ Cart abandonment not tracked
Recommendation: Add reviews resource and inventory fields
Metrics to Calculate
Schema Metrics
- Total tables
- Total fields
- Average fields per table
- Relationship count
- Index count
Code Metrics
- Handlers with tests
- Template coverage
- Middleware count
- Shared utilities
Feature Metrics
- Auth completeness (0-100%)
- CRUD coverage (0-100%)
- Advanced features (search, sort, filter)
Common Insights
Well-Structured App
- Consistent naming
- Proper relationships
- Good index coverage
- Comprehensive tests
- Clear separation of concerns
Needs Improvement
- Missing relationships
- No indexes on high-volume queries
- Inconsistent naming
- Missing tests
- Monolithic handlers
Success Criteria
Analysis is complete when:
- โ All resources documented
- โ Relationships mapped
- โ Complexity calculated
- โ Code organization reviewed
- โ Database health checked
- โ Features detected
- โ Recommendations provided
Notes
- Purely informational (no modifications)
- Helps users understand their app
- Identifies improvement opportunities
- Great for onboarding new developers
- Useful before refactoring
- Can inform testing priorities
- Combines data from multiple inspection tools