Thank you for considering contributing to Galacticus! We welcome contributions from developers, scientists, and researchers who are passionate about galaxy formation physics and computational methods. Whether you're fixing bugs, adding features, improving documentation, or using AI tools to accelerate your development, your work helps advance scientific discovery.
We welcome many types of contributions:
- Bug reports - Help us identify and fix issues
- Features & enhancements - New functionality and improvements to existing code
- Documentation - Updates to comments, docstrings, wiki pages, and guides
- Performance improvements - Optimizations and efficiency gains
- AI-assisted contributions - Code developed with tools like GitHub Copilot, Claude, ChatGPT, etc.
- Published results - Parameter files and commit details for papers that use Galacticus, contributed to the separate Galacticus Publications repository (see its contribution guidelines)
All contributions, regardless of source, must be thoroughly verified by a human developer before submission.
Before developing, ensure you have:
- A modern Fortran compiler (
gfortran≥ 16; earlier versions will not compile Galacticus) make- HDF5, FFTW3, and GSL libraries
- Python 3 (≥ 3.9)
Tip: Use GitHub Codespaces for a pre-configured environment with all dependencies installed.
For detailed setup instructions, see the README.
-
Clone the repository:
git clone https://github.com/galacticusorg/galacticus.git cd galacticus -
Install Python dependencies (puts the modules under
python/on the import path and pulls in numpy / scipy / h5py / lxml / matplotlib / …):pip install -e '.[test]'The
[test]extra also installspytest. Drop it if you don't need to run the unit tests. -
Build Galacticus:
make -jN Galacticus.exe
Replace
Nwith the number of CPU cores to use. -
Run the quick test:
./Galacticus.exe parameters/quickTest.xml
-
(Optional) Run the Python unit tests:
export GALACTICUS_EXEC_PATH=`pwd` python -m pytest -v
These cover the build-system modules under
python/and the documentation tooling underscripts/doc/. They do not run the model regression tests. -
(Optional) Run the model regression suite — the tests CI relies on to check the compiled model:
python3 testSuite/test-all.py
This runs every
testSuite/test-*.pyscript (logs are written totestSuite/outputs/); you can also run one directly, e.g.python3 testSuite/test-Python-interface.py. Most of these require a builtGalacticus.exeand the run-time datasets (GALACTICUS_DATA_PATH).
See the Testing and Continuous Integration guide for full details on the test suites and the CI pipeline.
Galacticus uses git hooks (kept in the separate gitHooks repository) to run pre-commit checks and to enforce the commit-message format. They are recommended for all contributors and are required if you commit directly to the repository. The simplest way to install them is to clone the hooks repository and point your Galacticus clone at it:
git clone https://github.com/galacticusorg/gitHooks.git
git config core.hooksPath /path/to/gitHooksThe hooks provide:
commit-msg— enforces Conventional Commits format (see Submitting a Pull Request below for the allowed types).pre-commit— runs static checks on staged files (Fortran static analysis;.bib, XML, YAML, and Python validation; docstring and spell checks; leftover-debug detection) and, ifclaudeis installed, an automated review.prepare-commit-msg— pre-fills a suggested Conventional-Commits message (whenclaudeis installed).pre-push— asks you to confirm before pushing directly tomaster.
See the gitHooks README for more detail.
For more help, see the README troubleshooting section.
For new features or bug fixes, create a branch:
git checkout -b feature/your-feature-nameFor simple changes (e.g. fixing a typo) you can commit directly to master; for anything larger, use a branch and open a pull request.
When making changes:
- Follow code conventions - See the Coding documentation for detailed style guidelines, naming conventions, and component patterns
- Test locally - Build and test your changes before submitting
- Add yourself as a contributor (see Contributor Attribution below)
- Document your changes - Update comments and documentation as needed
Before submitting a pull request, ensure:
- The code builds successfully:
make -jN Galacticus.exe - The quick test passes:
./Galacticus.exe parameters/quickTest.xml - Any new code you added is tested (or explain why not in the PR)
- Your changes don't break existing tests or functionality
- Documentation and comments are clear and updated
When your changes are ready:
-
Push your branch to your fork:
git push origin your-branch-name
-
Create a pull request - Use the PR template, which asks for:
- A summary of your changes
- Type of change (bug fix, feature, documentation, etc.)
- How to test your changes
- Confirmation that you've tested locally
-
Follow Conventional Commits - The
commit-msghook enforces the Conventional Commits formattype(scope): summary. Use clear, descriptive messages:fix: resolve memory leak in component initialization feat: add new parameter for galactic winds model docs: update building instructions for gfortran 16The allowed types are:
fix,feat,build,chore,ci,docs,style,test,refactor,perf,revert, andclean. For a breaking change, append!after the type/scope (e.g.feat!: …) and include aBREAKING CHANGE:footer. -
Address CI/CD checks - Automated checks run on your PR (see Testing and Continuous Integration for what runs and when). If any checks fail, review the error messages and update your code accordingly.
-
Respond to code review - A maintainer will review your PR and may request changes. This is normal and helps maintain code quality!
-
Merging - Pull requests are merged with a merge commit; we do not squash-merge or rebase-merge. This preserves commit hashes, which is a correctness requirement rather than a style preference: parameter file migrations in
scripts/aux/migrations.xmlare keyed by the hash of the commit that introduced each change, and a migration whose hash is absent from the history is silently skipped. See Merging pull requests.For the same reason, if you rebase or amend a branch that adds an entry to
migrations.xml, update that entry'scommitattribute to the new hash before pushing, and re-run the migration on a representative parameter file to confirm the expectedUpdating to revision <hash>line still appears.
We use inline markers to track who contributed to each part of the code. This is automatically extracted to generate contributor lists.
Add a marker comment near the top of the file, listing the contributors by name:
!+ Contributions to this file made by: Jane Developer, Bob Smith.
module myModule
! ... rest of code
end module myModuleA !+ marker records names only — never a description of what was contributed. The names are parsed as a comma-separated list, so anything else on the line is read as if it were a contributor's name. Keep the marker to the single sentence above; nothing else belongs on the line, not even a trailing comment.
So, not:
!+ Bug fix for issue #1234 implemented by Jane Developer, with tests by Bob Smith.which names neither developer in the contributor list: it is split on the comma, the first fragment is discarded as too long to be a name, and the second is published as a "contributor" called with tests by Bob Smith.
Describe what changed in the commit message (and in the pull request), not in the source. This keeps the markers short and keeps the generated contributor list free of stray fragments of prose.
The extractContributors.py script automatically generates contributor lists from these markers; the result appears in the Acknowledgments section of the documentation. The same script validates them — run it before you push, as the Validate-Contributor-Markers CI job runs the same check on your pull request:
python3 scripts/doc/extractContributors.py --checkIt reports any marker which is not of the names-only form above, and exits non-zero if it finds one.
We welcome contributions developed with AI tools like GitHub Copilot, Claude, ChatGPT, and similar services. The key requirement is human verification.
AI is an excellent development tool that can help you:
- Generate boilerplate code faster
- Suggest implementations for routine tasks
- Refactor existing code
- Write documentation and comments
However, you are responsible for:
- Reviewing the code - Ensure it's correct, efficient, and follows project conventions
- Testing thoroughly - AI-generated code needs the same level of testing as human-written code
- Understanding the logic - You should be able to explain every part of your code
- Catching issues - Look for edge cases, performance problems, and style inconsistencies that AI may have missed
- Use the AI tool - Prompt Claude, Copilot, etc. to help with your implementation
- Review what it generated - Read through all the code carefully
- Test it locally - Build and run your changes, including edge cases
- Fix any issues - Update the code based on your testing and review
- Add attribution comments - Record the AI tool as a contributor (optional but appreciated)
- Submit your PR - You're now the verified human author of this contribution
If you used AI tools, add the tool's name to the file's !+ contributor marker, alongside your own:
!+ Contributions to this file made by: Jane Developer, Claude.
module myModule
! ... rest of code
end module myModuleName the tool as you would a person — Claude, Copilot, ChatGPT — with no description of what it contributed. As with every !+ marker (see Contributor Attribution above), the line carries names only: the marker is parsed as a comma-separated list of contributors, so a description would both corrupt the generated contributor list and make the in-source marker needlessly long.
Record what the AI contributed, and how you verified it, in the commit message instead — that is where the detail belongs, and where git log/git blame will surface it for whoever needs it:
fix(numerical): correct the dark energy equation of state parameter w_a
The value passed for w_a was 3(1+w_0), which is correct only for w_0 = -1.
Diagnosed and drafted with assistance from Claude; reviewed, tested, and
verified by Jane Developer.
This helps future maintainers understand the code's origin and appreciate your use of modern development tools.
Human verification ensures:
- Correctness - The code actually does what it's supposed to do
- Quality - It meets project standards and best practices
- Maintainability - Future developers can understand and modify it
- Responsibility - You stand behind the code you submit
This is not a distrust of AI—it's professional responsibility. Just as you'd review code from any source before merging it, AI-generated code needs human eyes. In fact, using AI tools responsibly can help you write better code faster.
- Questions? Ask in the discussion forum
- Found a bug? Open an issue with details about your system and the error
- Need more details? See the developer guide on ReadTheDocs
- Development docs? Check the Development documentation for build system details and the Coding documentation for code conventions
By contributing to Galacticus, you agree that your contributions will be licensed under the same GPL-3.0 license as the project. This ensures that the code remains open and available to the scientific community.
Thank you for contributing to Galacticus! We appreciate your time and effort in helping advance this project.