Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ review to their owning team instead.

Ownership is by directory. Skills not listed above (`audit`, `audit-*`,
`cost-cutting`, `creating-product-tours`, `error-tracking`, `events-audit`,
`feature-flags`, `llm-analytics`, `logs`, `migrate`, `omnibus`,
`posthog-best-practices`, `quack`, `tools-and-features`) fall through the
`feature-flags`, `feature-flags-setup`, `llm-analytics`, `logs`, `migrate`,
`omnibus`, `posthog-best-practices`, `quack`, `tools-and-features`) fall through the
default and are owned by `team-wizard-docs`. Today CODEOWNERS only
auto-requests review — approval is not a merge gate.

Expand Down
10 changes: 10 additions & 0 deletions context/commandments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ commandments:
- For flags that affect initial render, evaluate server-side and pass as props to prevent UI flicker
- Client-side hooks may return undefined initially while flags load - handle this loading state

# Exception to `nextjs` / `nextjs-feature-flags` (analytics-simple path:
# instrumentation-client, no provider). Only for skills that server-evaluate
# flags and bootstrap them into the client. Do not add this tag to the
# docs-only `feature-flags` group.
nextjs-flags-bootstrap:
- When flags are evaluated on the server and bootstrapped into the client, initialize posthog-js via PostHogProvider with a per-request bootstrap option — not in instrumentation-client.ts, which cannot take per-request bootstrap
- If instrumentation-client.ts (or .js) already inits posthog-js, move that init into the provider and keep existing api_host / defaults / other options. Do not leave both inits in place
- If there is no existing client init, the provider is the only client init — do not add instrumentation-client.ts
- Evaluate flags with posthog-node evaluateFlags() once per request. Do not call getAllFlags, getFeatureFlag, or isFeatureEnabled — each is its own /flags request

javascript_web:
- When a reverse proxy is configured, both /static/* AND /array/* must route to the assets origin (us-assets.i.posthog.com or eu-assets.i.posthog.com).
- posthog-js is the JavaScript SDK package name
Expand Down
22 changes: 22 additions & 0 deletions context/skills/feature-flags-setup/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Feature flags install — Next.js App Router. Distinct from wizard audit
# feature-flags (read-only) and from the docs-only `feature-flags` group.
type: skill
template: description.md
category: feature-flags
description: Add the cheap feature-flags path to an existing PostHog install on Next.js App Router 15.3+. Evaluates flags server-side with posthog-node.evaluateFlags(), bootstraps the values into the client to avoid flicker and a duplicate /flags fetch, and disables /flags polling in CI. After one confirm, optionally creates one boolean flag at 0% rollout and gates one additive UI path so production users are unchanged until rollout is raised. Does not replace the default wizard integration.
tags: [feature-flags, javascript, react, nextjs-flags-bootstrap]
cli:
role: command
command: feature-flags
shared_docs:
- https://posthog.com/docs/feature-flags/start-here.md
- https://posthog.com/docs/feature-flags/bootstrapping.md
- https://posthog.com/docs/feature-flags/cutting-costs.md
- https://posthog.com/docs/feature-flags/adding-feature-flag-code.md
variants:
- id: all
display_name: Next.js App Router
tags: []
docs_urls:
- https://posthog.com/docs/libraries/next-js.md
- https://posthog.com/docs/libraries/js/config.md
Loading