| name | lvt-run-and-test |
| description | Use when running and testing LiveTemplate applications - covers lvt serve for development, running generated tests, debugging issues, and verifying app works |
lvt:run-and-test
Run and test LiveTemplate applications during development.
🎯 ACTIVATION RULES
Context Detection
This skill typically runs in existing LiveTemplate projects (.lvtrc exists).
✅ Context Established By:
- Project context -
.lvtrc exists (most common scenario)
- Agent context - User is working with
lvt-assistant agent
- 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
Overview
LiveTemplate apps can be run in two ways:
- Development server (
lvt serve) - Hot reload, browser auto-open, debugging
- Direct execution (
go run) - Production-like, no development features
Generated resources and views include E2E tests that verify HTTP endpoints and WebSocket connections.
Running Your App
Quick Start
lvt serve
Serve Options
lvt serve --port 3000
lvt serve --no-browser
lvt serve --no-reload
lvt serve --dir /path/to/app
lvt serve --mode app
Development Workflow
lvt new myapp
cd myapp
lvt gen resource products name price:float
lvt migration up
lvt serve
Running Tests
Generated Tests
Each resource/view gets a test file:
app/products/products_test.go
app/dashboard/dashboard_test.go
Tests verify:
- HTTP endpoint responds
- WebSocket connection works
- Basic functionality
Run All Tests
go test ./...
go test ./app/products
go test -v ./app/products
go test -short ./...
Before Running Tests
Prerequisites:
- ✓ Migrations applied (
lvt migration up)
- ✓ Dependencies installed (
go mod tidy)
- ✓ No server running on test ports
lvt migration up
go mod tidy
go test ./...
Common Issues
❌ Port Already in Use
lvt serve --port 3000
lsof -ti:8080 | xargs kill -9
ps aux | grep "lvt serve"
kill <PID>
❌ Tests Fail: Server Won't Start
lvt migration up
go test ./...
pkill -f "lvt serve"
go test ./...
go mod tidy
go test ./...
go test -short ./...
❌ 404 Not Found
lvt migration status
cat cmd/myapp/main.go | grep products
❌ Database Locked
pkill -f "go run"
pkill -f "lvt serve"
lsof app.db
lvt serve
Test Structure
Generated tests follow this pattern:
func TestProductsWebSocket(t *testing.T) {
if testing.Short() {
t.Skip("Skipping WebSocket test in short mode")
}
serverPort, _ := getFreePort()
go run cmd/myapp/main.go
GET /products → 200 OK
ws:
Kill server process
}
Key points:
- Tests start their own server instance
- Use random ports to avoid conflicts
- Skip in
-short mode for faster feedback
- Clean up server process automatically
Running Modes
LiveTemplate auto-detects mode from project structure:
| Mode | When Used | What It Does |
|---|
| app | Standard apps with cmd/ | Runs your application |
| component | Component development | Component preview server |
| kit | Kit development | Kit testing environment |
Force specific mode:
lvt serve --mode app
Debugging Tips
Check Server is Running
lsof -i:8080
ps aux | grep "lvt serve"
curl http://localhost:8080/products
View Server Logs
lvt serve
Database State
lvt migration status
sqlite3 app.db
> .tables
> .schema products
> SELECT * FROM products;
> .quit
Test Specific Handler
go test -v ./app/products -run TestProductsWebSocket
go test -v ./app/products -run TestProductsWebSocket 2>&1 | less
Production Build
Development server is NOT for production:
go build -o myapp cmd/myapp/main.go
./myapp
go run cmd/myapp/main.go
For production deployment, see lvt:deploy skill.
Quick Reference
| I want to... | Command |
|---|
| Run development server | lvt serve |
| Change port | lvt serve --port 3000 |
| Run all tests | go test ./... |
| Run fast tests only | go test -short ./... |
| Test one package | go test ./app/products |
| Stop server | Ctrl+C or pkill -f "lvt serve" |
| Check what's on port | lsof -i:8080 |
| View database | sqlite3 app.db |
| Check migration status | lvt migration status |
| Full reset | pkill -f "lvt serve" && lvt migration up && go mod tidy |
Typical Development Session
cd myapp
lvt migration up
go mod tidy
lvt serve
go test ./...
go build ./cmd/myapp
Ctrl+C
Remember
✓ lvt serve for development (hot reload, auto-browser)
✓ Run migrations before testing (lvt migration up)
✓ Tests start their own server on random ports
✓ Use --port if 8080 is busy
✓ Stop server before running tests to avoid conflicts
✓ go test -short to skip slow WebSocket tests
✗ Don't use lvt serve in production
✗ Don't forget go mod tidy after generating resources
✗ Don't run tests while lvt serve is running on same port
✗ Don't manually open database while server is running