---
lang: en
---

# Feature flags

Feature flags are the switches your code checks, and you can connect PostHog or LaunchDarkly so Cactus can count the flags your code checks and read their state when it writes a page that checks one. You connect a flag tool in the Flag tools panel on the Sources page of the web app.

> Verified against the product on 2026-11-15

## Connect PostHog

1. In [Settings › Sources](https://app.heycactus.ai/settings/sources), select **Connect PostHog** on the PostHog row under **Flag tools**.
2. Sign in to PostHog. Cactus asks PostHog for read access to feature flags, projects and group types only.
3. You come back to Settings › Sources, where the PostHog row names the project it is connected to.

## Connect LaunchDarkly

1. In [Settings › Sources](https://app.heycactus.ai/settings/sources), select **Connect LaunchDarkly** on the LaunchDarkly row under **Flag tools**.
2. Paste a LaunchDarkly access token into **Reader token**. The token needs the Reader role, and Cactus only reads with it. Select **Find projects**, which stays off until a token is pasted.
3. Pick the **Project** and the **Environment** the token can see, then select **Save**.

> **Note:** Finding projects stores nothing. Save checks the project and environment with LaunchDarkly again, then keeps the token only to read your flags.

## What the rows say

Each row says how many flags your code checks with that tool, counting each flag name once. A check whose flag name Cactus cannot work out is not counted.

- `"No PostHog flag checks found in your code"` means your code checks no flag with PostHog.
- `"Your code checks _the number_ flags with PostHog"` gives how many flags your code checks with it, in the singular for one.

Cactus reads a flag's state each time it writes a page that checks that flag. After a flag changes, ask Cactus to republish those pages, which is what a [build](https://cactus.heycactus.ai/builds) does.

## Disconnect a tool

In [Settings › Sources](https://app.heycactus.ai/settings/sources), select **Disconnect** on the tool's row under **Flag tools**.

Disconnecting deletes the token and the project from Cactus. Nothing the tool answered is kept, so nothing else is removed.

## If Cactus can't tell the PostHog project

Until a teammate chooses one, the PostHog connection reads no flags for this product.

When your PostHog sign-in sees several projects, Cactus picks one by the flags your code checks.

- The sign-in sees one project, and Cactus connects it.
- Several projects, and one defines more of the flags your code checks than any other, so Cactus connects that one.
- Otherwise it waits for a choice: no project is visible, two or more tie for the most, or none defines a flag your code checks.

## If a tool turns Cactus away

| What you see | What it means | What to do |
| --- | --- | --- |
| "PostHog turned down Cactus' access. Connect again to fix it." | PostHog refused the saved token, so the PostHog row offers **Connect again** in place of **Disconnect**. | Select **Connect again** on the PostHog row. |
| "LaunchDarkly turned down this token. Disconnect, then connect with a new Reader token." | LaunchDarkly refused the saved token. | Select **Disconnect** on the LaunchDarkly row, then connect again with a new token. |
| "PostHog connection was cancelled." | You stopped the PostHog sign-in before it finished. | Select **Connect PostHog** again. |
| "PostHog could not complete that connection." | Cactus could not finish the PostHog connection. | Select **Connect PostHog** again. |
| "That PostHog connection expired. Connect again." | The PostHog sign-in took longer than 10 minutes to finish. | Select **Connect PostHog** again. |
| "LaunchDarkly refused the token." | The Reader token was refused when Cactus looked for its projects. | Paste a token that can see your projects, then select **Find projects**. |
| "LaunchDarkly could not be reached." | Cactus could not reach LaunchDarkly to read its projects. | Select **Find projects** again. |
| "That token can see no project." | The token reads no project at all. | Paste a different token. |
| "That project and environment are not ones the token can see." | The project or environment picked is not one the token reads. | Pick a project and environment the token can see, then select **Save**. |
