This skill provides developers with quick reference patterns and best practices for building applications using Gadget. It includes resources for core data modeling, backend logic, and more.
$ npx skills add https://github.com/gadget-inc/skills --skill gadget-best-practicesThis skill equips developers with reference documentation and proven patterns for building applications on Gadget. It covers core topics including data modeling, backend logic, actions, routes, access control, and integrations with Shopify and BigCommerce. The skill activates automatically when working on Gadget projects or manually via command, providing guidance on tasks like creating bundle models, building leaderboards with computed views, publishing actions, form building, and webhook route handling. Developers can reference established patterns to accelerate development and follow Gadget conventions effectively.
Install the skill using the command provided.
Understanding core data modeling conventions
Implementing backend logic patterns
Utilizing HTTP routes effectively
Enqueuing background jobs
$ npx skills add https://github.com/gadget-inc/skills --skill gadget-best-practicesgit clone https://github.com/gadget-inc/skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Generate a quick reference guide for best practices in building applications with Gadget, focusing on [COMPONENT_TYPE] (e.g., data modeling, backend logic, API design). Include key principles, common pitfalls, and code snippets where applicable. Format as a concise checklist with explanations.
# Gadget Best Practices: Data Modeling for [COMPANY]
## Core Principles
- **Single Source of Truth**: Each entity should represent a single concept. Avoid duplicating data across models unless absolutely necessary.
- **Relationships Over Redundancy**: Use relational fields (e.g., `belongsTo`, `hasMany`) instead of duplicating data. Example:
```javascript
// Good: Reference via relationship
const order = await store.findOne('order', { id: orderId });
const customer = await order.customer();
// Bad: Duplicated customer data
const order = await store.findOne('order', { id: orderId });
const customer = await store.findOne('customer', { id: order.customerId });
```
## Common Pitfalls & Fixes
- **Over-nesting Models**: Avoid creating deeply nested models (e.g., `UserProfileSettingsNotifications`). Flatten where possible.
- **Ignoring Indexes**: Always add indexes for fields used in queries (e.g., `email` for authentication).
## Quick Checklist
✅ Use `belongsTo` for one-to-many relationships.
✅ Add indexes for fields used in `where` clauses.
✅ Avoid storing derived data (e.g., `totalPrice`) unless it’s frequently accessed.
✅ Validate data at the model level using Gadget’s built-in validations.
Need help? Run `gadget generate model --help` for scaffolding.Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan