Skip to content

Commit 30848aa

Browse files
josephschorrclaude
andcommitted
fix(gen): skip claude invocation in proto Gen() when buf produces no changes
The meta gen-nodiff CI job runs mage gen:all and checks for drift. Each proto client's Gen() function unconditionally called claude after buf generate/export, which always failed in CI (claude binary not available). Add a git diff check immediately after buf generate/export: if the generated proto files have no changes, skip the claude boilerplate step and return nil. When proto API hasn't changed (the normal case for gen-nodiff), Gen() is now a clean no-op that does not require claude. Idiomatic client Gen() functions already have an equivalent guard (they diff against a stored baseline ref), so Gen().Client() was already safe. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f326d1e commit 30848aa

7 files changed

Lines changed: 44 additions & 1 deletion

File tree

proto-clients/spicedb-csharp-proto/Magefile.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ func Gen() error {
2121
return fmt.Errorf("buf generate failed: %w", err)
2222
}
2323

24+
diff, _ := sh.Output("git", "diff", "--name-only", ".")
25+
if strings.TrimSpace(diff) == "" {
26+
fmt.Println("==> No proto changes detected after buf generate, skipping Claude step.")
27+
return nil
28+
}
29+
2430
fmt.Println("==> Invoking Claude to add boilerplate...")
2531
if err := runClaude(
2632
"Read DESIGN.md. Review the generated code under gen/. " +

proto-clients/spicedb-go-proto/Magefile.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@ import (
1414
const maxRetries = 3
1515

1616
// Gen regenerates the proto client: runs buf generate, then invokes Claude
17-
// to add boilerplate per DESIGN.md.
17+
// to add boilerplate per DESIGN.md. If buf generate produces no changes,
18+
// the Claude step is skipped (so gen-nodiff CI passes without claude).
1819
func Gen() error {
1920
fmt.Println("==> Running buf generate...")
2021
if err := sh.Run("buf", "generate"); err != nil {
2122
return fmt.Errorf("buf generate failed: %w", err)
2223
}
2324

25+
diff, _ := sh.Output("git", "diff", "--name-only", ".")
26+
if strings.TrimSpace(diff) == "" {
27+
fmt.Println("==> No proto changes detected after buf generate, skipping Claude step.")
28+
return nil
29+
}
30+
2431
fmt.Println("==> Invoking Claude to add boilerplate...")
2532
if err := runClaude(
2633
"Read DESIGN.md. Review the generated code under gen/. " +

proto-clients/spicedb-java-proto/Magefile.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ func Gen() error {
2121
return fmt.Errorf("buf generate failed: %w", err)
2222
}
2323

24+
diff, _ := sh.Output("git", "diff", "--name-only", ".")
25+
if strings.TrimSpace(diff) == "" {
26+
fmt.Println("==> No proto changes detected after buf generate, skipping Claude step.")
27+
return nil
28+
}
29+
2430
fmt.Println("==> Invoking Claude to add boilerplate...")
2531
if err := runClaude(
2632
"Read DESIGN.md. Review the generated code under gen/. " +

proto-clients/spicedb-python-proto/Magefile.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ func Gen() error {
2020
return fmt.Errorf("buf generate failed: %w", err)
2121
}
2222

23+
diff, _ := sh.Output("git", "diff", "--name-only", ".")
24+
if strings.TrimSpace(diff) == "" {
25+
fmt.Println("==> No proto changes detected after buf generate, skipping Claude step.")
26+
return nil
27+
}
28+
2329
fmt.Println("==> Syncing Python deps...")
2430
if err := sh.RunV("uv", "sync"); err != nil {
2531
return fmt.Errorf("uv sync failed: %w", err)

proto-clients/spicedb-ruby-proto/Magefile.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ func Gen() error {
2121
return fmt.Errorf("buf generate failed: %w", err)
2222
}
2323

24+
diff, _ := sh.Output("git", "diff", "--name-only", ".")
25+
if strings.TrimSpace(diff) == "" {
26+
fmt.Println("==> No proto changes detected after buf generate, skipping Claude step.")
27+
return nil
28+
}
29+
2430
fmt.Println("==> Installing Ruby dependencies...")
2531
if err := sh.Run("bundle", "install"); err != nil {
2632
return fmt.Errorf("bundle install failed: %w", err)

proto-clients/spicedb-rust-proto/Magefile.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ func Gen() error {
2020
return fmt.Errorf("buf export failed: %w", err)
2121
}
2222

23+
diff, _ := sh.Output("git", "diff", "--name-only", "proto")
24+
if strings.TrimSpace(diff) == "" {
25+
fmt.Println("==> No proto changes detected after buf export, skipping Claude step.")
26+
return nil
27+
}
28+
2329
fmt.Println("==> Invoking Claude to wire up generated code...")
2430
if err := runClaude(
2531
"Read DESIGN.md. The proto/ directory has been populated by buf export. " +

proto-clients/spicedb-typescript-proto/Magefile.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ func Gen() error {
2020
return fmt.Errorf("buf generate failed: %w", err)
2121
}
2222

23+
diff, _ := sh.Output("git", "diff", "--name-only", ".")
24+
if strings.TrimSpace(diff) == "" {
25+
fmt.Println("==> No proto changes detected after buf generate, skipping Claude step.")
26+
return nil
27+
}
28+
2329
fmt.Println("==> Installing deps...")
2430
if err := sh.RunV("pnpm", "install"); err != nil {
2531
return fmt.Errorf("pnpm install failed: %w", err)

0 commit comments

Comments
 (0)