Most small SaaS teams skip proper A/B testing because the operational overhead is brutal. You need a developer to build a variant, integrate a feature flag SDK, define metrics, and then interpret Bayesian credible intervals. A new open-source project called Twig aims to eliminate that friction by letting you text an AI agent to run the whole process. Built in 72 hours for the Toggle Wars hackathon, Twig allows users to describe a change in plain English, receive visual previews, and approve tests via WhatsApp or a web interface.
The End-to-End Workflow
Twig operates as a harness around the opencode coding agent. When a user requests a change, such as shortening a signup form, the agent edits the code in an isolated git branch named after the chat ID. It then spins up a local dev server and uses Playwright to capture before-and-after screenshots on both mobile and desktop viewports. The user selects the conversion metric from a list of actions actually available on the page, and Twig automatically injects the necessary Flagsmith SDK tracking code. Once approved, the agent publishes the branch to Vercel and configures a 50/50 split experiment in Flagsmith.
Enforcing Statistical Integrity
The most critical engineering challenge was preventing the LLM from overclaiming results. An agent that declares a "win" after only 200 visitors is dangerous. The team implemented six layers of defense, relying primarily on code rather than prompt instructions. The explain_results tool constructs a fact sheet with hard numbers, including confidence intervals and watch-out metrics. The UI renders cards directly from this data, keeping the model's generated text as a mere caption. Furthermore, a post-response validator checks every number in the agent's reply against the fact sheet, flagging any discrepancies to ensure the AI doesn't invent statistics.
Architecture and Platform Support
The system runs on a single VPS container behind Cloudflare, hosting a Next.js 16 web app, a FastAPI backend, and the opencode agent. Twig supports Shopify and WordPress by treating the theme as a repository, maintaining a git copy of the live theme for branch-based previews. The architecture uses an allowlist in present.py to filter what the user sees, ensuring that raw stack traces, API keys, and internal file paths never leak into the chat interface. This design choice keeps the interaction clean and secure, hiding the complexity of the underlying infrastructure.
Key Takeaways
- Twig reduces the A/B testing workflow to a text message conversation, lowering the barrier for non-technical founders.
- The project uses a six-layer validation system to prevent LLM hallucinations in statistical reporting, prioritizing code-based facts over prompt adherence.
- Built on Flagsmith's experimentation API, the agent handles flag creation, metric definition, and result refreshing automatically.
- The team successfully integrated Shopify and WordPress support by abstracting theme management into git workflows.
- The entire project was completed in 72 hours with roughly 20,000 lines of code, demonstrating the rapid prototyping potential of agentic workflows.
The Bottom Line
Twig proves that the bottleneck in experimentation isn't technical capability but operational complexity. By wrapping a coding agent in strict statistical guardrails, we can finally make data-driven decisions as easy as sending a text message.