ワンクリックで
lvt-add-resource
Add a CRUD resource to an existing LiveTemplate app with database schema, queries, handler, and template
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Add a CRUD resource to an existing LiveTemplate app with database schema, queries, handler, and template
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when deploying LiveTemplate applications to production - covers Docker containerization, Fly.io deployment, Kubernetes setup, database persistence, and production best practices
Transform app to production-ready - adds authentication, deployment config, environment setup, and best practices
Use when deploying LiveTemplate applications to production - covers Docker containerization, Fly.io deployment, Kubernetes setup, database persistence, and production best practices
Rapid end-to-end workflow - creates app, adds resources, sets up development environment in one flow
Generate test apps, capture screenshots, analyze UI for issues, and recursively fix problems in kit templates
Use when adding database migrations to LiveTemplate apps - guides both auto-generated migrations (from lvt gen resource) and custom migrations (indexes, constraints, data transformations)
| name | lvt-add-resource |
| description | Add a CRUD resource to an existing LiveTemplate app with database schema, queries, handler, and template |
| keywords | ["lvt","livetemplate","lt"] |
| category | core |
| version | 1.0.0 |
Adds a full CRUD (Create, Read, Update, Delete) resource to an existing LiveTemplate application. This skill intelligently infers field types, generates database migrations, SQL queries, Go handlers, and HTML templates.
This skill typically runs in existing LiveTemplate projects (.lvtrc exists).
✅ Context Established By:
.lvtrc exists (most common scenario)lvt-assistant agentKeyword matching (case-insensitive): lvt, livetemplate, lt
With Context: ✅ "add a posts resource" ✅ "create a products resource with name and price" ✅ "generate CRUD for tasks"
Without Context (needs keywords): ✅ "add a posts resource to my lvt app" ✅ "use livetemplate to create a products resource" ❌ "add a posts resource" (no context, no keywords)
This skill should activate when the user requests to add a resource to their app:
Explicit prompts:
Implicit prompts:
Examples:
Before executing this skill, verify:
In Project Directory:
.lvtrc file (confirms it's an lvt project)go.mod (confirms it's a Go project)database/ directoryDependencies Available:
lvt binary is installed and accessiblelvt newNot Already Exists:
When adding a resource, show what will be created and ask for confirmation:
I'll add a **products** resource with these fields:
- name (string)
- price (float)
- quantity (int)
- description (text)
This will create:
- app/products/products.go (handler)
- app/products/products.tmpl (template)
- database/migrations/..._create_products.sql
- Update database/queries.sql
**Proceed?**
- **yes** - create the resource
- **change X** - modify fields or name
- **advanced** - explore options (pagination, edit mode, references)
- **no** - cancel
If user says "advanced", show:
⚙️ **Advanced Resource Options**
| Option | Current | Alternatives |
|--------|---------|--------------|
| Pagination | infinite scroll | page numbers |
| Edit Mode | modal | inline, page |
| Page Size | 20 | 10, 50, 100 |
**Field modifiers:**
- `field:references:table` - foreign key relationship
- `field:references:table:CASCADE` - with cascade delete
What would you like to change?
Then WAIT for user response before running commands.
Confirmation Phase:
Step 1: Verify we're in an lvt project directory
.lvtrc filego.mod filedatabase/ directoryStep 2: Extract resource details from user request
Step 3: Present what will be created and ask for confirmation
Execution Phase (after approval):
Step 4: Validate prerequisites
lvt command is availableStep 5: Parse and organize fields
Step 6: Check for naming conflicts
app/[resource]/ already existsStep 6: Determine resource options
Step 7: Build and run the lvt gen resource command
lvt gen resource <name> <field1:type1> <field2:type2> ...--pagination <mode> if not default--page-size <num> if not default--edit-mode <mode> if not defaultStep 8: Verify resource generation succeeded
app/<resource>/<resource>.go (handler)app/<resource>/<resource>.tmpl (template)app/<resource>/<resource>_test.go (tests)database/schema.sql (schema updated)database/queries.sql (queries added)database/migrations/<timestamp>_create_<table>.sql (migration created)cmd/<app>/main.go or main.go (route injected)Step 9: Run database migration
lvt migration upStep 10: Generate sqlc models
database/ directorygo run github.com/sqlc-dev/sqlc/cmd/sqlc generate Step 11: Run go mod tidy
Step 12: Verify app builds successfully
go build ./cmd/<app>go buildStep 13: Provide user with success summary
If the user doesn't specify types, lvt will infer them:
String types:
Text types (textarea):
Integer types:
_count, _number, _id, or ending with idFloat types:
_price, _amount, _total, or ending with priceBoolean types:
is_, has_, can_, should_Time types:
_at, _date, _time, or ending with dateTo create foreign key relationships:
field_name:references:table_namefield_name:references:table_name:CASCADEExample: user_id:references:users:CASCADE
# Simple resource with type inference
lvt gen resource posts title content published
# Explicit types
lvt gen resource products name:string price:float quantity:int enabled:bool
# With foreign key
lvt gen resource comments post_id:references:posts:CASCADE content author
# With pagination options
lvt gen resource articles title content --pagination numbers --page-size 10
# With edit mode
lvt gen resource tasks title description due_date --edit-mode page
If resource directory already exists:
If not in an lvt project:
.lvtrc fileIf field names are invalid:
If migration fails:
If build fails after generation:
go mod tidy againAfter successful resource generation, provide:
✅ Resource '[name]' generated successfully!
📁 Files created:
- app/[resource]/[resource].go
- app/[resource]/[resource].tmpl
- app/[resource]/[resource]_test.go
- database/migrations/[timestamp]_create_[table].sql
📝 Files updated:
- database/schema.sql
- database/queries.sql
- cmd/[app]/main.go (route: /[resource])
✅ Migration applied successfully
✅ Models generated successfully
✅ App builds successfully
🚀 Next steps:
1. Start your app: lvt serve (or go run main.go)
2. Visit: http://localhost:8080/[resource]
3. Test CRUD operations in your browser
Scenario 1: Blog posts
Scenario 2: E-commerce products
Scenario 3: Task management with relationships
Scenario 4: Comments with explicit types
Resource generation is successful if:
go build succeeds