Contributing to codebrief¶
Thank you for your interest in contributing to codebrief! We welcome contributions from developers of all skill levels. This guide will help you get started with contributing to our project.
๐ Table of Contents¶
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Reporting Bugs
- Requesting Features
- Development Workflow
- Coding Standards
- Testing Guidelines
- Pull Request Process
- Release Process
๐ Code of Conduct¶
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
๐ Getting Started¶
Prerequisites¶
- Python 3.9+: codebrief requires Python 3.9 or higher
- Poetry: For dependency management and virtual environments
- Git: For version control
- Pre-commit: For automated code quality checks
Development Setup¶
Fork and Clone the Repository
Install Dependencies
Set Up Pre-commit Hooks
Verify Installation
๐ค How to Contribute¶
Types of Contributions¶
We welcome several types of contributions:
- ๐ Bug Reports: Help us identify and fix issues
- โจ Feature Requests: Suggest new functionality
- ๐ Documentation: Improve or add documentation
- ๐งช Tests: Add or improve test coverage
- ๐ง Code: Fix bugs or implement new features
- ๐จ UI/UX: Improve the CLI interface and user experience
๐ Reporting Bugs¶
Before creating a bug report, please check the existing issues to avoid duplicates.
Bug Report Template¶
When reporting bugs, please use our issue template and include:
- Clear Description: What happened vs. what you expected
- Reproduction Steps: Detailed steps to reproduce the issue
- Environment: OS, Python version, codebrief version
- Error Messages: Full error messages and stack traces
- Sample Files: Minimal example files if relevant
Example:
**Bug Description**
The `codebrief tree` command crashes when encountering symlinks.
**Steps to Reproduce**
1. Create a symlink: `ln -s /path/to/target symlink`
2. Run: `codebrief tree`
3. Observe the error
**Expected Behavior**
The command should handle symlinks gracefully.
**Environment**
- OS: macOS 14.0
- Python: 3.11.5
- codebrief: 0.1.0
โจ Requesting Features¶
We love feature requests! Please check existing feature requests first.
Feature Request Guidelines¶
- Clear Use Case: Explain the problem you're trying to solve
- Proposed Solution: Describe your ideal solution
- Alternatives: Consider alternative approaches
- Implementation: Suggest how it might be implemented
- Breaking Changes: Note any potential breaking changes
๐ Development Workflow¶
Branching Strategy¶
Create a Feature Branch
Make Your Changes
- Write code following our coding standards
- Add tests for new functionality
Update documentation as needed
Test Your Changes
Commit Your Changes
๐ Coding Standards¶
We maintain high code quality standards using automated tools:
Code Style¶
- Formatter: Ruff for consistent formatting
- Linter: Ruff for code quality and style enforcement
- Line Length: 88 characters maximum
- Quotes: Double quotes for strings
- Imports: Sorted and organized automatically
Code Quality Tools¶
# Format code
poetry run ruff format
# Lint code
poetry run ruff check
# Fix auto-fixable issues
poetry run ruff check --fix
# Security scanning
poetry run bandit -r src/
Conventional Commits¶
We use Conventional Commits for clear commit history:
feat:
- New featuresfix:
- Bug fixesdocs:
- Documentation changestest:
- Test additions or modificationsrefactor:
- Code refactoringchore:
- Maintenance tasksci:
- CI/CD changes
Examples:
feat(tree): add support for custom tree symbols
fix(bundler): resolve encoding issues with non-UTF8 files
docs: add examples for advanced configuration
test: improve coverage for git provider module
Type Hints¶
- Use type hints for all function parameters and return values
- Import types from
typing
module when needed - Use
Optional[T]
for nullable values - Document complex types in docstrings
Documentation¶
- Docstrings: Use Google-style docstrings for all public functions
- Comments: Explain complex logic and business decisions
- README: Update README.md for user-facing changes
- API Docs: Update API documentation for new features
๐งช Testing Guidelines¶
Test Structure¶
tests/
โโโ tools/ # Tool-specific tests
โโโ utils/ # Utility function tests
โโโ conftest.py # Shared test fixtures
โโโ test_main.py # CLI integration tests
Writing Tests¶
- Test Coverage: Aim for 80%+ coverage for new code
- Test Types:
- Unit tests for individual functions
- Integration tests for CLI commands
Edge case testing for error conditions
Test Naming: Use descriptive test names
Fixtures: Use pytest fixtures for common test data
- Assertions: Prefer content-based assertions over brittle snapshot tests
Running Tests¶
# Run all tests
poetry run pytest
# Run specific test file
poetry run pytest tests/tools/test_tree_generator.py
# Run with coverage
poetry run pytest --cov=src/codebrief --cov-report=html
# Run tests matching a pattern
poetry run pytest -k "test_tree"
๐ Pull Request Process¶
Before Submitting¶
- Update Documentation: Ensure all documentation is current
- Add Tests: Include tests for new functionality
- Run Quality Checks: Ensure all pre-commit hooks pass
- Update Changelog: Add entry to CHANGELOG.md if applicable
PR Guidelines¶
- Clear Title: Use conventional commit format
- Detailed Description: Explain what and why
- Link Issues: Reference related issues with
Fixes #123
- Small PRs: Keep changes focused and reviewable
- Draft PRs: Use draft PRs for work-in-progress
PR Template¶
We provide a PR template that includes:
- Description of changes
- Type of change (bug fix, feature, etc.)
- Testing checklist
- Documentation updates
- Breaking changes
Review Process¶
- Automated Checks: All CI checks must pass
- Code Review: At least one maintainer review required
- Testing: Reviewers will test functionality
- Documentation: Ensure docs are clear and complete
- Merge: Maintainers will merge approved PRs
๐ Release Process¶
Version Management¶
- We use Semantic Versioning
- Versions are managed through Poetry
- Releases are tagged in Git
Release Checklist¶
- Update version in
pyproject.toml
- Update CHANGELOG.md
- Create release PR
- Tag release after merge
- Publish to PyPI (maintainers only)
๐ Getting Help¶
Communication Channels¶
- GitHub Issues: For bugs and feature requests
- GitHub Discussions: For questions and general discussion
- Documentation: Check our comprehensive docs
Maintainer Contact¶
For sensitive issues or questions, contact the maintainers directly through GitHub.
๐ Recognition¶
Contributors are recognized in:
- CHANGELOG.md for significant contributions
- GitHub contributors page
- Release notes for major features
Thank you for contributing to codebrief! Your efforts help make this tool better for the entire developer community. ๐