Getting Started
Prerequisites
Before you begin, ensure you have:- Go 1.21 or later - Download Go
- Git - Version control
- Make - Build automation (usually pre-installed on macOS/Linux)
- A GitHub account - For submitting pull requests
Setting Up Your Development Environment
If you encounter build issues, see the Troubleshooting guide.
Project Structure
Understanding the codebase structure will help you navigate and contribute effectively:Key Components
- API Specs: OpenAPI definitions in
api/directory drive API client generation - Commands: Each command is implemented in
cmd/with a root command and subcommands - Modules: Business logic for specific services (migrations, package handling)
- Generated Code: API clients are auto-generated from OpenAPI specs
- Utilities: Shared functionality like error handling, output formatting, progress bars
Making Changes
Development Workflow
Commit your changes
Coding Standards
- Go Style: Follow the Effective Go guidelines
- Formatting: Use
gofmtandgoimports(run viamake format) - Linting: Code must pass
golangci-lintchecks (run viamake lint) - Error Handling: Use the error types in
util/common/errors/ - Testing: Write unit tests for new functionality
- Documentation: Add comments for exported functions and types
Commit Message Guidelines
Use clear, descriptive commit messages:feat: New featurefix: Bug fixdocs: Documentation changesrefactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
Adding New Commands
Command Structure
Commands follow the Cobra framework pattern. Here’s how to add a new command:Using Generated API Clients
API clients are generated from OpenAPI specs:Build System
The project uses a Makefile for common tasks:Available Make Targets
| Target | Description |
|---|---|
make build | Build the CLI binary (output: ./hc) |
make build-all | Generate code, format, and build |
make generate | Generate API clients from OpenAPI specs |
make test | Run all tests |
make lint | Run linter checks |
make format | Format code with goimports and gci |
make clean | Remove generated files and artifacts |
make tools | Install required development tools |
Code Generation
The CLI uses code generation for API clients:Testing
Writing Tests
- Place tests in
*_test.gofiles next to the code they test - Use table-driven tests for multiple test cases
- Mock external dependencies (API calls, file system)
Running Tests
Documentation
Code Documentation
- Add godoc comments for all exported functions, types, and packages
- Use complete sentences starting with the item name
User Documentation
When adding new features:- Update command help text (
ShortandLongdescriptions) - Add examples to command documentation
- Update relevant guides in the docs site
- Add FAQ entries if the feature addresses common questions
Pull Request Process
Ensure your PR is ready
Before submitting:
- All tests pass (
make test) - Linter passes (
make lint) - Code is formatted (
make format) - Commits follow message guidelines
- Documentation is updated
Create the pull request
- Provide a clear title and description
- Reference any related issues
- Describe what changed and why
- Include testing steps if applicable
Code review
- Address reviewer feedback
- Keep the PR up to date with main branch
- Be responsive to questions
PR Template
Reporting Bugs
Found a bug? Help us fix it:Check existing issues
Search GitHub Issues to see if it’s already reported.
Gather information
Collect:
- CLI version
- Operating system and architecture
- Full command that caused the issue
- Complete error message
- Logs (use
--log-fileflag)
Create a detailed issue
Include:
- Clear title: “artifact push fails with connection timeout”
- Description: What you were trying to do
- Steps to reproduce: Exact commands to reproduce
- Expected behavior: What should happen
- Actual behavior: What actually happens
- Environment: OS, version, etc.
- Logs: Relevant log output (redact sensitive data)
Feature Requests
Have an idea for a new feature?- Check if it’s already requested in GitHub Issues
- Create a new issue with the “enhancement” label
- Describe:
- The problem you’re trying to solve
- Your proposed solution
- Any alternative approaches considered
- How it benefits other users
Community
- GitHub Discussions: Ask questions and share ideas
- Issues: Report bugs and request features
- Pull Requests: Contribute code and documentation
License
By contributing, you agree that your contributions will be licensed under the MIT License.Questions?
If you have questions about contributing:FAQ
Check frequently asked questions
GitHub Issues
Ask in GitHub discussions
Troubleshooting
Common development issues
Documentation
Browse full documentation