Add SKILL.md documentation for Enumify usage and best practices#15
Add SKILL.md documentation for Enumify usage and best practices#15iqbalhasandev merged 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new “Enumify” skill document intended to guide consistent PHP enum usage and TypeScript enum generation/sync practices in Laravel projects using this package.
Changes:
- Introduces
resources/boost/skills/enumify/SKILL.mdwith backend/frontend rules and anti-pattern guidance. - Documents an end-to-end implementation sequence (enum → cast → usage → sync → frontend usage).
- Provides references for config, artisan commands, and generated TypeScript structure.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| 8. **ALWAYS cover every case** in `match()` for `label()` and custom methods. Missing cases will cause runtime errors and break TypeScript generation. | ||
|
|
||
| 9. **Custom methods MUST follow these constraints** or they will be silently skipped during TypeScript generation: | ||
| - MUST be `public` (not `protected` or `private`) | ||
| - MUST NOT be `static` | ||
| - MUST have zero required parameters | ||
| - MUST declare a return type | ||
| - Return type MUST be `string`, `int`, `float`, `bool`, `null`, or nullable/union of these | ||
| - MUST NOT throw exceptions on any case |
There was a problem hiding this comment.
Rule 8 says missing match() cases “will cause runtime errors and break TypeScript generation”, but Enumify catches exceptions when resolving labels and will fall back to other label sources or humanize() in the generated TS. For custom methods, if a case throws, the method is skipped (it doesn’t crash generation). Please adjust the wording to reflect the actual behavior (e.g., missing cases can lead to missing/incorrect labels or skipped method generation).
| 13. **ALWAYS import from the barrel file** `@/enums` (maps to `resources/js/enums/index.ts`): | ||
|
|
||
| ```typescript | ||
| // CORRECT | ||
| import { OrderStatus, OrderStatusUtils } from "@/enums"; | ||
|
|
||
| // WRONG — bypasses barrel file, fragile path | ||
| import { OrderStatus } from "@/enums/order-status"; | ||
| ``` |
There was a problem hiding this comment.
Frontend rule 13 says the barrel file is always available at resources/js/enums/index.ts and should always be imported via @/enums, but the barrel file can be disabled (enumify.features.generate_index_barrel = false) and the output directory may differ (enumify.paths.output). Consider rewording this as a best practice when the barrel is enabled, and avoid hardcoding the filesystem path/alias mapping.
…acement and TypeScript generation rules
Add SKILL.md documentation for Enumify usage and best practices