/laravel-playbook:craft-macrofrom laravel-playbook
Crafting macros. Runtime extension of Laravel core classes.
Ships in laravel-playbook. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
"Macros let packages add methods to classes they don't own."
Single Macros for One-Off Methods: Use ClassName::macro('name', fn () => ...) to add individual methods. Register in your service provider's boot(). The closure is bound to the target instance via $this. Keep macros small and focused -- one behavior per macro.
Mixins for Grouped Methods: Use ClassName::mixin(new YourMixin) when registering multiple related macros. Each method on the mixin class returns a closure that becomes the macro. This is the double-closure pattern: the mixin method is invoked by reflection, and its return value is bound to the target instance.
Macros Over Subclassing: Prefer macros when adding behavior to framework classes. You cannot subclass Collection, Request, or Builder -- they're resolved by the framework. Macros extend them without touching the resolution chain. This is the right tool for the job.
Register in boot(), Not register(): Macros depend on the class being loaded. Register them in packageBooted() or boot(), never in register(). The service provider lifecycle guarantees the target class exists at boot time.
Document With @method Annotations: Macros are invisible to static analysis and IDEs. Add @method annotations to a mixin class or document them in your README. Without annotations, developers discover macros by accident, not by autocomplete.
Know When NOT to Macro: Macros are runtime monkey-patching. Use them for convenience methods on framework classes. Do not use them for core package logic, complex behavior, or anything that needs testing in isolation. If the logic is complex, it belongs in your own class.
| Don't | Do | Why |
|---|---|---|
| Put business logic in macros | Keep macros as thin wrappers | Macros are hard to test in isolation |
Register macros in register() | Register in boot() | Target class may not exist yet |
| Add many unrelated macros to one class | Group related macros in a mixin | Cohesion matters |
| Skip IDE annotations | Add @method docblocks | Discoverability is DX |
| Subclass framework classes | Use macros | Framework resolves its own classes |
See also: craft-extension-point (Macroable as one of nine extension mechanisms).
See examples.md.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub attac-t/the-foundry --plugin laravel-playbook29 skills in this plugin
/craft-apiCrafting API surfaces. Entry points, fluent builders, progressive disclosure./craft-brandingCrafting package identity. Professional impressions from the first click./craft-ciCrafting a CI pipeline. Five workflows, zero manual gates./craft-configCrafting a config file. The self-documenting contract between package and consumer./craft-deprecationCrafting deprecations. Sunset gracefully, remove confidently./craft-docsCrafting a documentation site. Progressive depth, not progressive confusion.