resources/boost/skills/traits/SKILL.md
Reusable behaviour shared across multiple unrelated classes. Traits provide shared Eloquent scopes, accessors, lifecycle hooks, and small stateless helper methods.
npx skillsauth add codebar-ag/coding-guidelines traitsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
app/Traits/.bootTraitName, initializeTraitName).Archivable, Sluggable) or coherent concern (HasAddress).bootTraitName() for model event hooks.initializeTraitName() for default property setup.namespace App\Traits;
use Illuminate\Database\Eloquent\Builder;
trait Archivable
{
public function archive(): void
{
$this->update(['archived_at' => now()]);
}
public function unarchive(): void
{
$this->update(['archived_at' => null]);
}
public function isArchived(): bool
{
return ! is_null($this->archived_at);
}
public function scopeArchived(Builder $query): Builder
{
return $query->whereNotNull('archived_at');
}
public function scopeNotArchived(Builder $query): Builder
{
return $query->whereNull('archived_at');
}
}
// Counter-example: avoid business orchestration in traits.
trait InvoiceSettlementTrait
{
public function settleInvoice(): void
{
// Bad: side effects, payment gateway, and notifications in trait.
$this->paymentGateway->charge($this->invoice_total);
Mail::to($this->user)->send(new InvoiceSettledMail($this));
}
}
trait Sluggable
{
public static function bootSluggable(): void
{
static::creating(function ($model) {
$model->slug = str($model->name)->slug();
});
}
public function scopeBySlug(Builder $query, string $slug): Builder
{
return $query->where('slug', $slug);
}
}
// Usage across unrelated models
class Post extends Model { use Archivable; }
class Supplier extends Model { use Archivable; }
$post->archive();
Post::archived()->get();
// Trait testing approach (feature/unit test setup)
$post = Post::factory()->create(['archived_at' => null]);
$post->archive();
$this->assertTrue($post->isArchived());
bootTraitName / initializeTraitName methods.resources/boost/skills/models/SKILL.md (trait usage in Eloquent models)testing
Translation and localization conventions for Laravel. Use when adding user-facing strings, creating translation files, or working with lang/ directory.
development
Tailwind CSS v4 styling conventions. Use when working with CSS, Tailwind utilities, or customizing the theme in Laravel projects.
development
Orchestration classes that coordinate multiple Actions, external APIs, or domain operations into a cohesive workflow. Services own transaction boundaries and third-party API integrations.
development
Saloon-based service layer pattern for all external API integrations. Every new external API integration must use Saloon — no raw HTTP calls.