feature-flags

We need to translate the given text from English to Brazilian Portuguese. The text is about managing React feature flags. We must preserve the name "feature-flags" if it appears, but it doesn't appear in the text. The text includes technical terms like "canary", "www", "React Native", "test renderer", "__VARIANT__", "@gate", "pragma", "gate()", etc. We should keep those as is. Also preserve numbers, URLs (none), protocol names (none). No extra commentary, no labels. Just translate the text. The text: "Manage React feature flags across channels, gate tests conditionally, and debug flag-specific test failures. Four flag files control defaults and channel-specific overrides (canary, www, React Native, test renderer) with __VARIANT__ flags simulating gatekeepers tested in both states Use @gate flagName pragma to skip tests entirely when a flag is unavailable, or inline gate() to branch assertions when behavior differs Adding a new flag requires entries in the main file plus all fork files;...

npx skills add https://github.com/facebook/react --skill feature-flags

React Feature Flags

Flag Files

FilePurpose
packages/shared/ReactFeatureFlags.jsDefault flags (canary), __EXPERIMENTAL__ overrides
packages/shared/forks/ReactFeatureFlags.www.jswww channel, __VARIANT__ overrides
packages/shared/forks/ReactFeatureFlags.native-fb.jsReact Native, __VARIANT__ overrides
packages/shared/forks/ReactFeatureFlags.test-renderer.jsTest renderer

Gating Tests

@gate pragma (test-level)

Use when the feature is completely unavailable without the flag:

// @gate enableViewTransition
it('supports view transitions', () => {
  // This test only runs when enableViewTransition is true
  // and is SKIPPED (not failed) when false
});

gate() inline (assertion-level)

Use when the feature exists but behavior differs based on flag:

it('renders component', async () => {
  await act(() => root.render(<App />));

  if (gate(flags => flags.enableNewBehavior)) {
    expect(container.textContent).toBe('new output');
  } else {
    expect(container.textContent).toBe('legacy output');
  }
});

Adding a New Flag

  1. Add to ReactFeatureFlags.js with default value
  2. Add to each fork file (*.www.js, *.native-fb.js, etc.)
  3. If it should vary in www/RN, set to __VARIANT__ in the fork file
  4. Gate tests with @gate flagName or inline gate()

Checking Flag States

Use /flags to view states across channels. See the flags skill for full command options.

__VARIANT__ Flags (GKs)

Flags set to __VARIANT__ simulate gatekeepers - tested twice (true and false):

/test www <pattern>              # __VARIANT__ = true
/test www variant false <pattern> # __VARIANT__ = false

Debugging Channel-Specific Failures

  1. Run /flags --diff <channel1> <channel2> to compare values
  2. Check @gate conditions - test may be gated to specific channels
  3. Run /test <channel> <pattern> to isolate the failure
  4. Verify flag exists in all fork files if newly added

Common Mistakes

  • Forgetting both variants - Always test www AND www variant false for __VARIANT__ flags
  • Using @gate for behavior differences - Use inline gate() if both paths should run
  • Missing fork files - New flags must be added to ALL fork files, not just the main one
  • Wrong gate syntax - It's gate(flags => flags.name), not gate('name')

Mais skills de facebook

gc-safe-coding
facebook
Para a explicação completa e a justificativa, veja doc/GCSafeCoding.md.
app-review-prep
facebook
Prepare um app da Meta para a App Review — verifica o status atual, requisitos pendentes, privilégios concedidos e histórico de envios. Use antes de enviar um app…
api-health
facebook
Monitore a saúde da API de um app da Meta — verifique limites de taxa, volume de chamadas e depreciações de API. Use para diagnosticar throttling, planejar capacidade ou se preparar para versões de API…
debug-webhooks
facebook
Solucione problemas de webhook para um app Meta — inspecione assinaturas ativas, identifique configurações incorretas e envie payloads de teste para verificar a entrega. Use quando…
api-integration
facebook
Orientar um desenvolvedor na configuração de uma integração com a API da Meta do zero — descobrir as APIs certas, buscar guias de configuração, requisitos de autenticação,…
webhook-setup
facebook
Configure webhooks para um app Meta de ponta a ponta — descubra tópicos disponíveis, assine campos e verifique com um payload de teste. Use ao configurar webhooks para…
test-ui
facebook
Testar o sistema de UI (PanelUI, ScreenSpace) contra o exemplo poke usando a CLI do iwsdk.
flags
facebook
Inspecionar e comparar estados de feature flags entre canais de lançamento do React. Visualizar todas as flags entre canais (www, www-modern, canary, next, experimental, variantes rn) ou comparar canais específicos com --diff. Formatos de saída incluem visualização padrão em tabela, exportação CSV e agrupamento por status de limpeza. Estados das flags indicados por símbolos: ativado (✅), desativado (❌), teste de variante (🧪), apenas perfilamento (📊). Armadilha comum: flags __VARIANT__ são testadas em ambos os estados no www; use --diff para identificar diferenças significativas...