본문으로 건너뛰기
cccskills
무료GitHub에 공개

laravel-pennant

Use when working with feature flags — Laravel Pennant, gradual rollouts, A/B testing, scope-based flags — even when the user just says 'hide this behind a flag' without naming Pennant.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md4.9 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

laravel-pennant

When to use

Use this skill when working with feature flags:

  • Gradual feature rollouts (percentage-based)
  • Per-user or per-tenant feature toggling
  • A/B testing with feature variants
  • Environment-based feature gating

Procedure: Set up feature flags

  1. Install — composer require laravel/pennant, publish config, run migrations.
  2. Define feature — Create feature class or use closure-based definition.
  3. Check feature — Use Feature::active('feature-name') in code.
  4. Verify — Confirm feature is active/inactive for correct scopes. Run tests.

Installation

composer require laravel/pennant
php artisan vendor:publish --provider="Laravel\Pennant\PennantServiceProvider"
php artisan migrate

Defining features

Class-based features (recommended)

php artisan pennant:feature NewDashboard
declare(strict_types=1);

namespace App\Features;

use App\Models\User;
use Illuminate\Support\Lottery;

class NewDashboard
{
    /** Resolve the feature's initial value. */
    public function resolve(User $user): bool
    {
        // Percentage rollout
        return Lottery::odds(1, 10)->choose();  // 10% of users
    }
}

Closure-based features

// In a service provider
use Laravel\Pennant\Feature;

Feature::define('new-dashboard', function (User $user): bool {
    return $user->getCustomer()?->isEarlyAdopter() ?? false;
});

// Rich values (A/B testing)
Feature::define('checkout-button', function (User $user): string {
    return Arr::random(['blue', 'green', 'red']);
});

Checking features

// Boolean check
if (Feature::active('new-dashboard')) {
    // Show new dashboard
}

// Via the user model (HasFeatures trait)
if ($user->features()->active('new-dashboard')) {
    // ...
}

// Rich value
$color = Feature::value('checkout-button');  // 'blue', 'green', or 'red'

// Blade directive
@feature('new-dashboard')
    <x-new-dashboard />
@else
    <x-legacy-dashboard />
@endfeature

Managing features

// Activate for a specific user
Feature::for($user)->activate('new-dashboard');

// Deactivate
Feature::for($user)->deactivate('new-dashboard');

// Activate for everyone
Feature::activateForEveryone('new-dashboard');

// Deactivate for everyone
Feature::deactivateForEveryone('new-dashboard');

// Purge stored values (re-resolve on next check)
Feature::purge('new-dashboard');

Scopes

Features can be scoped to any model, not just users:

// Per-tenant feature
Feature::for($customer)->active('advanced-reporting');

// Define with tenant scope
Feature::define('advanced-reporting', function (Customer $customer): bool {
    return $customer->getPlan() === 'enterprise';
});

Drivers

DriverStorageUse case
databaseDB tableProduction — persistent, shared across servers
arrayIn-memoryTesting — no persistence
// config/pennant.php
'default' => env('PENNANT_STORE', 'database'),

Eager loading

// Prevent N+1 when checking features for multiple users
Feature::for($users)->loadAll();

// Load specific features
Feature::for($users)->load(['new-dashboard', 'advanced-reporting']);

Core rules

  • Use class-based features for anything non-trivial — they're testable and discoverable.
  • Scope to the right model — user, customer, or team depending on the feature.
  • Eager load when checking features for collections of users.
  • Purge after full rollout — remove the flag once 100% of users have the feature.
  • Use array driver in tests — prevents test pollution.
  • Clean up old flags — feature flags are temporary, not permanent config.

Output format

  1. Feature flag definition with scope and resolve logic
  2. Integration in controllers/services using Feature::active()

Auto-trigger keywords

  • feature flag
  • feature toggle
  • Pennant
  • gradual rollout
  • A/B test
  • feature gate

Gotcha

  • Feature flags in database driver require migration — don't forget php artisan pennant:purge for cleanup.
  • The model tends to check flags without a scope — always pass the authenticated user or a default scope.
  • Don't nest feature flag checks — it makes the logic impossible to reason about.

Do NOT

  • Do NOT leave feature flags forever — remove them after full rollout.
  • Do NOT use feature flags for permanent configuration — use config files.
  • Do NOT check features in tight loops without eager loading.
  • Do NOT forget to purge stored values when changing the resolve logic.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when reviewing UI for accessibility — WCAG 2.2 AA, keyboard nav, focus, ARIA, contrast, screen-reader semantics — even on 'is this a11y-OK?' or 'mach das barrierefrei'.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

event4u-app/agent-config122026년 10월 18일 업데이트

Use when defining or auditing the activation event — aha-moment selection, retention correlation, falsifiable definition. Triggers on 'what is our aha moment', 'redefine activation'.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

event4u-app/agent-config122026년 10월 18일 업데이트

Use when capturing an architectural decision — file naming, next ADR number, Status / Context / Decision / Consequences, index regen; fires even without saying 'ADR'.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

event4u-app/agent-config122026년 10월 18일 업데이트

Adversarial critique — devil's advocate, stress-test, honest teardown ('poke holes', 'be brutal', 'was hältst du davon'); explicit request only. Routine code or design review → code-review.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

event4u-app/agent-config122026년 10월 18일 업데이트

Use when reading, creating, or updating agent documentation, module docs, roadmaps, or AGENTS.md. Understands the full .augment/, agents/, and copilot-instructions structure.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

event4u-app/agent-config122026년 10월 18일 업데이트

Use for an adversarial red-team / blue-team / auditor review of an AI agent's CONFIG + behaviour (rules, skills, MCP, hooks, permissions) — attack-chain → defensive-gap list, not a code audit.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

event4u-app/agent-config122026년 10월 18일 업데이트

event4u-app의 스킬 모두 보기

이 스킬의 문제 신고