Add linting documentation and pre-commit hooks (#177)

## Summary

This PR improves the developer experience by adding clear linting
documentation and optional pre-commit hooks to catch issues before CI.
Helpful to avoid fighting Claude Code / Copilot on "please make sure
linting passes CI".

## Changes

- Updated `README.md` with:
  - Go 1.23.x requirement (was "1.18 or later")
  - golangci-lint v1.61.0 in prerequisites
  - New Development section with linting instructions
  
- Updated `CLAUDE.md` with:
  - Development Setup section
  
- Added `.githooks/pre-commit`:
  - Runs golangci-lint and gofmt checks
  - References README for installation instructions
  - Can be bypassed with `--no-verify` when needed

## Test Plan

- [x] Verified pre-commit hook blocks commits when golangci-lint is
missing
- [x] Confirmed hook shows clear error message pointing to README
- [x] Tested that linting passes with Go 1.23.0 and golangci-lint
v1.61.0
- [x] Verified gofmt correctly identifies formatting issues

Co-authored w/ Claude Code

---------

Co-authored-by: Charles Lowell <10964656+chlowell@users.noreply.github.com>
This commit is contained in:
Tadas Antanavicius 2025-07-15 09:31:17 -07:00 • committed by GitHub
commit 4e221e49a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,10 +24,16 @@ The MCP Registry service provides a centralized repository for MCP server entrie
### Prerequisites
- Go 1.18 or later
- Go 1.23.x (required - check with `go version`)
- MongoDB
- Docker (optional, but recommended for development)
For development:
- golangci-lint v1.61.0 - Install with:
```bash
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
```
## Running
The easiest way to get the registry running is to use `docker compose`. This will setup the MCP Registry service, import the seed data and run MongoDB in a local Docker environment.
@ -54,6 +60,33 @@ This will create the `registry` binary in the current directory. You'll need to
By default, the service will run on `http://localhost:8080`.
## Development
### Linting
The project uses golangci-lint with extensive checks. Always run linting before pushing:
```bash
# Run all linters (same as CI)
golangci-lint run --timeout=5m
# Check formatting
gofmt -s -l .
# Fix formatting
gofmt -s -w .
```
### Git Hooks (Optional)
To automatically run linting before commits:
```bash
git config core.hooksPath .githooks
```
This will prevent commits that fail linting or have formatting issues.
## Project Structure
```