AgentSkillsCN

pennant-development

通过Laravel Pennant管理功能标志。在创建、检查或切换功能标志时激活;在有条件地显示或隐藏功能时使用;在开展A/B测试时使用;在使用@feature指令时使用;或当用户提及功能标志、功能开关、Pennant、条件性功能、灰度发布,或逐步启用功能时使用此功能。

SKILL.md
--- frontmatter
name: pennant-development
description: "Manages feature flags with Laravel Pennant. Activates when creating, checking, or toggling feature flags; showing or hiding features conditionally; implementing A/B testing; working with @feature directive; or when the user mentions feature flags, feature toggles, Pennant, conditional features, rollouts, or gradually enabling features."
license: MIT
metadata:
  author: laravel

Pennant Features

When to Apply

Activate this skill when:

  • Creating or checking feature flags
  • Managing feature rollouts
  • Implementing A/B testing

Documentation

Use search-docs for detailed Pennant patterns and documentation.

Basic Usage

Defining Features

<!-- Defining Features -->
php
use Laravel\Pennant\Feature;

Feature::define('new-dashboard', function (User $user) {
    return $user->isAdmin();
});

Checking Features

<!-- Checking Features -->
php
if (Feature::active('new-dashboard')) {
    // Feature is active
}

// With scope
if (Feature::for($user)->active('new-dashboard')) {
    // Feature is active for this user
}

Blade Directive

<!-- Blade Directive -->
blade
@feature('new-dashboard')
    <x-new-dashboard />
@else
    <x-old-dashboard />
@endfeature

Activating / Deactivating

<!-- Activating Features -->
php
Feature::activate('new-dashboard');
Feature::for($user)->activate('new-dashboard');

Verification

  1. Check feature flag is defined
  2. Test with different scopes/users

Common Pitfalls

  • Forgetting to scope features for specific users/entities
  • Not following existing naming conventions