"I'm CLU. I'm here to create the perfect system."
AI-powered test generation CLI that writes comprehensive, production-ready unit tests for your code in 14+ languages.
CLU analyzes your code and automatically generates test suites with edge cases, error handling, and proper structure using Claude AI. Point it at any code file and watch it create production-ready tests in seconds.
- π€ AI-Powered - Uses Claude Sonnet 4.5 for intelligent test generation
- π Auto-Detection - Automatically detects language and testing framework from file extension
- π― Comprehensive - Generates tests for main functionality, edge cases, and error handling
- β‘ Fast - Generates full test suites in seconds
- π Multi-Language - Supports JavaScript, TypeScript, Python, Go, Rust, Java, C++, and more
- π‘ Smart Naming - Follows language-specific test file conventions
| Language | Framework | Extension |
|---|---|---|
| JavaScript | Jest | .js, .jsx |
| TypeScript | Jest | .ts, .tsx |
| Python | pytest | .py |
| Go | testing | .go |
| Rust | cargo test | .rs |
| Java | JUnit | .java |
| C++ | Google Test | .cpp |
| Ruby | RSpec | .rb |
| PHP | PHPUnit | .php |
| Swift | XCTest | .swift |
| Kotlin | JUnit | .kt |
- Python 3.9+ (Download here)
- Claude API Key (Get one here)
- Clone the repository:
git clone https://github.com/yourusername/clu.git
cd clu- Install dependencies:
pip3 install anthropic python-dotenvOr using a virtual environment (recommended):
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install anthropic python-dotenv-
Configure your API key:
Create a
.envfile in the project root:
ANTHROPIC_API_KEY=your-api-key-here.env file to version control! Add it to .gitignore.
The above shows CLU:
- Detecting JavaScript + Jest framework
- Reading and analyzing
example.js - Generating comprehensive Jest tests
- Saving results to
example.test.js
python3 clu.py <code_file>CLU will automatically:
- Detect the programming language from the file extension
- Select the appropriate testing framework
- Analyze your code structure
- Generate comprehensive tests
- Save them with proper naming conventions
JavaScript:
python3 clu.py app.js
# Creates: app.test.js with Jest testsPython:
python3 clu.py calculator.py
# Creates: test_calculator.py with pytest testsGo:
python3 clu.py main.go
# Creates: main_test.go with Go testing testsIf you need to specify a different framework manually:
python3 clu.py mycode.js javascript mochaAfter CLU generates your tests, run them with the appropriate test runner:
JavaScript/TypeScript:
npm install --save-dev jest
npx jestRust:
cargo testfunction add(a, b) {
return a + b;
}
function multiply(a, b) {
return a * b;
}
function divide(a, b) {
if (b === 0) {
throw new Error("Cannot divide by zero");
}
return a / b;
}
module.exports = { add, multiply, divide };const { add, multiply, divide } = require('./example');
describe('Math Operations', () => {
describe('add()', () => {
test('should add two positive numbers correctly', () => {
expect(add(2, 3)).toBe(5);
});
test('should handle zero correctly', () => {
expect(add(0, 5)).toBe(5);
expect(add(5, 0)).toBe(5);
});
test('should handle negative numbers', () => {
expect(add(-2, 3)).toBe(1);
expect(add(-5, -3)).toBe(-8);
});
test('should handle decimal numbers', () => {
expect(add(0.1, 0.2)).toBeCloseTo(0.3);
});
});
describe('multiply()', () => {
test('should multiply two positive numbers correctly', () => {
expect(multiply(3, 4)).toBe(12);
});
test('should handle zero', () => {
expect(multiply(5, 0)).toBe(0);
expect(multiply(0, 5)).toBe(0);
});
test('should handle negative numbers', () => {
expect(multiply(-2, 3)).toBe(-6);
expect(multiply(-2, -3)).toBe(6);
});
});
describe('divide()', () => {
test('should divide two numbers correctly', () => {
expect(divide(6, 2)).toBe(3);
expect(divide(10, 5)).toBe(2);
});
test('should handle decimal results', () => {
expect(divide(5, 2)).toBe(2.5);
});
test('should throw error when dividing by zero', () => {
expect(() => divide(5, 0)).toThrow('Cannot divide by zero');
expect(() => divide(-10, 0)).toThrow('Cannot divide by zero');
});
test('should handle negative numbers', () => {
expect(divide(-6, 2)).toBe(-3);
expect(divide(6, -2)).toBe(-3);
expect(divide(-6, -2)).toBe(3);
});
});
});- File Analysis β CLU reads your code file and extracts the file extension
- Language Detection β Maps the extension to the appropriate language and testing framework
- Code Processing β Reads and prepares your code for analysis
- AI Generation β Sends structured prompt to Claude API with code context and testing requirements
- Test Creation β Claude generates comprehensive test suite following framework best practices
- File Output β Saves generated tests with language-appropriate naming conventions
CLU uses zero-shot prompting, meaning it generates tests without requiring:
- Example test files
- Training data
- Pre-configured templates
- Manual test structure definitions
The AI understands your code context and generates appropriate tests on the first attempt.
CLU uses the Anthropic Claude API with usage-based pricing. Typical costs per generation:
- Small file (~100 lines): ~$0.01
- Medium file (~500 lines): ~$0.05
- Large file (~1000 lines): ~$0.10
Anthropic provides $5 in free credits when you sign up, which covers hundreds of test generations.
- Batch processing (test entire directories at once)
- Auto-run tests and iterate on failures
- Custom test templates and configurations
- IDE extensions (VSCode, JetBrains)
- Support for additional testing frameworks
- Test coverage analysis and reporting
- Git hook integration for pre-commit testing
- Interactive mode for test refinement
Contributions are welcome! Feel free to:
- π Report bugs
- π‘ Suggest new features
- π§ Submit pull requests
- π Improve documentation
MIT License - see LICENSE for details
- Built with Claude API by Anthropic
- Inspired by TRON: Legacy (CLU character)
- Created to eliminate the tedious task of writing boilerplate tests
"Am I still to create the perfect system?" - CLU
"yeAHH" - Kevin Flynn
