Contributing to promptfoo
We love contributions from the community! Here is how to get started.
Development Setup
Prerequisites
- Node.js 18+
- npm or yarn
Quick Start
git clone https://github.com/promptfoo/promptfoo.git
cd promptfoo
npm install
npm run build
Running Tests
# Unit tests
npm test
# Watch mode
npm run test:watch
# Integration tests
npm run test:integration
# Linting
npm run lint
Project Structure
src/
assertions/ # Built-in assertion implementations
providers/ # LLM provider integrations
redteam/ # Red teaming and adversarial testing
evaluator/ # Core evaluation engine
web/ # Web UI (React)
cli/ # CLI commands
types/ # TypeScript type definitions
Contribution Guidelines
What We Accept
- Bug fixes: Include a failing test case when possible
- New providers: Implement the
ApiProviderinterface - New assertions: Follow the assertion interface pattern
- Documentation: Improvements, examples, tutorials
- Performance: Evaluation speed optimizations
- Red teaming: New attack strategies and detectors
Pull Request Process
- Fork the repository
- Create a feature branch from
main - Write tests for new functionality
- Ensure all tests pass:
npm test - Lint your code:
npm run lint:fix - Submit a PR with a clear title and description
Commit Convention
type(scope): description
feat(provider): add Mistral AI provider
fix(assertion): handle null responses in contains assertion
docs(readme): update installation instructions
test(evaluator): add edge case tests for parallel evaluation
Code Standards
- TypeScript strict mode
- Jest for testing
- ESLint + Prettier for formatting
- No
anytypes without explicit justification - JSDoc comments on exported functions
Adding a New Provider
- Create
src/providers/<name>.ts - Implement the
ApiProviderinterface - Register in
src/providers/index.ts - Add tests in
test/providers/<name>.test.ts - Add documentation in
site/docs/providers/
License
By contributing, you agree that your contributions will be licensed under the MIT License.