From 5293e94e21515d0a51f0cf0a252de574374445a2 Mon Sep 17 00:00:00 2001 From: Joakim Olsson Date: Fri, 9 Jan 2026 16:39:14 +0100 Subject: [PATCH] docs: add CLAUDE.md for Claude Code guidance --- CLAUDE.md | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..d0f6cfd --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,61 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +A Kubernetes monitoring tool that checks for CronJobs not running according to schedule and sends Slack notifications. It runs as a container inside a K8s cluster, polling all CronJobs every 60 seconds. + +## Common Commands + +```bash +# Run tests +go test ./... + +# Run tests with race detection and coverage +go test -race -coverprofile=coverage.txt ./... + +# Build the binary +CGO_ENABLED=0 go build -o release/cron-checker -ldflags '-w -s' + +# Check for vulnerabilities +govulncheck ./... + +# Format and vet +go fmt ./... +go vet ./... + +# Check for unused modules +go mod tidy +``` + +## Architecture + +This is a single-file Go application (`main.go`) with comprehensive tests (`main_test.go`). + +**Core Components:** +- `doCheck()` - Main loop that polls K8s CronJobs, parses cron schedules, and sends Slack alerts for overdue jobs +- `Client` / `ClientProvider` interfaces - Abstractions over K8s client for testability +- `ConfigProvider` / `InClusterProvider` - Handles K8s in-cluster authentication + +**Key Dependencies:** +- `k8s.io/client-go` - Kubernetes API client +- `github.com/robfig/cron` - Cron schedule parsing +- `github.com/multiplay/go-slack` - Slack webhook integration +- `github.com/alecthomas/kingpin/v2` - CLI flag parsing + +**Configuration:** +- `SLACK_URL` env var or `--slack-url` flag (required) - Slack webhook URL for notifications + +## Building Docker Image + +The Dockerfile performs a multi-stage build that runs fmt, vet, and tests before building: + +```bash +docker build -t cron-checker . +``` + +To extract coverage report: +```bash +docker build --target export -o . . +```