Skip to content

Commit a3a65cb

Browse files
committed
Claude boilerplate (#52)
1 parent 0393d71 commit a3a65cb

File tree

3 files changed

+101
-40
lines changed

3 files changed

+101
-40
lines changed

.github/workflows/claude.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Claude Assistant
2+
on:
3+
issue_comment:
4+
types: [created]
5+
pull_request_review_comment:
6+
types: [created]
7+
pull_request:
8+
types: [opened, synchronize] # opened = new PR, synchronize = new commits pushed
9+
issues:
10+
types: [opened, assigned]
11+
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
issues: write
16+
id-token: write
17+
18+
jobs:
19+
# Interactive mode - responds to @claude mentions
20+
claude-response:
21+
if: github.event_name != 'pull_request'
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: anthropics/claude-code-action@v1
26+
with:
27+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
28+
claude_args: |
29+
--model opus
30+
31+
# Automation mode - auto-review new PRs
32+
claude-review:
33+
if: github.event_name == 'pull_request'
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: anthropics/claude-code-action@v1
38+
with:
39+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
40+
claude_args: |
41+
--model opus
42+
prompt: |
43+
Review this PR. Focus on:
44+
- Correctness and potential bugs
45+
- Code clarity and maintainability
46+
- Any security concerns
47+
48+
Be concise. Only comment if you have substantive feedback.

AGENTS.md

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,52 @@
1-
# Repository Guidelines
2-
3-
## Project Structure & Module Organization
4-
- Source layout: `cmd/cli` and `cmd/httpserver` are entrypoints; shared packages live in `common/`, `httpserver/`, `database/`, and `metrics/`.
5-
- Tests: co-located `*_test.go` files (e.g., `httpserver/handler_test.go`, `database/database_test.go`).
6-
- Artifacts: binaries output to `build/` via Makefile targets. Dockerfiles: `cli.dockerfile`, `httpserver.dockerfile`.
7-
- Go version: 1.24 (see `go.mod`). Module path: `github.com/flashbots/go-template`.
8-
9-
## Coding Style & Naming Conventions
10-
- Use tabs instead of spaces for indentation.
11-
- Always run `make fmt` and `make lint` (and `make test`) before committing.
12-
- Formatting: run `make fmt` before committing. Go files must pass `golangci-lint` (config in `.golangci.yaml`).
13-
- Style: idiomatic Go; exported identifiers use CamelCase; packages lower-case short names; errors returned, not panicked.
14-
- JSON tags: prefer snake_case (configured via `tagliatelle`).
15-
- Logging: use `common.SetupLogger` (slog) and structured fields; respect `--log-json` and `--log-debug` flags.
16-
17-
## Build, Test, and Development Commands
18-
- `make build`: builds CLI and HTTP server into `build/`.
19-
- `make build-cli` / `make build-httpserver`: build individual binaries.
20-
- `make lint`: run formatters and linters (`gofmt`, `gofumpt`, `go vet`, `staticcheck`, `golangci-lint`).
21-
- `make test` / `make test-race`: run tests (optionally with race detector).
22-
- `make fmt`: apply formatting (`gofmt`, `gci`, `gofumpt`) and `go mod tidy`.
23-
- `make cover` / `make cover-html`: coverage summary / HTML report.
24-
- Docker: `make docker-cli`, `make docker-httpserver` build images using the respective Dockerfiles.
25-
26-
## Testing Guidelines
27-
- Framework: standard `testing` with `testify/require` for assertions.
28-
- Run: `make test` (or `go test ./...`).
29-
- Database tests: gated by `RUN_DB_TESTS=1` and a Postgres instance. Example:
30-
- `docker run -d --name postgres-test -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres`
31-
- `RUN_DB_TESTS=1 make test`
32-
- Coverage: aim to keep or increase coverage; use `make cover`.
33-
34-
## Commit & Pull Request Guidelines
35-
- Commits: concise, imperative mood; scope prefixes like `ci:`, `docs:`, `fix:`, `feat:` when helpful. Reference issues/PRs.
36-
- PRs: include a clear description, linked issues, test plan (commands run), and any config notes. Ensure `make fmt lint test` pass locally.
37-
38-
## Security & Configuration Tips
39-
- Configuration: prefer flags/env via `common.GetEnv` and CLI options; avoid hardcoding secrets.
40-
- HTTP server: `/debug` (pprof) is opt-in; do not expose publicly. Metrics on `/metrics` (Prometheus format).
1+
This file provides guidance to LLMs when working with code in this repository.
2+
3+
## Build Commands
4+
5+
```bash
6+
make build-cli # Build CLI binary to ./build/cli
7+
make build-httpserver # Build HTTP server binary to ./build/httpserver
8+
make build # Build all binaries
9+
```
10+
11+
## Test Commands
12+
13+
```bash
14+
make test # Run all tests
15+
make test-race # Run tests with race detector
16+
go test ./... -run TestName # Run a single test
17+
18+
# Database tests require a running Postgres instance:
19+
docker run -d --name postgres-test -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres postgres
20+
RUN_DB_TESTS=1 make test
21+
```
22+
23+
## Lint and Format
24+
25+
```bash
26+
make lint # Run all linters (gofmt, gofumpt, go vet, staticcheck, golangci-lint)
27+
make fmt # Format code (gofmt, gci, gofumpt, go mod tidy)
28+
make lt # Run both lint and test
29+
```
30+
31+
## Architecture
32+
33+
This is a Go project template with two entry points:
34+
35+
- **cmd/cli/main.go** - CLI application entry point using urfave/cli
36+
- **cmd/httpserver/main.go** - HTTP server entry point with graceful shutdown
37+
38+
### Key Packages
39+
40+
- **httpserver/** - HTTP server with chi router, includes `/livez`, `/readyz`, `/drain`, `/undrain` endpoints, metrics middleware, and optional pprof
41+
- **database/** - Postgres database layer using sqlx with sql-migrate for migrations
42+
- **database/migrations/** - In-memory migrations registered in `Migrations` variable
43+
- **metrics/** - VictoriaMetrics-based Prometheus metrics with HTTP middleware
44+
- **common/** - Shared utilities including structured logging setup (slog-based via httplog)
45+
46+
### HTTP Server Pattern
47+
48+
The server runs two HTTP servers: main API (default :8080) and metrics (default :8090). Supports graceful shutdown with configurable drain duration for load balancer compatibility.
49+
50+
### Database Migrations
51+
52+
Migrations are defined as Go code in `database/migrations/` and registered in `migrations.Migrations`. They run automatically on database connection unless `DB_DONT_APPLY_SCHEMA` env var is set.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

0 commit comments

Comments
 (0)