A public gallery and CLI for browsing, installing, and submitting animated pixel-art pets that float on your screen and react to Codex and other coding agents.
dif-sh/dif
Feature flags and A/B tests stored as Markdown files in your repo, compiled by a CLI into a typed TypeScript client.
Open-source alternative to:LaunchDarkly
Optimizely
- Stars
- 129
- Forks
- 0
- Open issues
- 1
- Last commit
- 5 days ago
What is it?
dif keeps every feature flag and experiment as a single Markdown file with YAML frontmatter, checked into git next to the code it affects. The `dif` CLI validates these files (weights, surface references, audience attributes, and experiment collisions) and compiles active ones into a typed TypeScript client and a context.json file. The runtime SDK is dependency-free and uses deterministic bucketing, so a given user gets the same variant across page loads and devices without any assignment database or network call.
The project targets Next.js, React and SvelteKit, with separate npm packages for each. Flags and experiments share one file format: a flag is an experiment ramped toward 100%. The CLI includes commands to scaffold a project, draft experiments, trace a user's assignment with `dif qa`, and record conclusions that feed later experiments on the same surface.
Analytics are optional. Without a publishable key, flags evaluate locally and nothing is sent anywhere. Connecting to dif.sh Cloud adds event ingest and statistical analysis, while custom event handlers can forward data to any pipeline. The repo also ships Claude Code skills and agent instruction files for authoring and concluding experiments.
Key features
- 01Flags and experiments are Markdown files with frontmatter, reviewed in pull requests.
- 02`dif validate` checks weights, surface references, audiences and experiment collisions.
- 03`dif build` generates a typed TypeScript client and context.json.
- 04Deterministic bucketing runs the same logic in the Rust CLI and the TypeScript SDK.
- 05`dif qa` shows the variant a given user receives and why.
- 06Optional connection to dif.sh Cloud for event ingest and analysis.
Use cases
- Running A/B tests on a Next.js or SvelteKit site without a hosted flag dashboard.
- Keeping flag history and experiment conclusions in git alongside the code.
- Letting AI coding agents create and retire flags by editing files in the repo.
Quick start
- 1
Install the dif CLI with npm (requires Node 20 or later)
npm install -g @dif.sh/cli - 2
Scaffold the dif/ directory, config and agent files in your repo
dif init - 3
Draft a new experiment file, then open it, set status: active, and run dif build
dif new home-hero-cta --surface home - 4
Compile active experiments into the typed TypeScript client
dif build
Things to know
- Requires Node 20 or later for the npm install path; a standalone binary is also offered.
- The generated client is gitignored, so CI and deploy must run dif build before the app build.
- The npm SDK packages are ESM-only and have no require() entry point.
- Cloud analytics are optional and require a dif.sh Cloud publishable key.
Topics
FAQ
- What is dif?
- Feature flags and A/B tests stored as Markdown files in your repo, compiled by a CLI into a typed TypeScript client. dif keeps every feature flag and experiment as a single Markdown file with YAML frontmatter, checked into git next to the code it affects. The `dif` CLI validates these files (weights, surface references, audience attributes, and experiment collisions) and compiles active ones into a typed TypeScript client and a context.json file. The runtime SDK is dependency-free and uses deterministic bucketing, so a given user gets the same variant across page loads and devices without any assignment database or network call.
- Is dif free to use? What license does it have?
- dif is open source under the MIT license. Check the license terms before using it in commercial products.
- Is dif still maintained?
- Actively maintained. The last commit to dif was on Oct 16, 2026.
- What can I use dif for?
- Running A/B tests on a Next.js or SvelteKit site without a hosted flag dashboard. Keeping flag history and experiment conclusions in git alongside the code. Letting AI coding agents create and retire flags by editing files in the repo.
- How do I install dif?
- Install the dif CLI with npm (requires Node 20 or later): npm install -g @dif.sh/cli Scaffold the dif/ directory, config and agent files in your repo: dif init Draft a new experiment file, then open it, set status: active, and run dif build: dif new home-hero-cta --surface home Compile active experiments into the typed TypeScript client: dif build
- Where can I get dif?
- The source code and installation instructions are on GitHub: https://github.com/dif-sh/dif
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
An MIT-licensed Claude agent skill that teaches Claude to create and edit motion-graphics videos in code with Remotion.
Open-source Next.js-native headless CMS and app framework with a TypeScript backend and customizable React admin panel.
A collection of installable instruction packs that give AI coding agents Vercel-specific and React/Next.js best-practice knowledge.
Open-source, self-hostable stock market dashboard with live charts, price alerts, watchlists and company insights, built with Next.js and TradingView.
A framework for building documentation websites with React.js, supporting Next.js, Astro, and Vite-based React frameworks.