AI-powered React component generator using Gherkin specifications and specialized agent pipelines.
react-agents generates production-ready React components directly from Gherkin feature files. Each component includes TypeScript code, CSS Module styles, Jest tests, and Ladle story filesβall generated in parallel by specialized AI agents.
Workflow:
- Write component specs in Gherkin (.feature files)
- Run generator:
pnpm run generate avatar - Get: Component + Styles + Tests + Stories automatically
- Visualize stories in Ladle dev server
- Iterate
- Monorepo: Turborepo + pnpm workspaces
- Generator: TypeScript, Node.js
- LLM API: OpenAI-compatible (Ollama local or OpenAI remote)
- Component Framework: React 19, TypeScript
- Styling: CSS Modules
- Testing: Jest + React Testing Library
- Visualization: Ladle.dev (component story browser)
- Local LLM: Ollama (OpenAI-compatible API)
react-agents (monorepo)
βββ apps/
β βββ generator/ # CLI: Gherkin β Components
β βββ ladle/ # Story visualizer
β βββ ...
βββ packages/
β βββ shared/ # Shared types (future)
β βββ ...
βββ pnpm-workspace.yaml
- Node.js 18+
- pnpm 9.0+
- Ollama running locally on port 11434
- Qwen2.5-Coder model (
ollama pull qwen2.5-coder)
Set OPENAI_API_KEY environment variable instead of using Ollama.
# Install pnpm if needed
npm install -g pnpm@9
# Clone and install
git clone <repo>
cd react-agents
pnpm installollama serve
# In another terminal:
ollama pull qwen2.5-coder# From repo root
pnpm run generate avatar
# or: pnpm run generate text, imagebutton, buttonThis creates in apps/ladle/stories/:
Avatar.tsx- ComponentAvatar.module.css- StylesAvatar.test.tsx- TestsAvatar.story.tsx- Ladle story
pnpm -F @react-agents/ladle dev
# Visit http://localhost:3000pnpm build # Build all apps
pnpm -F @react-agents/generator build # Build generator onlypnpm run generate avatar # Use avatar.feature file
pnpm run generate text # Use text.feature file
pnpm run generate button # Use button.feature file
node apps/generator/dist/index.js avatar # Direct executionpnpm dev # Start all dev servers (ladle + generator watch)
pnpm -F @react-agents/ladle dev # Start ladle onlypnpm test # Run all tests
pnpm test:watch # Watch mode
pnpm -F @react-agents/generator test # Generator tests onlyCreate apps/generator/features/mycomponent.feature:
Feature: MyComponent
Brief description of what component does
Scenario: Primary use case
Given a MyComponent
When props are set to X
Then component renders as Y
And displays Zpnpm run generate mycomponent
# or: pnpm run generate mycomponent.featurepnpm -F @react-agents/ladle dev
# Visit http://localhost:3000
# Component story appears under MyComponentFiles created automatically:
apps/ladle/stories/MyComponent.tsxapps/ladle/stories/MyComponent.module.cssapps/ladle/stories/MyComponent.test.tsxapps/ladle/stories/MyComponent.story.tsx
Edit files as needed. Next generation overwrites them.
Located in apps/generator/features/:
Feature: Avatar
Display user avatar as circular image
Scenario: Render avatar from URL
Given an Avatar component
When provided with imageUrl prop
Then the avatar displays the image
And the image is circular (border-radius: 50%)
And the image has fixed size (48px)Default (Ollama, local):
pnpm run generate avatar
# Uses http://localhost:11434/v1 automaticallyOpenAI API:
OPENAI_API_KEY=sk_... pnpm run generate avatarEdit apps/generator/src/agents/pipeline.json:
{
"model": "qwen2.5-coder", // Change to gpt-4, claude-3, etc
"pipeline": [...]
}Generator runs agents in parallel:
- GherkinParser β Parse .feature β ComponentModel
- ReactGenerator β Generate React component (TypeScript validation)
- StyleGenerator β₯ TestGenerator β₯ StoryGenerator β Run in parallel
- StyleGenerator β CSS Modules
- TestGenerator β Jest tests
- StoryGenerator β Ladle story
Ensure all relative imports have .js extensions in compiled output (handled automatically).
Check Ollama is running:
ollama serveollama pull qwen2.5-coder
# List available: ollama listNon-critical. Generator logs them but continues (see β οΈ Some TypeScript errors remain).
apps/generator/src/β Main CLIindex.tsβ Entry pointOrchestratorAgent.tsβ Pipeline orchestratorsub-agents/β Specialized AI agentsagents/pipeline.jsonβ Agent pipeline configfeatures/β Gherkin files
apps/ladle/β Component visualizerstories/β Generated component stories
.ladle/config.mjsβ Ladle configurationturbo.jsonβ Turborepo task configpnpm-workspace.yamlβ Workspace definition
- Add more Gherkin feature files
- Generate component library
- Deploy Ladle as static site
- Extend agents for more languages (Vue, Svelte)
- Add E2E tests with Playwright