Introduction
Thank you for your interest in contributing to Bench! Contributing to open source means you’re helping make things better for not only yourself, but everyone else too. We appreciate you taking the initiative to contribute to the commons.Great projects depend on good code quality and adhering to certain standards. Following these guidelines ensures that developers can quickly give feedback on your contribution and help make it better.
Development Setup
To contribute to Bench development, you’ll need to set up an editable installation.Clone and Install
Install in Editable Mode
Install bench in editable mode using pip:This creates a link to your local repository, so any changes you make are immediately reflected.
Editable Mode Warning
When running bench in editable mode, you’ll see this warning:BENCH_DEVELOPER environment variable:
Switching Back to Production
When you’re done developing:Contribution Guidelines
Feedback Policy
We strive for a “Zero Pull Request Pending” policy:- If your PR meets requirements, it will be merged within a day
- If it doesn’t meet requirements, it will be closed with feedback
- Don’t worry if your PR is closed - fix the issues and re-open it!
Pull Request Requirements
1. Test Cases
1. Test Cases
Add test cases for your changes, even simple ones that just call the function.For UI changes, include screenshots or animated GIFs.
2. User Experience
2. User Experience
If your change involves user experience:
- Add screenshots showing before/after
- Include narration of the user flow
- Provide animated GIFs for complex interactions
3. Documentation
3. Documentation
Update relevant documentation:
- Command help text
- README files
- Code comments
- API documentation
4. Explanation
4. Explanation
For design changes:
- Explain the use case
- Describe why your approach is better
- If adding/replacing libraries, provide references
5. Keep PRs Small
5. Keep PRs Small
Try to keep pull requests to ~30 lines of code (excluding tests and config).For large features:
- Break them into smaller parts
- Submit incremental PRs
- Use cascading pull requests
- Hide incomplete features from users
6. Passing Tests
6. Passing Tests
Ensure all automated tests pass:
7. Code Style
7. Code Style
Follow the existing code style:
- Use tabs for indentation (matching existing codebase)
- Consistent formatting
- Meaningful variable names
- Clear function/method names
8. No Breaking Changes
8. No Breaking Changes
Avoid breaking changes when possible. If necessary:
- Provide migration path
- Update documentation
- Include deprecation warnings
Code Quality Standards
Naming Conventions
Commands:Indentation
Bench uses tabs for indentation (we know, but changing would lose history):Documentation Strings
Testing
Running Tests
Writing Tests
Tests are located inbench/tests/. Follow existing patterns:
Git Workflow
Create Feature Branch
Create a branch for your changes:Use descriptive branch names:
fix-issue-123add-new-commandimprove-error-handling
Make Changes
Make your changes and commit them:Use clear commit messages:
fix: description- Bug fixesfeat: description- New featuresdocs: description- Documentationrefactor: description- Code refactoringtest: description- Tests
Pull Request Template
Use this template for your PR description:Environment Variables for Development
Useful environment variables during development:Getting Help
Discussions
Ask questions and discuss ideas
GitHub Issues
Report bugs and request features
Code of Conduct
Community guidelines
Security
Report security vulnerabilities
Code Review Process
- Submission: You submit a pull request
- Initial Review: Maintainers review within 24-48 hours
- Feedback: You receive feedback on changes needed
- Iteration: Make requested changes and update PR
- Approval: Once approved, PR is merged
- Release: Changes included in next release
Recognition
Your contributions are valued! Contributors are:- Listed in the repository’s contributor graph
- Mentioned in release notes (for significant contributions)
- Part of the growing Frappe community