Agent Skillswarpdotdev/warp › add-feature-flag

add-feature-flag

GitHub

指导在Warp代码库中添加功能标志,包括配置Cargo特性、枚举定义及运行时检查,用于按渠道控制代码启用。

.agents/skills/add-feature-flag/SKILL.md warpdotdev/warp

Trigger Scenarios

需要添加新功能开关 实现代码的灰度发布或渠道隔离

Install

npx skills add warpdotdev/warp --skill add-feature-flag -g -y
More Options

Non-standard path

npx skills add https://github.com/warpdotdev/warp/tree/master/.agents/skills/add-feature-flag -g -y

Use without installing

npx skills use warpdotdev/warp@add-feature-flag

指定 Agent (Claude Code)

npx skills add warpdotdev/warp --skill add-feature-flag -a claude-code -g -y

安装 repo 全部 skill

npx skills add warpdotdev/warp --all -g -y

预览 repo 内 skill

npx skills add warpdotdev/warp --list

SKILL.md

Frontmatter
{
    "name": "add-feature-flag",
    "description": "Add a new feature flag to gate code changes in the Warp codebase."
}

add-feature-flag

Add a new feature flag to gate code changes in the Warp codebase.

Overview

Feature flags in Warp are compile-time flags that allow features to be selectively enabled for different channels (e.g.: Dev, Stable). They use a small runtime plumbing layer that checks if a flag is enabled.

TUI note

The FeatureFlag enum (warp_core/src/features.rs) and the runtime FeatureFlag::X.is_enabled() check are SHARED by both front-ends: the GUI desktop app (app/) and the headless TUI (crates/warp_tui). The Cargo-feature steps in this skill (app/Cargo.toml, app/src/lib.rs) are GUI-app-specific. Prefer runtime is_enabled() checks so a flag works in both front-ends with no per-binary wiring. Only if you truly need a compile-time Cargo feature in the TUI, wire it into crates/warp_tui/Cargo.toml as well. Test the TUI with ./script/run-tui.

Steps

1. Add to Cargo.toml

Add the feature to app/Cargo.toml under the [features] section, but NOT under the default nested stanza:

[features]
your_feature_name = []

2. Add to FeatureFlag enum

Add a new variant to the FeatureFlag enum in warp_core/src/features.rs:

#[derive(Sequence)]
pub enum FeatureFlag {
    YourFeatureName,
}

3. Add conditional compilation directive

Add the feature to app/src/lib.rs with a corresponding #[cfg(feature = "...")] attribute to ensure it's only included when enabled:

#[cfg(feature = "your_feature_name")]
YourFeatureName,

4. Gate code with runtime checks

In your code, use the runtime check to conditionally execute feature-gated code:

if FeatureFlag::YourFeatureName.is_enabled() {
    // feature-gated behavior
}

5. (Optional) Enable for dogfood builds

To enable the feature by default for Dev/dogfood builds, add it to the DOGFOOD_FLAGS array in features.rs:

pub const DOGFOOD_FLAGS: &[FeatureFlag] = &[
    FeatureFlag::YourFeatureName,
];

6. Running with feature flags

To test locally with the feature enabled:

cargo run --features your_feature_name

# Multiple features:
cargo run --features your_feature_name,another_feature

Keybindings with Feature Flags

If adding an EditableBinding or FixedBinding that's part of a gated feature, include an enabled predicate that checks the feature flag. This prevents the keybinding from appearing in keyboard settings when the feature is disabled.

Example:

EditableBinding::new(
    "action:name",
    "Action description",
    YourAction::Variant
)
.with_enabled(|| FeatureFlag::YourFeatureName.is_enabled())
.with_key_binding("cmdorctrl-key")

Rolling Out to Stable

When ready to enable the feature for all Warp Stable users, add it to the default array in app/Cargo.toml:

[features]
default = [
    "your_feature_name",
    # other default features...
]

Best Practices

  • Prefer runtime checks over cfg directives: Use FeatureFlag::YourFeatureName.is_enabled() instead of #[cfg(...)] when possible, so flags can be toggled without recompilation and are easier to clean up later
  • Use #[cfg(...)] only when code cannot compile without the flag (e.g., platform-specific code or missing dependencies)
  • Keep flags high-level and product-focused rather than per-call-site
  • Remove flags and dead branches after launch has stabilized

Version History

  • 726c1b6 Current 2026-07-24 20:21

Same Skill Collection

.agents/skills/add-telemetry/SKILL.md
.agents/skills/changelog-draft/SKILL.md
.agents/skills/classify-changelog-pr/SKILL.md
.agents/skills/cross-platform-cloud-verification/SKILL.md
.agents/skills/dedupe-issue-local/SKILL.md
.agents/skills/gui-create-launch-modal/SKILL.md
.agents/skills/gui-integration-test/SKILL.md
.agents/skills/gui-reproduce-bug-report-local/SKILL.md
.agents/skills/gui-settings-ui/SKILL.md
.agents/skills/gui-ui-guidelines/SKILL.md
.agents/skills/logging-and-error-reporting/SKILL.md
.agents/skills/promote-feature/SKILL.md
.agents/skills/remove-feature-flag/SKILL.md
.agents/skills/review-pr-local/SKILL.md
.agents/skills/rust-unit-tests/SKILL.md
.agents/skills/triage-issue-local/SKILL.md
.agents/skills/tui-testing/SKILL.md
.agents/skills/tui-ui-guidelines/SKILL.md
.agents/skills/tui-verify-change/SKILL.md
resources/bundled/mcp_skills/figma/figma-code-connect-components/SKILL.md
resources/bundled/mcp_skills/figma/figma-create-design-system-rules/SKILL.md
resources/bundled/mcp_skills/figma/figma-create-new-file/SKILL.md
resources/bundled/mcp_skills/figma/figma-generate-library/SKILL.md
resources/bundled/mcp_skills/figma/figma-implement-design/SKILL.md
resources/bundled/skills/add-mcp-server/SKILL.md
resources/bundled/skills/change-keybinding/SKILL.md
resources/bundled/skills/create-skill/SKILL.md
resources/bundled/skills/create-tab-config/SKILL.md
resources/bundled/skills/factory-files/SKILL.md
resources/bundled/skills/factory-mcp/SKILL.md
resources/bundled/skills/modify-settings/SKILL.md
resources/bundled/skills/oz-platform/SKILL.md
resources/bundled/skills/pr-comments/SKILL.md
resources/bundled/skills/tab-configs/SKILL.md
resources/bundled/skills/tui-migrate-setup/SKILL.md
resources/bundled/skills/update-tab-config/SKILL.md
resources/bundled/skills/warpctrl/SKILL.md
resources/channel-gated-skills/dogfood/test-warp-ui/SKILL.md
resources/channel-gated-skills/dogfood/triage-vulnerabilities/SKILL.md
resources/channel-gated-skills/dogfood/verify-ui-change-in-cloud/SKILL.md
.agents/skills/gui-onboarding-verification-skill/SKILL.md
.warp/skills/gui-integration-test-video/SKILL.md
resources/bundled/mcp_skills/figma/edit-figma-design/SKILL.md
resources/bundled/mcp_skills/figma/figma-generate-design/SKILL.md
resources/bundled/mcp_skills/figma/figma-use/SKILL.md
resources/bundled/skills/claude-api/SKILL.md

Metadata

Files
0
Version
04a7f83
Hash
35276f46
Indexed
2026-07-24 20:21

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-20 07:28
浙ICP备14020137号-1 $Гость$