Contributing to Sugar
January 3, 2026 ยท View on GitHub
Thank you for your interest in contributing to Sugar! This guide will help you get started with contributing to the project.
๐ฟ Branching Model
Sugar uses Gitflow for development:
| Branch | Purpose |
|---|---|
main | Production releases only - never commit directly |
develop | Integration branch for all new work |
feature/* | New features (branch from develop) |
bugfix/* | Bug fixes (branch from develop) |
hotfix/* | Urgent production fixes (branch from main) |
All contributions should target the develop branch, not main.
๐ Quick Start
-
Fork and Clone
git clone https://github.com/yourusername/sugar.git cd sugar git checkout develop # Always work from develop -
Set up Development Environment
# Create virtual environment python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install in development mode pip install -e ".[dev]" # Install pre-commit hooks pre-commit install -
Run Tests
pytest -
Make Changes and Submit PR
๐ ๏ธ Development Setup
Prerequisites
- Python 3.11+
- Claude Code CLI (installation guide)
- Git
- Node.js (for Claude CLI)
Installation
# Clone your fork
git clone https://github.com/yourusername/sugar.git
cd sugar
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install development dependencies
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
# Verify installation
sugar --version
pytest --version
๐งช Testing
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=sugar --cov-report=html
# Run specific test file
pytest tests/test_cli.py
# Run specific test
pytest tests/test_cli.py::TestSugarInit::test_init_creates_sugar_directory
# Run tests in parallel (faster)
pytest -n auto
Test Structure
tests/conftest.py- Shared fixtures and configurationtests/test_cli.py- CLI command teststests/test_core_loop.py- Core Sugar loop teststests/test_storage.py- Database and storage teststests/test_*.py- Additional test modules
Writing Tests
import pytest
from click.testing import CliRunner
from sugar.main import cli
def test_my_feature(cli_runner):
"""Test description following Google style."""
result = cli_runner.invoke(cli, ['command', 'args'])
assert result.exit_code == 0
assert "expected output" in result.output
๐๏ธ Code Quality
Pre-commit Hooks
We use pre-commit hooks to ensure code quality:
- black - Code formatting
- flake8 - Linting
- isort - Import sorting
- mypy - Type checking
- bandit - Security scanning
# Run all pre-commit hooks
pre-commit run --all-files
# Run specific hook
pre-commit run black --all-files
Manual Quality Checks
# Format code
black sugar/ tests/
# Sort imports
isort sugar/ tests/
# Lint code
flake8 sugar/ tests/
# Type checking
mypy sugar/
# Security scan
bandit -r sugar/
๐ Development Workflow
1. Choose an Issue
- Look at open issues
- Good first issues are labeled
good-first-issue - Ask questions in the issue comments if unclear
2. Create a Branch
# Ensure you're on develop and up to date
git checkout develop
git pull origin develop
# Create your feature branch from develop
git checkout -b feature/your-feature-name
# or
git checkout -b bugfix/issue-description
3. Make Changes
- Write code following existing patterns
- Add tests for new functionality
- Update documentation if needed
- Follow the coding standards
4. Test Your Changes
# Run tests
pytest
# Run quality checks
pre-commit run --all-files
# Test CLI manually
sugar init
sugar add "test task"
sugar status
5. Commit Changes
git add .
git commit -m "feat: add new feature
Detailed description of what was changed and why.
Closes #123"
6. Push and Create PR
git push origin feature/your-feature-name
Then create a pull request on GitHub targeting the develop branch (not main).
๐ Coding Standards
Python Style
- PEP 8 compliance (enforced by black and flake8)
- Type hints for all functions and methods
- Google-style docstrings
- Maximum line length: 88 characters
Example Function
def add_task(
title: str,
task_type: str = "feature",
priority: int = 3,
description: Optional[str] = None,
) -> str:
"""Add a new task to the work queue.
Args:
title: Task title
task_type: Type of task (feature, bug_fix, etc.)
priority: Priority level 1-5
description: Optional detailed description
Returns:
Task ID of the created task
Raises:
ValueError: If priority is not between 1-5
"""
if not 1 <= priority <= 5:
raise ValueError("Priority must be between 1-5")
# Implementation here
return task_id
Commit Message Format
We use Conventional Commits:
type(scope): description
Longer description if needed
Closes #123
Types:
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Code style changes (formatting)refactor:- Code refactoringtest:- Adding or updating testschore:- Maintenance tasks
๐งฉ Project Structure
sugar/
โโโ sugar/ # Main package
โ โโโ core/ # Core loop and orchestration
โ โโโ discovery/ # Work discovery modules
โ โโโ executor/ # Claude CLI execution
โ โโโ learning/ # Adaptive learning
โ โโโ storage/ # Database and persistence
โ โโโ utils/ # Utility functions
โโโ tests/ # Test suite
โโโ docs/ # Documentation
โ โโโ user/ # User documentation
โ โโโ dev/ # Developer documentation
โโโ config/ # Configuration files
โโโ .github/ # CI/CD workflows
๐ Reporting Bugs
Before Reporting
- Search existing issues
- Check if it's already fixed in the
developbranch - Try to reproduce with minimal example
Bug Report Template
**Bug Description**
A clear description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Run `sugar init`
2. Run `sugar add "test"`
3. See error
**Expected Behavior**
What you expected to happen.
**Environment**
- OS: [e.g. macOS 14.0]
- Python: [e.g. 3.11.5]
- Sugar: [e.g. 0.1.0]
- Claude CLI: [e.g. 1.2.3]
**Additional Context**
Any other context about the problem.
๐ก Feature Requests
Before Requesting
- Check if similar feature exists
- Search existing feature requests
- Consider if it fits Sugar's goals
Feature Request Template
**Is your feature request related to a problem?**
A clear description of what the problem is.
**Describe the solution you'd like**
A clear description of what you want to happen.
**Describe alternatives you've considered**
Other solutions you've considered.
**Additional context**
Any other context or screenshots.
๐ Pull Request Process
- Fork the repository
- Checkout the
developbranch - Create a feature branch from
develop - Make your changes
- Add tests for new functionality
- Update documentation if needed
- Run tests and quality checks
- Submit pull request targeting
develop
PR Checklist
- Tests pass (
pytest) - Code is formatted (
black,isort) - Code passes linting (
flake8) - Type checking passes (
mypy) - Security scan passes (
bandit) - Documentation updated if needed
- CHANGELOG.md updated for significant changes
๐ Recognition
Contributors will be:
- Added to the contributors list
- Mentioned in release notes for significant contributions
- Given credit in documentation
๐ Getting Help
- GitHub Issues - For bugs and feature requests
- GitHub Discussions - For questions and general discussion
- Email - contact@roboticforce.io
๐ License
By contributing, you agree that your contributions will be licensed under the same license as the project (MIT).
Thank you for contributing to Sugar! ๐