Contributing to HMS Commander¶
Thank you for your interest in contributing to HMS Commander! This project embraces CLB Engineering's LLM Forward Approach and welcomes contributions from both humans and AI-assisted workflows.
Quick Start for Contributors¶
1. Fork and Clone¶
2. Set Up Development Environment¶
# Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Linux/Mac
# Install in editable mode with all dependencies
pip install -e ".[all]"
3. Read the Context Files¶
Before contributing, familiarize yourself with:
- AGENTS.md - Shared repository contract for coding agents
- CLAUDE.md - Claude Code loader that imports
AGENTS.md - STYLE_GUIDE.md - Coding standards and patterns
- LLM Development Guide - LLM Forward approach overview
Development Workflow¶
LLM Forward Development¶
HMS Commander is built using the LLM Forward approach. When using Claude, Codex, or other LLMs:
- Provide AGENTS.md: Include the shared repository contract as context
- Reference style guide: Mention specific patterns to follow
- Use examples: Point to existing code as reference
- Iterate: Review AI-generated code carefully
Code Quality Standards¶
Static Type Hints (Optional but Encouraged)¶
from pathlib import Path
import pandas as pd
def get_subbasins(basin_path: str) -> pd.DataFrame:
"""Type hints improve LLM understanding."""
...
Comprehensive Docstrings (Required)¶
Use Google-style docstrings with examples:
def function_name(param1: type1, param2: type2) -> return_type:
"""
Brief description.
Detailed explanation of what the function does,
why it exists, and how to use it.
Args:
param1 (type1): Description of param1
param2 (type2): Description of param2
Returns:
return_type: Description of return value
Raises:
ErrorType: When this happens
Example:
>>> from hms_commander import Module
>>> result = function_name("value1", 123)
>>> print(result)
expected_output
Note:
Additional considerations or warnings
"""
Logging (Required)¶
Use the @log_call decorator:
from ._logging_config import log_call
@staticmethod
@log_call
def my_function(param: str) -> bool:
"""Function automatically logged."""
...
Testing¶
HMS Commander uses example-based testing with real HEC-HMS projects:
# tests/test_new_feature.py
from pathlib import Path
import sys
import pytest
# Flexible imports
try:
from hms_commander import HmsExamples, NewFeature
except ImportError:
sys.path.append(str(Path(__file__).parent.parent))
from hms_commander import HmsExamples, NewFeature
def test_new_feature():
"""Test with real HMS project."""
# Extract example project
project_path = HmsExamples.extract_project("castro")
# Test your feature
result = NewFeature.do_something(project_path)
# Assertions
assert result is not None
assert len(result) > 0
Run tests:
Contribution Types¶
Bug Fixes¶
- Create an issue describing the bug
- Reference the issue in your PR
- Add a test that reproduces the bug
- Fix the bug
- Verify the test passes
New Features¶
- Check GitHub Issues for planned features
- Open an issue for discussion
- Follow the class design patterns (see Style Guide)
- Add comprehensive documentation
- Create example notebook demonstrating usage
- Update API documentation
Documentation¶
- Docstrings: In-code documentation
- User Guide:
docs/user_guide/ - Examples: Jupyter notebooks in
examples/ - API Reference: Auto-generated from docstrings
Example Notebooks¶
Notebooks should:
- Use flexible import pattern
- Use HMS example projects when possible
- Include clear markdown explanations
- Be tested before submission
# Standard notebook import pattern
from pathlib import Path
import sys
try:
from hms_commander import init_hms_project
except ImportError:
sys.path.append(str(Path().resolve().parent))
from hms_commander import init_hms_project
Code Review Process¶
What We Look For¶
✅ Good practices:
- Follows style guide
- Has comprehensive docstrings
- Includes working examples
- Uses @log_call decorator
- Handles errors appropriately
- Updates AGENTS.md when shared agent rules change
❌ Red flags: - No documentation - Breaks existing tests - Doesn't follow static class pattern - Missing error handling - No usage example
Review Checklist¶
Before submitting a PR:
- [ ] Code follows STYLE_GUIDE.md
- [ ] All functions have docstrings with examples
- [ ] Tests pass (
pytest tests/) - [ ] Example notebook created (if applicable)
- [ ]
AGENTS.mdupdated if shared agent guidance changed - [ ] No breaking changes (or clearly documented)
- [ ] Logging configured properly
Documentation Builds¶
Local Documentation¶
Build and serve docs locally:
Open http://localhost:8000 in your browser.
Documentation Structure¶
docs/
├── index.md # Home page
├── getting_started/ # Installation, quick start
├── user_guide/ # Comprehensive guides
├── examples/ # Notebook documentation
├── api/ # API reference (auto-generated)
├── data_formats/ # HMS file format specs
└── llm_dev/ # Development guides
LLM-Driven Development Tips¶
Using Claude Code¶
When working with Claude Code:
- Set context: Paste or reference
AGENTS.md; Claude Code will loadCLAUDE.mdas its adapter - Specify patterns: Reference style guide sections
- Provide examples: Point to similar existing code
- Iterate: Review and refine AI suggestions
Effective Prompts¶
Good prompt:
"Add a method to HmsBasin to extract reach parameters, following the same pattern as get_loss_parameters(). Use HmsFileParser for parsing, add @log_call decorator, include comprehensive docstring with example."
Poor prompt:
"Add reach parameters"
AI-Assisted Testing¶
Use LLMs to: - Generate test cases - Create example data - Draft documentation - Suggest edge cases
But always: - Review generated code - Test thoroughly - Verify against style guide
Release Process¶
HMS Commander follows semantic versioning:
- Major (X.0.0): Breaking changes
- Minor (0.X.0): New features, backward compatible
- Patch (0.0.X): Bug fixes
Releases are managed by maintainers.
Getting Help¶
- Questions: Open a GitHub Discussion
- Bugs: Create an Issue
- Features: Start with an Issue for discussion
- LLM Help: Reference
AGENTS.mdfor shared context andCLAUDE.mdfor Claude-specific loading
Code of Conduct¶
Be respectful, inclusive, and constructive. We're building tools for the engineering community together.
Attribution¶
Contributors are recognized in: - Git commit history - Release notes - Project documentation
Recognition¶
Significant contributions may be acknowledged in: - Release notes or project documentation - Release announcements - Documentation
Thank you for contributing to HMS Commander! Your work helps the hydrologic engineering community automate and improve their workflows.