name: nk-livewire-best-practices description: >- Use this skill whenever creating, modifying, or reviewing Livewire components in a Naykel (Gotime) project. Do not wait for an explicit request — if a Livewire component is involved, this skill applies.
Naykel Livewire Best Practices
Patterns and conventions for Livewire components built on the Naykel Gotime framework.
Config First
Before building any component, the resource config must exist and be read. All structure — columns, fields, buttons — is derived from config, never inferred from models, migrations, or the prompt.
If config exists, implement exactly as written. If it conflicts with the request, stop and surface the conflict — do not resolve it yourself.
Quick Reference
Read the relevant rule file before building. Summaries below are defaults only — full rules take precedence.
1. Resource Config → rules/resource-config.md
- Check for
config/resources.phpbefore building any component - If config does not exist, create it before building any component
- Determine buttons from the component types table — ask if the combination isn't listed
routePrefixis required forindexandform; not required forform-modal- Never modify existing config without explicit instruction
- Config conflicts with the request? Stop and surface — never resolve yourself
2. Index Component → rules/index-component.md
- Extend
BaseIndex; set$modelClassandconfigKey() - Always include sort — add
Sortabletrait andapplySorting()to the query - Build table columns from
index.columnsin config — never infer from the model - Render
index.buttonsfrom config exactly — no more, no less - Only add features beyond the base structure if explicitly requested
3. Form Component → rules/form-component.md
- Extend
BaseForm; declareModelFormObject $formand$modelClass - Route-based forms:
saveAndEditfor save action, link back to index via$routePrefix - Form-modal: add
createTitle,editTitlePrefix, andtitleFieldfor the modal heading - Render buttons from config using the form button tokens in
rules/resource-config.md
4. Form Object → rules/form-object.md
- Use Gotime traits:
FormableandCrudable - Name it
ModelFormObject— neverModelForm - Build properties from
form.fieldsin config — never infer from model, migration, or prompt - Use
#[Validate(...)]on properties by default - Only use
rules()when a unique constraint requiresRule::unique()->ignore() required/nullablevalidation must match database nullability — resolve conflicts before implementingsetFormProperties()convertsnullto''for string properties — only override ininit()for date fields
5. File Uploads → rules/file-uploads.md
- Add
WithFileUploadsto the component, not the form object - Do not declare
tmpUploadon the form object — it is provided byCrudable - Add
$storageto the form object to configure disk, column, and path - Add
imageUrl()to the component to handle preview and fallback
How to Apply
Read the relevant rule files before responding — do not rely on the Quick Reference summaries alone.
- Identify the component types being built: index, form, form-modal, form object, file uploads
- Read
rules/resource-config.mdfirst — config drives everything - Read the relevant component rule files for the task
- Check sibling files for existing patterns — follow those first per Consistency First