Thank you for your interest in contributing! This guide will help you set up your development environment and understand the project structure.
- Go 1.24 or later
- Git
- Make
- Fork and clone the repository:
git clone https://github.com/heiko-braun/draft.git
cd draft- Install dependencies:
go mod download- Install git hooks (recommended):
make install-hooksThis installs a pre-commit hook that automatically checks your code before each commit.
# Build the draft binary
make build
# The binary will be in bin/draft
./bin/draft --versionmake testBefore committing, ensure your code passes these checks:
# Format your code
make fmt
# Run static analysis
make vetWe use git hooks to maintain code quality. When you run make install-hooks, a pre-commit hook is installed that automatically:
- Checks code formatting - Ensures all Go code follows standard formatting
- Validates dependencies - Runs
go mod tidyand checks for changes - Runs static analysis - Executes
go veton changed packages only
The hook (scripts/pre-commit):
- Stashes unstaged changes before running checks
- Only checks packages that have changed (for efficiency)
- Restores your working directory state after running
- Prevents commits if any check fails
If you need to commit without running the hook (not recommended):
git commit --no-verifyThe project includes several helpful Make targets:
| Target | Description |
|---|---|
make build |
Build the draft binary to bin/draft |
make install |
Install draft to $GOPATH/bin |
make test |
Run all tests |
make fmt |
Format all Go code with go fmt |
make vet |
Run go vet static analysis |
make install-hooks |
Install git pre-commit hooks |
make clean |
Remove build artifacts |
make run ARGS="init" |
Run the CLI with arguments (for development) |
The build process injects version information at compile time using ldflags:
- VERSION: Git tag or "dev" (from
git describe) - COMMIT: Short commit hash
- DATE: Build timestamp (UTC)
These are accessible via the --version flag:
./bin/draft --version
# Output: draft version v1.0.0 (commit: abc123, built: 2024-01-25T10:00:00Z)Releases are automated using GoReleaser and GitHub Actions.
- Tag a new version:
git tag -a v1.0.0 -m "Release v1.0.0"
git push origin v1.0.0- GitHub Actions automatically:
- Builds binaries for macOS (amd64 and arm64)
- Generates checksums
- Creates a GitHub release with binaries attached
- Generates release notes from commits
The release process is configured in:
.goreleaser.yaml- GoReleaser configuration.github/workflows/release.yml- GitHub Actions workflow
Pull requests are automatically verified by GitHub Actions (.github/workflows/pr-verify.yml):
- ✅ Code formatting check
- ✅ Static analysis (
go vet) - ✅ Build verification
- ✅ Test execution
All checks must pass before a PR can be merged.
.
├── .claude/ # Spec-driven development commands
│ ├── commands/ # Slash commands (plan, spec, implement, refine)
│ └── specs/ # Feature specifications
├── .github/
│ └── workflows/ # CI/CD workflows
│ ├── pr-verify.yml # PR verification checks
│ └── release.yml # Release automation
├── cmd/
│ └── draft/ # CLI entry point
│ ├── main.go
│ └── templates/.claude/ # Embedded template files
├── internal/
│ ├── cli/ # CLI commands (init, version, root)
│ └── templates/ # Template loader implementations
│ ├── loader.go # Loader interface
│ ├── local.go # Local filesystem loader
│ ├── github.go # GitHub releases loader
│ └── embedded.go # Embedded templates loader
├── scripts/
│ ├── pre-commit # Pre-commit hook script
│ └── install-git-hooks.sh # Hook installation script
├── .goreleaser.yaml # GoReleaser configuration
├── Makefile # Build automation
├── go.mod # Go module definition
└── README.md # Project documentation
- Write clear, descriptive commit messages
- Use conventional commit format when possible (e.g.,
feat:,fix:,docs:) - Keep commits focused on a single change
- Reference issues/PRs when relevant
<type>: <short description>
<longer description if needed>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Common types:
feat: New featurefix: Bug fixdocs: Documentation changesrefactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
- Create a feature branch from
main - Make your changes and ensure all checks pass
- Push to your fork and create a pull request
- Address review feedback if any
- Wait for CI checks to pass
- Merge once approved
The CLI supports multiple template sources for testing:
# Use local templates
DRAFT_TEMPLATES=/path/to/templates ./bin/draft init
# Use specific GitHub release version
./bin/draft init --version v1.0.0
# Normal use (latest release or embedded fallback)
./bin/draft init- Issues: Report bugs or request features via GitHub Issues
- Discussions: Ask questions in GitHub Discussions
By contributing, you agree that your contributions will be licensed under the same license as the project.