Thank you for your interest in contributing to this project! This document provides guidelines and instructions for contributing.
By participating in this project, you agree to be respectful and constructive in all interactions.
Before creating an issue, please:
- Check existing issues to avoid duplicates
- Use the issue templates when available
- Include as much relevant information as possible
When reporting bugs, include:
- Your operating system and version
- Zig version (run
zig version) - Steps to reproduce the issue
- Expected vs actual behavior
- Any error messages or logs
Feature requests are welcome! Please:
- Check if the feature has already been requested
- Explain the use case and why it would be valuable
- Consider if it aligns with the project's goals
- Fork the repository and create your branch from
main - Follow the coding style used throughout the project
- Write tests for new functionality
- Update documentation as needed
- Ensure all tests pass by running
zig build test - Format your code with
clang-format - Write clear commit messages following conventional commits
We follow the Conventional Commits specification:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Test additions or modificationschore: Maintenance tasksperf: Performance improvements
Examples:
feat(cli): add new command for file processing
fix(config): handle missing config file gracefully
docs(readme): update installation instructions
-
Install Zig (master branch recommended):
# Using zvm (recommended) zvm install master zvm use master # Or download directly # Visit https://ziglang.org/download/
-
Clone your fork:
git clone https://github.com/yourusername/yourproject.git cd yourproject -
Install platform dependencies:
# macOS brew install ncurses # Ubuntu/Debian sudo apt-get install libncurses-dev clang-format clang-tidy # Fedora/RHEL sudo dnf install ncurses-devel clang-tools-extra # Windows (using vcpkg) git clone https://github.com/Microsoft/vcpkg.git cd vcpkg && bootstrap-vcpkg.bat vcpkg install pdcurses:x64-windows
-
Set up pre-commit hooks (recommended):
# Install pre-commit pip install pre-commit # Install Node.js for markdownlint # (varies by OS - use your preferred method) # Install the hooks pre-commit install
-
Alternative: Use Devcontainer (recommended for consistency):
This project includes a devcontainer configuration for VS Code that provides a consistent development environment.
- Install the Dev Containers extension for VS Code
- Open the project in VS Code
- When prompted, choose "Reopen in Container"
- The container will automatically install all dependencies
This project uses Zig as its build system. If you're new to Zig, see our Zig Primer for C Developers.
# Build the project (debug mode)
zig build
# Build with optimizations
zig build -Doptimize=ReleaseSafe
# Run the application
zig build run -- --help
# Run tests
zig build test
# Check code without building
zig build check
# Cross-compile for Windows (from Linux/macOS)
zig build -Dtarget=x86_64-windows
# Install to a custom prefix
zig build install --prefix ~/.local| Option | Description | Default |
|---|---|---|
-Doptimize= |
Build mode: Debug, ReleaseSafe, ReleaseFast, ReleaseSmall |
Debug |
-Dtarget= |
Target triple (e.g., x86_64-windows, aarch64-linux) |
Native |
-Denable-tui= |
Enable TUI support | true |
--prefix |
Installation directory | zig-out |
- Add your C file to the appropriate directory under
src/ - Update
build.zigto include the new file:exe.addCSourceFiles(.{ .files = &.{ // existing files... "src/your_module/new_file.c", }, .flags = &.{ "-std=c23", "-Wall", "-Wextra" }, });
- If adding a new module, update the architecture diagram in docs/ARCHITECTURE.md
Common Issues:
- "Unable to find ncurses": Install the development package for your OS (see step 3 above)
- "C header not found": Check that all include paths are added in
build.zig - Cache issues: Run
rm -rf zig-cache zig-outand rebuild - Windows DLL issues: Ensure vcpkg bin directory is in PATH
For more details, see the Architecture Overview.
# Run all tests
zig build test
# Run tests with different optimization levels
zig build test -Doptimize=Debug
zig build test -Doptimize=ReleaseSafe
zig build test -Doptimize=ReleaseFast- Write tests for new functionality in
test/directory - Ensure all existing tests pass
- Test on multiple platforms if possible
- Test error conditions and edge cases
- Update README.md for user-facing changes
- Add inline comments for complex logic
- Keep examples up to date
- Use 2 spaces for indentation
- Opening braces on same line for functions
- Use descriptive variable names
- Add comments for complex logic
- Keep functions focused and small
- Follow the .clang-format configuration
Example:
app_error process_input(const char* input, size_t len) {
// Validate input parameters
if (!input || len == 0) {
return APP_ERROR_INVALID_ARG;
}
// Process the input
app_buffer_t buffer = {0};
app_error err = process_data(input, len, &buffer);
if (err != APP_SUCCESS) {
app_secure_free(buffer.data, buffer.capacity);
return err;
}
// Clean up
app_secure_free(buffer.data, buffer.capacity);
return APP_SUCCESS;
}- Always check return values
- Provide meaningful error messages
- Clean up resources on error paths
- Use early returns for error conditions
- Free all allocated memory
- Use secure memory functions for sensitive data
- Check for allocation failures
- Avoid memory leaks in error paths
cli-starter/
├── src/ # Core implementation
│ ├── main.c # Entry point
│ ├── core/ # Core functionality
│ ├── cli/ # CLI interface
│ ├── io/ # Input/Output
│ └── utils/ # Utilities
├── test/ # Test suite
├── build.zig # Build configuration
└── build.zig.zon # Build dependencies
- Check the documentation
- Look through existing issues
- Ask questions in issues with the "question" label
By contributing to this project, you agree that your contributions will be licensed under the MIT License.