FlowSpec CLI - AI-powered autonomous React test generation with self-healing capabilities and intelligent file watching
npm install @cosmah/flowspec-cli๐ AI-powered autonomous React test generation with intelligent file watching
FlowSpec automatically generates, executes, and maintains comprehensive test suites for your React applications using GPT-4. Features intelligent file watching, incremental updates, and token optimization.


- ๐ค AI-Powered Generation - GPT-4 analyzes your components and generates comprehensive tests
- ๐ Intelligent File Watching - Automatically detects new/changed React components
- ๐ Incremental Updates - Only updates changed parts of existing tests (saves tokens)
- ๐ Real-time Dashboard - Monitor coverage, performance, and team productivity
- โก Zero Configuration - Works out of the box with React, Next.js, and more
- ๐ฏ Smart Context - Uses codebase embedding for intelligent test generation
- ๐ง Auto-Installation - Automatically installs and configures Vitest dependencies
- ๐ฐ Token Optimized - Smart duplication guards and incremental updates
- โก Smart Caching - Instant test generation for unchanged components (5-second rule)
- ๐ง Auto-Healing - Automatically fixes test syntax and import errors
- ๐ Test Debt Counter - Track untested components and estimate coverage time
- ๐จ Design System Awareness - Detects and leverages UI libraries (Shadcn, MUI, Chakra, Ant Design)
- ๐ฆ Data Archetype Detection - Automatically finds and uses factories, mocks, and test data
- ๐ Background Execution - Non-blocking test execution with real-time feedback
``bashInstall globally
npm install -g @cosmah/flowspec-cli@latest
$3
`bash
1. Create account and login
flowspec signup
flowspec login2. Initialize in your React project
cd my-react-app
flowspec init3. Start intelligent file watching (auto-embeds codebase)
flowspec watch # Automatically embeds codebase + generates tests for ALL existing files + watches for changes
`๐ Commands
$3
`bash
flowspec signup # Create new account
flowspec login # Login to existing account
flowspec logout # Logout from FlowSpec
`$3
`bash
flowspec init # Initialize FlowSpec in project
flowspec embed # Embed codebase for AI context
flowspec status # Show project status and info
flowspec dashboard # Open web dashboard
flowspec update # Update CLI to latest version
`$3
`bash
flowspec generate # Generate tests for specific files
flowspec watch # Auto-generate tests for existing + new files
`๐ ๏ธ How It Works
$3
FlowSpec watches multiple directories and automatically detects React components:
- src/*/.{tsx,jsx} (Create React App)
- app/*/.{tsx,jsx} (Next.js App Router)
- pages/*/.{tsx,jsx} (Next.js Pages Router)
- components/*/.{tsx,jsx}
- lib/*/.{tsx,jsx}$3
Before generating tests, FlowSpec:
- โ
Checks if test file already exists
- โ
Compares modification times (component vs test)
- โ
Skips generation if test is up-to-date
- โ
Only updates when component is newer$3
For existing tests:
- ๐ Sends existing test code to AI
- โ๏ธ AI only modifies changed/new parts
- ๐ฐ Saves ~60% on API tokens
- ๐ฏ Preserves working test logic$3
When you run flowspec watch:
1. ๐ Scans all existing React components
2. ๐งช Generates tests for components without tests
3. ๐ Starts watching for new files and changes
4. โก Auto-generates tests for any new/modified components๐ Supported Project Structures
FlowSpec works with all React project structures:
$3
`
src/
โโโ components/
โ โโโ Button.tsx โ Button.test.tsx
โ โโโ Header.tsx โ Header.test.tsx
โโโ pages/
โโโ Home.tsx โ Home.test.tsx
`$3
`
app/
โโโ components/
โ โโโ Navigation.tsx โ Navigation.test.tsx
โโโ dashboard/
โ โโโ page.tsx โ page.test.tsx
โโโ (auth)/
โโโ login/
โโโ page.tsx โ page.test.tsx
`$3
`
pages/
โโโ index.tsx โ index.test.tsx
โโโ about.tsx โ about.test.tsx
โโโ api/ (ignored)
components/
โโโ Layout.tsx โ Layout.test.tsx
`โ๏ธ Configuration
$3
`json
{
"projectId": "proj_abc123",
"userId": "user_xyz789",
"name": "My React App",
"framework": "react",
"apiUrl": "https://api.flowspecai.dev"
}
`๐ฏ File Watching Behavior
$3
- โ
.tsx and .jsx files only
- โ
Files starting with capital letter (React components)
- โ
Files in src/, app/, pages/, components/, lib/$3
- โ */.test.{tsx,jsx} (existing test files)
- โ */.spec.{tsx,jsx} (spec files)
- โ node_modules/, dist/, build/, .next/
- โ Files starting with lowercase (utilities, not components)$3
`bash
$ flowspec watchStarting FlowSpec file watcher...
Found 12 existing components
Generating tests for existing files...
File found: src/components/Button.tsx
Generated test for src/components/Button.tsx
Test file: src/components/Button.test.tsx
Status: Passing
Attempts: 1
File found: app/dashboard/Header.tsx
Test exists: app/dashboard/Header.test.tsx - checking for updates...
Skipping app/dashboard/Header.tsx - test is up to date
Initial sync complete! Processed 12 existing files
FlowSpec watcher is ready and monitoring for changes
Press Ctrl+C to stop watching
File changed: src/components/Button.tsx
Updated test for src/components/Button.tsx
Test file: src/components/Button.test.tsx
Status: Passing
Attempts: 1
`๐ฐ Token Optimization Features
$3
- Before: Generated tests for all files every time
- After: Only generates when needed (new files or component changes)
- Savings: ~60% reduction in API calls$3
- Before: Rewrote entire test file for small component changes
- After: Sends existing test + component changes for incremental updates
- Savings: ~40% reduction in prompt tokens$3
- Before: Tests included decorative comments and emojis
- After: Clean, minimal test code focused on functionality
- Savings: ~20% reduction in response tokens๐จ Troubleshooting
$3
"Project not initialized"
`bash
flowspec init
`"Not logged in"
`bash
flowspec login
`"No components found"
Make sure you have
.tsx or .jsx files starting with capital letters in:
- src/, app/, pages/, components/, or lib/ directories"Test generation failed"
- Check internet connection
- Verify you have sufficient API credits
- Try
flowspec status to check connection๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
$3
`bash
git clone https://github.com/cosmah/flowspec-cli.git
cd flowspec-cli
npm install
npm run dev
`๐ License
MIT License - see LICENSE file for details.
๐ Links
- ๐ Website: https://flowspecai.dev
- ๐ Documentation: https://flowspecai.dev/docs
- ๐ Issues: GitHub Issues
- ๐ฌ Support: support@flowspecai.dev
๐ What's New in v2.1.0
$3
- ๐ฆ Auto-Installation: FlowSpec automatically detects and installs missing dependencies during test generation
- ๐ Smart Verification: Checks both package.json and actual node_modules to ensure dependencies exist
- ๐ Automatic Retry: Tests automatically retry after dependency installation completes
- ๐ฏ Error Classification: Distinguishes between dependency errors (auto-installs) and test code errors (auto-heals)$3
- ๐ก๏ธ Resource Cleanup: Enhanced connection pool management and cleanup prevents resource leaks
- ๐ Process Management: Improved child process tracking ensures no orphaned processes on exit
- โฑ๏ธ HTTP Timeouts: All HTTP requests now have explicit timeouts for better reliability
- ๐ช Graceful Shutdown: Enhanced signal handling ensures proper cleanup on all exit paths$3
- โ
Healer Node: Fixed critical bug preventing auto-healing (re module import)
- โ
Code Extraction: Improved healer response parsing and validation
- โ
Dependency Errors: Fixed false auto-healing triggers on dependency issues$3
- โก Smart Caching (Ghost Runner): Instant test generation for unchanged components - bypass API calls when code hasn't changed
- ๐ง Auto-Healing: Automatically detects and fixes test syntax errors, import issues, and component mismatches
- ๐ Test Debt Counter: Real-time visibility into untested components with time-to-coverage estimates
- ๐จ Design System Awareness: Automatically detects UI libraries (Shadcn, MUI, Chakra, Ant Design) and tailors test generation
- ๐ฆ Data Archetype Detection: Finds and leverages existing factories, mocks, and test data patterns
- ๐ Background Test Execution: Non-blocking test runs with silent notifications for seamless workflow
- ๐ฏ Intelligent Failure Analysis: Classifies test failures as "our fault" (auto-heals) vs "their fault" (shows suggestions)
- โก 5-Second Rule: Smart caching ensures sub-5-second response times for cached components๐ What's New in v2.0.0
- ๐ Intelligent File Watching: Automatically processes existing files + watches for changes
- ๐ Next.js App Router Support: Full support for
app/` directory structure ---
Made with โค๏ธ by the FlowSpec Team