diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..dfab309 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +repos: + # Go formatting and imports + - repo: https://github.com/dnephin/pre-commit-golang + rev: v0.5.1 + hooks: + # Format Go code with gofmt + - id: go-fmt + # Organize Go imports + - id: go-imports + # Run go mod tidy + - id: go-mod-tidy + # Run go vet + - id: go-vet-mod + # Build the project to catch compilation errors + - id: go-build-mod + + # General hooks for all files + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + # Remove trailing whitespace + - id: trailing-whitespace + # Ensure files end with newline + - id: end-of-file-fixer + # Check YAML files are valid + - id: check-yaml + # Check JSON files are valid + - id: check-json + # Check for merge conflict markers + - id: check-merge-conflict + # Prevent committing large files + - id: check-added-large-files + args: ['--maxkb=1000'] \ No newline at end of file diff --git a/README.md b/README.md index b70aa83..e11d568 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,42 @@ sudo mv cwt /usr/local/bin/ 3. **State Tracking**: CWT monitors session status and git changes 4. **TUI Interface**: Real-time dashboard built with terminal UI components +## Development + +### Setting Up Pre-commit Hooks + +This project uses pre-commit hooks to catch linting and formatting issues before they reach CI: + +```bash +# Install pre-commit (one-time setup) +pip install pre-commit + +# Install the git hook scripts +pre-commit install + +# (Optional) Run hooks on all files +pre-commit run --all-files +``` + +### Available Make Targets + +```bash +make help # Show available targets +make test # Run tests +make build # Build binary +make lint # Run basic linting +make clean # Clean build artifacts +``` + +### Pre-commit Hooks + +The pre-commit configuration includes: +- **gofmt**: Code formatting +- **goimports**: Import organization +- **go mod tidy**: Dependency management +- **go vet**: Basic linting +- **General checks**: trailing whitespace, file endings, YAML/JSON validation + ## Contributing See [workflows.md](workflows.md) for detailed workflow documentation.