Hacker
Ivan Bhargava
@ivanbhargava
Petri: run Flagsmith experiments where the code lives
Flagsmith Experimentation HackathonNov 2026
Petri is an open-source VS Code extension (plus a CLI and GitHub Action) that runs Flagsmith experiments from the place they actually break: the code. An experiment is only as good as the code that feeds it, and the failures are silent. A self-hosted SDK sends its events to Flagsmith Cloud unless eventsApiUrl is set. trackEvent("Checkout_Completed") never counts for a metric on checkout_completed. getValue() serves the variant but records no exposure. A variant without a key creates a phantom arm. Nothing errors; a week later the results are empty or wrong. And when an experiment does finish, the losing branch stays in the code forever. Petri connects to your (self-hosted) Flagsmith and: - catches 20 of these failures as you type, as diagnostics with quick fixes, next to the line that causes them; - locks the treatment: petri.lock.json records what each running experiment serves, so changing it mid-run is flagged in the editor, in CI (offline) and against Flagsmith. No other tool checks that an experiment still tests what it started testing; - watches production: Petri Watch reads Flagsmith's hourly per-arm timelines and alerts when an arm stops converting or enrolling or the split breaks, naming the commit that caused it, in the editor, as a CLI exit code, or hourly in a scheduled Action. Proven on a staged incident (https://github.com/Ivan825/petri/blob/main/docs/watch.md#a-real-run): a checkout route that forgot trackEvent passed all 20 static rules, the shop took 37 orders Flagsmith never counted, and Watch flagged it and named the right commit; - remembers the decision: completing records the winner and its evidence, and a lens keeps it above the shipped code; - shows live experiment state where the flag is read: CodeLens with lift and chance to win, hovers with the split and per-arm results, and a results panel with credible intervals; - decides with one conservative rule, shared by the UI and the AI: ship only at ≥95% chance to win, with no guardrail likely hurt, no sample-ratio mismatch and no phantom arms; - acts: start, pause and complete experiments, then remove the losing code path; - delegates to an Experiment Copilot (Claude) that goes from idea → flag, metrics and code → start → judge → ship → delete the losing branch. Every Flagsmith write shows the exact HTTP request, and every code change shows a diff, before you approve. Who it's for: developers who own the code behind an experiment, especially teams running Flagsmith themselves. The same rules run in CI (petri check / the GitHub Action), so a broken experiment fails a pull request instead of wasting a week of traffic.
AgentRehearsal
First CommitSep 2026
https://builder.aws.com/content/3JatYhrbOe8dPZTOVoGeIUGu1a5/agentrehearsal