{"id":50802124,"url":"https://github.com/launchdarkly-labs/statsig-to-ld","last_synced_at":"2026-06-12T21:07:54.084Z","repository":{"id":362747901,"uuid":"1225035000","full_name":"launchdarkly-labs/statsig-to-ld","owner":"launchdarkly-labs","description":"CLI to convert metrics from Statsig to LaunchDarkly","archived":false,"fork":false,"pushed_at":"2026-06-05T18:28:51.000Z","size":353,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-05T19:18:59.787Z","etag":null,"topics":["cli","experimentation","featureflags","go","launchdarkly","metrics","migration","statsig"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/launchdarkly-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-29T22:05:49.000Z","updated_at":"2026-06-05T18:00:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/launchdarkly-labs/statsig-to-ld","commit_stats":null,"previous_names":["launchdarkly-labs/statsig-to-ld"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/launchdarkly-labs/statsig-to-ld","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchdarkly-labs%2Fstatsig-to-ld","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchdarkly-labs%2Fstatsig-to-ld/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchdarkly-labs%2Fstatsig-to-ld/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchdarkly-labs%2Fstatsig-to-ld/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/launchdarkly-labs","download_url":"https://codeload.github.com/launchdarkly-labs/statsig-to-ld/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchdarkly-labs%2Fstatsig-to-ld/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34262230,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","experimentation","featureflags","go","launchdarkly","metrics","migration","statsig"],"created_at":"2026-06-12T21:07:53.302Z","updated_at":"2026-06-12T21:07:54.071Z","avatar_url":"https://github.com/launchdarkly-labs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# statsig-to-ld\n\nA CLI for migrating from Statsig to LaunchDarkly.\n\n\u003e **Important — read this first.** This tool migrates **flag and metric definitions, and targeting rules**, from Statsig to LaunchDarkly. For the SDK code rewrite (Statsig SDK calls → LaunchDarkly SDK calls), use the bundled Claude Code skill at [`skills/statsig-to-launchdarkly-migrator/`](skills/statsig-to-launchdarkly-migrator/SKILL.md). It does not run experiments. It does not recreate every Statsig feature 1:1. See [`docs/migration-playbook.md`](docs/migration-playbook.md) for what you still need to do yourself.\n\n## Overview\n\nFive CLI subcommands plus a bundled Claude Code skill:\n\n| Surface | What it does | Writes to |\n|---|---|---|\n| [`analyze`](docs/cli-reference.md#analyze) (CLI) | Read-only Statsig project survey + sizing report | Nothing |\n| [`flags import`](docs/cli-reference.md#flags-import) (CLI) | Create LaunchDarkly flag shells from Statsig gates and dynamic configs | LaunchDarkly |\n| [`targeting import`](docs/cli-reference.md#targeting-import) (CLI) | Apply per-environment targeting rules, rollouts, and overrides | LaunchDarkly |\n| [`metrics convert`](docs/cli-reference.md#metrics-convert) (CLI) | Convert Statsig metric definitions | LaunchDarkly |\n| [`warehouse`](docs/cli-reference.md#warehouse-native-migration) (CLI) | Set up LaunchDarkly warehouse integrations and metric data sources from Statsig (metric definitions are migrated separately by `metrics convert`) | LaunchDarkly + warehouse |\n| [`skills/statsig-to-launchdarkly-migrator/`](skills/statsig-to-launchdarkly-migrator/SKILL.md) (Claude Code skill) | Rewrite Statsig SDK calls → LaunchDarkly SDK calls in your codebase | Your source files |\n\n## Quick start (coding agent)\n\nPaste this into any coding agent\n\n```\nRead the README at https://github.com/launchdarkly-labs/statsig-to-ld and follow\nthe Agent Instructions section.\n```\n\nYour agent will then run the [Agent Instructions](#agent-instructions) below — asking which path(s) you need (SDK code, flags, targeting, metrics, warehouse-native integrations), prompting you to export credentials securely in your shell, and running the appropriate surface.\n\nFor running the CLI directly without an agent, see [`docs/cli-reference.md`](docs/cli-reference.md) — full subcommand reference, lossy-feature handling, warehouse walkthrough, and the AI-agent integration table.\n\n## Agent Instructions\n\nThis section is for AI coding agents (Claude Code, Codex, Cursor, etc.) helping a user migrate from Statsig to LaunchDarkly. Use it to pick the right surface for what the user is migrating, then follow the linked guide. Detailed CLI flags and examples live in [`docs/cli-reference.md`](docs/cli-reference.md).\n\n### Step 1 — Ask what to migrate\n\nAsk the user which paths they need (multi-select). Do this even if you are operating in auto-mode:\n\n| Path | What | Where to go |\n|---|---|---|\n| **A — SDK code** | Statsig SDK calls → LaunchDarkly SDK calls in application code | Load [`skills/statsig-to-launchdarkly-migrator/SKILL.md`](skills/statsig-to-launchdarkly-migrator/SKILL.md) and run its phases. |\n| **B — Flags** | Statsig gates / dynamic configs → LD flag shells | [`statsig-to-ld flags import`](docs/cli-reference.md#flags-import) |\n| **C — Targeting rules** | Per-environment rules, rollouts, overrides on existing LD flag shells | [`statsig-to-ld targeting import`](docs/cli-reference.md#targeting-import) (requires B first) |\n| **D — Metrics** | Statsig metric definitions → LD metrics | [`statsig-to-ld metrics convert`](docs/cli-reference.md#metrics-convert) |\n| **E — Warehouse-native integrations** | Data export + experimentation integrations + LD metric data sources, from a Statsig warehouse-native project | See Step 2 |\n\n### Step 2 — If the user picked E, ask which warehouse scope\n\nAsk one follow-up:\n\n- **\"I already have the LaunchDarkly warehouse integration set up; I only need to migrate metric data sources.\"** → [`statsig-to-ld warehouse --only data-sources`](docs/cli-reference.md#running-only-one-phase). Skips the integrations wizard, creates LD data sources, writes `source-mapping.json`.\n- **\"I haven't set up the LaunchDarkly warehouse integration yet — do all of it.\"** → [`statsig-to-ld warehouse`](docs/cli-reference.md#warehouse-native-migration) with no `--only` flag. Runs the full pipeline: integrations wizard + data sources + `source-mapping.json`.\n\nEither path produces a `source-mapping.json` file. **Then run path D** to migrate the warehouse-native metric definitions: `statsig-to-ld metrics convert --source-mapping source-mapping.json` binds each metric to the LD data source `warehouse` just created. The agent shim at [`.claude/agents/statsig-warehouse-migrator.md`](.claude/agents/statsig-warehouse-migrator.md) has the wizard-by-wizard detail for the warehouse subcommand.\n\n### Step 3 — Check credentials before running anything\n\n**Applies to paths B, C, D, and E only.** Path A handles its own credentials inside the skill (via `ldcli` to `.env`).\n\nBefore running any CLI command, check whether the user's shell already has the two required environment variables:\n\n```bash\n[ -n \"$STATSIG_CONSOLE_KEY\" ] \u0026\u0026 echo \"STATSIG_CONSOLE_KEY: set\" || echo \"STATSIG_CONSOLE_KEY: NOT set\"\n[ -n \"$LD_API_KEY\" ]          \u0026\u0026 echo \"LD_API_KEY: set\"          || echo \"LD_API_KEY: NOT set\"\n```\n\nIf either is `NOT set`, **do not ask the user to paste the key into the chat**. Anything pasted into the chat lands in the conversation transcript and may be logged or persisted. Instead, give the user this exact snippet to run in their own terminal:\n\n```bash\nread -rs STATSIG_CONSOLE_KEY \u0026\u0026 export STATSIG_CONSOLE_KEY   # console-... from Statsig\nread -rs LD_API_KEY \u0026\u0026 export LD_API_KEY                     # api-... from LaunchDarkly\n```\n\nWhy this form:\n- `read -rs` reads with **no echo** (the key never appears on screen) and **no backslash interpretation** (so a `\\` in the key isn't misread). This avoids the key landing in shell history that `export KEY=value` would create.\n- The two `export` statements then make the values available to any subprocess (including the CLI the agent runs).\n\n**Important constraint:** the user must run these `read -rs \u0026\u0026 export` lines in **the same shell session that the agent's subprocess inherits from**. If the agent is already running and the user exports keys in a *different* terminal, the agent's subprocess won't see them. After the user reports the export is done, re-check with the snippet above; if values still show `NOT set`, ask the user to restart the agent session so the new shell environment is inherited.\n\nFor users on Windows / fish / non-POSIX shells, give the equivalent (`Read-Host -AsSecureString` on PowerShell, `read -s` + `set -x` on fish) — same principle: no echo, no history, no chat-paste.\n\nOnly after both env vars are confirmed set should you run any `statsig-to-ld \u003csubcommand\u003e` command. The CLI reads them automatically; never pass keys as `--statsig-key` / `--ld-key` flags when env vars are set, since flag values are visible in `ps` output.\n\n## Prerequisites\n\n- Go 1.24+ (to build from source) or a pre-built binary from the [Releases](https://github.com/launchdarkly-labs/statsig-to-ld/releases) page\n- A Statsig **Console API Key** (`console-xxx`) — create at Statsig Console \u003e Project Settings \u003e Keys \u0026 Environments\n- A LaunchDarkly **API access token** (`api-xxx`) — create at **Account settings → Authorization → Access tokens** with a role that can write flags, metrics, and (optionally) environments in the target project. The Writer role works.\n- **For the SDK-rewrite skill only:** Claude Code (or another Claude interface), `node` 18+ to run the skill's helper scripts, and [`ldcli`](https://github.com/launchdarkly/ldcli) (the skill auto-installs it if missing).\n\n## Installation\n\n### CLI (from source)\n\n```bash\ngo build -o statsig-to-ld .\n\n# With version stamped into the binary\ngo build -ldflags \"-X github.com/launchdarkly-labs/statsig-to-ld/cmd.version=1.0.0\" \\\n  -o statsig-to-ld .\n```\n\n### CLI (pre-built binary)\n\nDownload from the [Releases](https://github.com/launchdarkly-labs/statsig-to-ld/releases) page.\n\n### SDK-rewrite skill\n\nThe Claude Code skill that rewrites Statsig SDK calls to LaunchDarkly is bundled in this repo at [`skills/statsig-to-launchdarkly-migrator/`](skills/statsig-to-launchdarkly-migrator/SKILL.md). To make it available to Claude Code in any project (not just this one), symlink or copy it into `~/.claude/skills/`:\n\n```bash\nmkdir -p ~/.claude/skills/\n\n# Symlink (recommended — picks up future updates from this repo)\nln -s \"$(pwd)/skills/statsig-to-launchdarkly-migrator\" \\\n  ~/.claude/skills/statsig-to-launchdarkly-migrator\n\n# Or, install a snapshot\ncp -R skills/statsig-to-launchdarkly-migrator ~/.claude/skills/\n```\n\nWhen running Claude Code inside *this* repository, no install step is needed — the skill auto-loads from `skills/`. A legacy compat shim at [`.claude/agents/statsig-to-launchdarkly-sdk-migrator.md`](.claude/agents/statsig-to-launchdarkly-sdk-migrator.md) redirects users who previously installed the older agent file.\n\n## CLI usage and reference\n\nFull manual flow, per-subcommand reference, lossy-feature handling, the warehouse-native migration walkthrough, EU/FedRAMP, release process, and the AI-agent integration table all live in [`docs/cli-reference.md`](docs/cli-reference.md).\n\nIf you arrived here from a search for a specific subcommand or flag, jump to that doc.\n\n## See also\n\n- [`docs/cli-reference.md`](docs/cli-reference.md) — full CLI reference (subcommands, flags, warehouse walkthrough, AI-agent integrations)\n- [`docs/migration-playbook.md`](docs/migration-playbook.md) — what this tool **doesn't** do (SDK rewrites, layers, experiments, holdouts, segment recreation, cutover, rollback)\n- [`AGENTS.md`](AGENTS.md) — operator guide for AI agents driving the CLI\n- [`CHANGELOG.md`](CHANGELOG.md)\n- [`CONTRIBUTING.md`](CONTRIBUTING.md)\n- [`SECURITY.md`](SECURITY.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchdarkly-labs%2Fstatsig-to-ld","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaunchdarkly-labs%2Fstatsig-to-ld","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchdarkly-labs%2Fstatsig-to-ld/lists"}