Claude Skills Guide

Claude Code for grpcurl gRPC Testing Workflow

gRPC services require thorough testing to ensure reliable communication between microservices. While traditional REST APIs have mature testing tools, gRPC testing demands specialized approaches. This guide demonstrates how to combine Claude Code with grpcurl to create efficient, reproducible gRPC testing workflows that integrate smoothly into your development process.

Understanding grpcurl Basics

grpcurl is a command-line tool that lets you interact with gRPC servers using a curl-like interface. Unlike standard HTTP clients, grpcurl understands Protocol Buffers (protobufs) and can invoke gRPC methods directly. Before integrating with Claude Code, ensure grpcurl is installed on your system:

# Install grpcurl
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest

# Verify installation
grpcurl --version

The tool requires either a proto file or reflection to discover available gRPC services. Reflection is the easier approach for development and testing.

Setting Up Claude Code for gRPC Testing

Claude Code can orchestrate complex grpcurl commands, handle response validation, and maintain testing context across multiple requests. Create a skill that encapsulates your gRPC testing patterns:

---
name: grpc-test
description: "Execute gRPC test calls with grpcurl"
---

With this foundation, Claude Code can execute gRPC calls and analyze responses intelligently.

## Basic gRPC Testing Patterns

### Service Reflection Testing

When testing against a gRPC server with reflection enabled, you can list available services and methods:

```bash
# List all services
grpcurl localhost:50051 list

# List methods for a specific service
grpcurl localhost:50051 list mypackage.UserService

Claude Code can parse these listings and help you discover which methods need testing. This is particularly valuable when working with unfamiliar services.

Making Unary Calls

Unary gRPC calls (request-response) work similarly to REST endpoints:

grpcurl -d '{"user_id": "123"}' localhost:50051 mypackage.UserService/GetUser

For more complex payloads, store the JSON in a file:

grpcurl -d @ localhost:50051 mypackage.UserService/CreateUser < payload.json

Handling Streaming Endpoints

gRPC supports server streaming, client streaming, and bidirectional streaming. Testing these requires additional flags:

# Server streaming
grpcurl -d '{"user_ids": ["1","2","3"]}' localhost:50051 mypackage.UserService/ListUsers

# Server streaming with timeout
grpcurl -d '{"user_id": "123"}' -max-time 30 localhost:50051 mypackage.UserService/WatchUser

Claude Code can manage streaming tests by running grpcurl in the background and collecting responses over time.

Advanced Testing Workflows

Request/Response Validation

Create a robust testing workflow that validates responses:

#!/bin/bash
# grpc-test.sh - Test wrapper with validation

HOST=$1
METHOD=$2
PAYLOAD=$3
EXPECTED_FIELD=$4

response=$(grpcurl -d "$PAYLOAD" $HOST $METHOD)
echo "$response"

# Extract and validate field
actual_value=$(echo "$response" | jq -r "$EXPECTED_FIELD")
if [ "$actual_value" = "null" ]; then
  echo "ERROR: Expected field not found"
  exit 1
fi

Metadata and Authentication

Many gRPC services require authentication via metadata:

# With authorization header
grpcurl -H "authorization: Bearer $TOKEN" \
  -d '{"query": "test"}' \
  localhost:50051 mypackage.QueryService/Execute

# With custom metadata
grpcurl -H "x-request-id: test-123" \
  -d '{"data": "test"}' \
  localhost:50051 mypackage.DataService/Submit

Claude Code can manage tokens and securely inject authentication headers into your test commands.

Testing Error Scenarios

gRPC uses rich error codes that you should test explicitly:

# Test not found error
grpcurl -d '{"user_id": "999"}' localhost:50051 mypackage.UserService/GetUser 2>&1

# Test with invalid data
grpcurl -d '{}' localhost:50051 mypackage.UserService/CreateUser 2>&1

Capture the exit code and error message to validate your error handling:

grpcurl -d '{"invalid": "data"}' localhost:50051 mypackage.UserService/GetUser
exit_code=$?

if [ $exit_code -ne 0 ]; then
  echo "Error handling works correctly"
fi

Building Test Suites with Claude Code

Automating Test Scenarios

Claude Code can maintain a comprehensive test suite that runs across your development workflow:

  1. Define test cases: Store proto requests in JSON files organized by service
  2. Execute systematically: Loop through test cases and capture results
  3. Validate responses: Compare actual vs expected responses
  4. Report results: Generate test summaries with Claude Code analysis

Continuous Integration Integration

Incorporate grpcurl tests into your CI pipeline:

#!/bin/bash
# ci-grpc-test.sh - CI-compatible test runner

set -e

HOST=${GRPC_HOST:-localhost:50051}
FAILED=0

test_endpoint() {
  local method=$1
  local payload=$2
  local expected=$3
  
  if grpcurl -d "$payload" $HOST $method | jq -e "$expected" > /dev/null 2>&1; then
    echo "✓ $method"
  else
    echo "✗ $method"
    FAILED=1
  fi
}

# Run test cases
test_endpoint 'mypackage.UserService/GetUser' '{"user_id":"1"}' '.user_id == "1"'
test_endpoint 'mypackage.UserService/ListUsers' '{}' '.users | length > 0'

exit $FAILED

Debugging gRPC Issues

When gRPC services behave unexpectedly, use Claude Code with grpcurl to diagnose problems:

  1. Check server reflection: Ensure the service supports reflection
  2. Verify proto definitions: Compare actual vs expected message structures
  3. Inspect metadata: Examine headers and authentication
  4. Test connectivity: Verify network paths and TLS configuration
# Enable verbose output
grpcurl -v -d '{}' localhost:50051 mypackage.HealthService/Check

# Test with TLS
grpcurl -cacert cert.pem -d '{}' \
  localhost:50051 mypackage.HealthService/Check

Best Practices

By combining Claude Code’s reasoning capabilities with grpcurl’s gRPC expertise, you can build robust testing workflows that catch issues early and provide confidence in your gRPC services.

Built by theluckystrike — More at zovo.one