AgentSkillsCN

pennant-development

利用 Laravel Pennant 管理功能标志。当创建、检查,或切换功能标志时,可灵活运用此方法;在有条件地显示或隐藏功能时,或在实施 A/B 测试时,亦或是当用户提及功能标志、功能切换、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.

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

<code-snippet name="Defining Features" lang="php"> use Laravel\Pennant\Feature;

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

Checking Features

<code-snippet name="Checking Features" lang="php"> if (Feature::active('new-dashboard')) { // Feature is active }

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

Blade Directive

<code-snippet name="Blade Directive" lang="blade"> @feature('new-dashboard') <x-new-dashboard /> @else <x-old-dashboard /> @endfeature </code-snippet>

Activating / Deactivating

<code-snippet name="Activating Features" lang="php"> Feature::activate('new-dashboard'); Feature::for($user)->activate('new-dashboard'); </code-snippet>

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