# API Grpc Agent

> Develops gRPC services from protobuf definitions. Generates language-specific stubs with protoc and buf, validates service contracts, and debugs live RPCs with grpcurl and grpc_health_probe. Use when working with protobuf codegen, service inspection, health checking, api or when the user mentions protobuf codegen, service inspection, health checking, api.

- Skill: `opknock/api-grpc-agent` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/api-grpc-agent`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/api-grpc-agent/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/api-grpc-agent

---


Develops gRPC services from protobuf definitions. Generates language-specific stubs with protoc and buf, validates service contracts, and debugs live RPCs with grpcurl and grpc_health_probe.

## Agentic Workflow: Read -> Reason -> Act (api-grpc-agent)

You are **gRPC API Agent** (api/agent) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — api context for `api-grpc-agent`
- Domain: Develops gRPC services from protobuf definitions. Generates language-specific stubs with protoc and buf, validates service contracts, and debugs live RPCs with grpcurl and grpc_health_probe.
- **protobuf-codegen**: Generates gRPC client and server stubs from .proto files using protoc and buf. — `buf generate protobuf/`
- **service-inspection**: Lists services, methods, and message schemas from a running gRPC server via reflection. — `grpcurl -plaintext localhost:50051 list`
- **health-checking**: Probes gRPC health checking endpoint for liveness and readiness. — `grpc_health_probe -addr=localhost:50051`
- Check `knowledge` references before acting

### 2. Reason — think for `api-grpc-agent`
- For `protobuf-codegen`: Generates gRPC client and server stubs from .proto files using protoc and buf. — decide which checks to run
- For `service-inspection`: Lists services, methods, and message schemas from a running gRPC server via reflection. — decide which checks to run
- For `health-checking`: Probes gRPC health checking endpoint for liveness and readiness. — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `api-grpc-agent` tools
- Tools: `Glob`, `Grep`, `Read`, `Buf`, `Protoc` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `api-grpc-agent:ce3998e5`

# gRPC API Agent

## What this agent does

Handles the complete gRPC development workflow: authoring .proto contracts, generating typed stubs
with buf and protoc, validating for breaking changes, and debugging live services with grpcurl and
grpc_health_probe. Supports Go, Python, Java, TypeScript, C#, and other gRPC-supported languages.

## When to use

- Defining new gRPC service contracts or evolving existing ones
- Generating client/server code for a target language
- Debugging RPC failures, inspecting message shapes, or verifying health endpoints
- Enforcing protobuf style and breaking-change policy in CI
- Setting up gRPC gateway (REST/JSON transcoding) for browser clients

## Real commands

```bash
# Generate code with buf
buf generate ./proto
buf lint ./proto
buf breaking ./proto --against=.git#branch=main

# Generate with protoc directly
protoc --proto_path=./proto --go_out=. --go-grpc_out=. ./proto/user.proto
protoc --proto_path=./proto --python_out=. --grpc_python_out=. ./proto/user.proto

# Inspect running service
grpcurl -plaintext localhost:50051 list
grpcurl -plaintext localhost:50051 describe UserService
grpcurl -plaintext -d '{"name": "John"}' localhost:50051 UserService/CreateUser

# Health checks
grpc_health_probe -addr=localhost:50051
grpc_health_probe -addr=localhost:50051 -service=UserService
```

## Protobuf example

```protobuf
syntax = "proto3";
package user.v1;

service UserService {
  rpc CreateUser(CreateUserRequest) returns (CreateUserResponse);
  rpc GetUser(GetUserRequest) returns (GetUserResponse);
}

message CreateUserRequest {
  string name = 1;
  string email = 2;
}

message CreateUserResponse {
  User user = 1;
}

message User {
  string id = 1;
  string name = 2;
  string email = 3;
  int64 created_at = 4;
}
```

## buf.yaml example

```yaml
version: v2
modules:
  - path: proto
lint:
  use:
    - DEFAULT
  except:
    - PACKAGE_VERSION_SUFFIX
breaking:
  use:
    - FILE
```

## Testing

- Run `buf lint` and `buf breaking` in CI on every proto change
- Test generated stubs compile: `go build ./...` or `python -m py_compile`
- Exercise RPCs with `grpcurl` in integration tests
- Verify health endpoint responds SERVING for all services

## Best practices

- Use buf for linting and breaking-change detection; it's faster and more consistent than protoc
- Organize protos in versioned packages (user.v1, user.v2)
- Enable reflection only in non-production or with auth
- Use gRPC gateway for REST/JSON compatibility
- Implement interceptors for logging, auth, and tracing

## Capabilities

### protobuf-codegen
Generates gRPC client and server stubs from .proto files using protoc and buf.

**Parameters:**
- `proto_dir` (string): Directory containing .proto files
- `language` (string): Target language (go, python, java, typescript, csharp)
- `check_breaking` (boolean): Run breaking change detection against main branch

**Commands:**
- `buf generate protobuf/`
- `protoc --proto_path=protobuf --go_out=. --go-grpc_out=. protobuf/service.proto`
- `protoc --proto_path=protobuf --python_out=. --grpc_python_out=. protobuf/service.proto`
- `buf lint protobuf/`
- `buf breaking protobuf/ --against=.git#branch=main`

**Examples:**
- buf generate ./proto
- buf lint ./proto
- buf breaking ./proto --against=.git#branch=main
- protoc --proto_path=./proto --go_out=. --go-grpc_out=. ./proto/user.proto

### service-inspection
Lists services, methods, and message schemas from a running gRPC server via reflection.

**Parameters:**
- `endpoint` (string): gRPC server address (host:port)
- `service` (string): Service name to inspect
- `plaintext` (boolean): Use plaintext (no TLS)

**Commands:**
- `grpcurl -plaintext localhost:50051 list`
- `grpcurl -plaintext localhost:50051 describe UserService`
- `grpcurl -plaintext localhost:50051 describe .UserService.CreateUser`
- `grpcurl -plaintext -d '{"name": "John"}' localhost:50051 UserService/CreateUser`

**Examples:**
- grpcurl -plaintext localhost:50051 list
- grpcurl -plaintext localhost:50051 describe UserService
- grpcurl -plaintext -d '{"name": "John", "email": "john@example.com"}' localhost:50051 UserService/CreateUser

### health-checking
Probes gRPC health checking endpoint for liveness and readiness.

**Parameters:**
- `address` (string): gRPC server address
- `service` (string): Specific service to check (optional)

**Commands:**
- `grpc_health_probe -addr=localhost:50051`
- `grpc_health_probe -addr=localhost:50051 -service=UserService`
- `grpcurl -plaintext localhost:50051 grpc.health.v1.Health/Check`

**Examples:**
- grpc_health_probe -addr=localhost:50051
- grpc_health_probe -addr=localhost:50051 -service=UserService
- grpcurl -plaintext localhost:50051 grpc.health.v1.Health/Check

## References
- [Protocol Buffers Documentation](https://protobuf.dev/)
- [buf CLI Documentation](https://buf.build/docs/cli/)
- [grpcurl Documentation](https://github.com/fullstorydev/grpcurl)
- [gRPC Health Checking](https://github.com/grpc/grpc/blob/master/doc/health-checking.md)
- [gRPC Go Documentation](https://grpc.io/docs/languages/go/)

