This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a multi-module Go monorepo that extends ent ORM with Protocol Buffers (protobuf) support. The repository provides three independent modules that work together to enable a protobuf-first development workflow.
| Module | Purpose |
|---|---|
entproto |
Generates .proto files from Ent schemas with auto-annotation support |
entconv |
Generates bidirectional converter functions between Ent entities and protobuf messages |
entcrud |
Generates CRUD operation code for Ent schemas |
# Run all lints across all modules
make lint-all
# Run tests (delegates to testdata)
make test
# Within individual modules:
cd entproto && go test ./...
cd entconv && go test ./...
cd entcrud && go test ./...- Works as an
entc.Extensionthat hooks into the Ent code generation pipeline - Generates
.protofiles based on Ent schema definitions - Key file:
entproto/extension.go- contains theExtensionstruct and generation hooks - Supports automatic annotation generation via
WithAutoFill()option - Uses
entproto.Message()andproto.Field()annotations to mark schemas/fields for generation
- Generates Go code that converts between Ent structs and protobuf structs
- Reads both Ent schema definitions and generated
.pb.gofiles - Key file:
entconv/entconv.go- contains theOptionsstruct andGenerateConverterfunction - Uses Go templates (see
entconv/internal/generator/template/converter.tmpl) for code generation
- Generates CRUD service implementations for Ent schemas
- Uses Go AST parsing and code generation
- Key files:
entcrud/bind.go,entcrud/internal/bind/func.go
- Integration test/example project demonstrating how all modules work together
- Contains Ent schemas, proto definitions, and generated code
- Can be used as a reference for proper module integration
entgo.io/ent- The Ent ORMgithub.com/jhump/protoreflect- Protocol buffer reflectiongoogle.golang.org/protobuf- Protobuf runtimegolang.org/x/tools- Go tools for code generation