Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
# Pre-commit hook: block the commit if any staged Go file is not gofmt-clean.
#
# Enable once per clone:
# git config core.hooksPath .githooks
#
# This mirrors the CI gofmt check so formatting failures surface locally
# instead of after a push. It only inspects staged Go files, so it stays fast.

# Added/Copied/Modified staged .go files (skip deletions).
gofiles=$(git diff --cached --name-only --diff-filter=ACM -- '*.go')
[ -z "$gofiles" ] && exit 0

unformatted=$(gofmt -l $gofiles)
if [ -n "$unformatted" ]; then
echo "gofmt: these staged files are not formatted:" >&2
echo "$unformatted" | sed 's/^/ /' >&2
echo "" >&2
echo "Fix with: gofmt -w $unformatted" >&2
exit 1
fi
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ Full instructions:
| `internal/proc` | Cross-platform helper that hides child-process console windows on Windows |
| `internal/version` | Version resolution from `-ldflags` override or embedded VCS info |
| `skills/` | `/distill` and `/distill-apply` Claude Code skills |
| `.githooks/` | Shared git hooks (pre-commit gofmt check) |

## Development

The repo ships a pre-commit hook that runs the same `gofmt` check as CI, so
formatting problems surface locally instead of after a push. Enable it once per
clone:

```sh
git config core.hooksPath .githooks
```

It only inspects staged `.go` files and blocks the commit if any are not
gofmt-clean, printing the `gofmt -w …` command to fix them. (`go vet` and the
test suite stay in CI, which runs them across Linux/macOS/Windows.)

## Releasing

Expand Down
Loading