Kafka Schema Registry Skill
Scan a project to identify Kafka applications, extract schemas, generate Terraform for Schema Registry registration, and produce a comprehensive analysis report.
When to Use
Invoke this skill when:
- A user asks to analyze a project for Kafka usage in order to add event schemas or integrate Schema Registry
- A user wants to extract schemas from Kafka producers
- A user wants Terraform to register schemas to Schema Registry
- A user wants to audit Kafka producer/consumer configurations
Deliverables
This skill produces 3 outputs in the target project:
schema-report.md — Full analysis report with findings, risks, and upgrade recommendations
schemas/ — Extracted schema files (Avro, JSON Schema, Protobuf) with PII tagging
terraform/ — Terraform configs using Confluent provider to register schemas
Optional: Code Migration Assistance
If the user asks for their application code to be updated to integrate Schema Registry, use the Code Migration Reference to update the code with proper Schema Registry integration patterns.
High-Level Workflow
Phase 0: Initialize
- Check for existing
schema.yaml and schemas/ directory manually
- Note any existing schema infrastructure in the report
Phase 1: Project Scan & Kafka Detection
- Find build files — Search for
pom.xml, build.gradle, requirements.txt, package.json, etc.
- Detect Kafka dependencies — Look for
spring-kafka, confluent-kafka, kafkajs, etc.
- Find producers & consumers — Grep for
KafkaTemplate, Producer(, producer.send, etc.
- Extract topic names — From string literals, config properties, YAML files
- Identify serializers — Find
value.serializer, KafkaAvroSerializer, custom serializers
- Build app catalog — Compile findings: app name, language, role, topics, serializer, category
Detailed patterns: Detection Patterns Reference
App catalog structure:
app_name: module name
language: Java | Python | .NET | Go | Node/TS
role: producer | consumer | both
topics: [list of topics]
serializer_class: value.serializer used
custom_serializer: true | false
schema_format: AVRO | JSON | PROTOBUF | UNKNOWN
sr_integrated: true | false
category: A | B | C | D | E # REQUIRED
Multi-schema topic detection:
- If multiple data models produce to the same topic, create a wrapper schema with
oneOf/union/oneof
- Generate Terraform with
schema_reference blocks
- Flag prominently in report
Phase 2: Risk Detection
Search for:
auto.register.schemas=true — Uncontrolled schema evolution (Category C)
use.latest.version — Eases migration when set
- Custom serializers — Bypass SR entirely (Category E)
Record file path, line number, and affected topics for each occurrence.
Patterns: Detection Patterns Reference
Phase 3: Schema Inference
For each producer:
- Check for existing schema files —
**/*.avsc, **/*.proto, **/*.schema.json
- Infer from data models — Java classes, Pydantic models, TypeScript interfaces, Go structs
- Infer from inline data — HashMap, dict literals, map[string]any, plain objects, JSON strings
- Convert to schemas — Map language types to JSON Schema / Avro / Protobuf
- Tag PII fields — Scan field names for
email, ssn, phone, address, etc.
PII tagging: Add confluent:tags (PII, PRIVATE, SENSITIVE, PHI) to detected fields.
Detailed inference patterns: Schema Inference Reference
Phase 4: Categorize Producers
Classify each producer:
| Category |
Criteria |
| A: Compliant |
Confluent serializer + SR + no auto.register |
| A→Header |
Already on SR, migrating to headers |
| B: Schema in code, no SR |
Data models exist, but no SR integration |
| C: Auto-register |
auto.register.schemas=true |
| D: No schema |
Raw strings/bytes, no data model |
| E: Custom serializer |
Custom Serializer<T> or inline serialization without SR |
CRITICAL: Use exact phrase "Category X" in:
- App catalog field
- Applications Discovered table
- Report section headers
- Terraform comments
- Risk sections
Details: Categorization Reference
Phase 5: Create Schema Files
Directory structure:
schemas/
├── avro/
│ └── {topic}-value.avsc
├── json/
│ └── {topic}-value.json
└── proto/
└── {topic}-value.proto
File naming: MUST use kebab-case (lowercase with hyphens):
- Value:
{topic}-value.{ext}
- Key:
{topic}-key.{ext}
- Examples:
order-events-value.avsc, user-notifications-value.json
Initialize: Create schema.yaml.
Validate: Call schema_lint(path: schemas/, fix: true) if available.
Phase 6: Generate Terraform
File structure (MANDATORY separate files):
terraform/
├── providers.tf # Provider config
├── variables.tf # Variable definitions
├── tags.tf # confluent_tag resources (if PII exists)
├── schemas.tf # Active schemas (A, B, E)
├── flagged-auto-register.tf # Category C only (commented out)
├── outputs.tf # Output values
└── import.sh # Import script
CRITICAL:
schemas.tf = Categories A, B, E — NOT commented out
flagged-auto-register.tf = Category C ONLY — MUST be commented out
tags.tf = MUST exist if ANY schema uses confluent:tags
- Each schema resource MUST have comment block: Topic, App, Source, Category
Templates: Terraform Templates Reference
Phase 7: Generate Report
Create schema-report.md with:
- Executive Summary (metrics + category breakdown)
- Applications Discovered table (EXACT format, Category column MANDATORY)
- RISKS (auto-register, custom serializers)
- Producer Upgrade Recommendations (per app, with "Category X" in heading)
- Migration Rollout Ordering (by category)
- PII Fields Detected
- Terraform Resources Generated
- Next Steps checklist
CRITICAL formatting requirements:
- Applications Discovered = markdown table, NOT narrative sections
- Every app section MUST say "Category X" explicitly
- Terraform comment blocks required for every resource
Template: Report Template Reference
Migration Rollout by Category
- Category B (JSON, no SR): Producers first → consumers
- Category A→Header (already on SR): Verify consumer versions → producers only
- Category C (auto-register): Register via Terraform → disable auto-register → producers fetch latest
- Category E (custom serializers): Consumers first (composite deserializer) → producers
Details: Categorization Reference
Edge Cases
- Monorepos: Treat each service/module with Kafka deps as separate app
- Multi-topic producers: Generate one schema resource per topic
- Shared schemas: One schema file, multiple Terraform resources reference it
- No topic names: If loaded from env vars, use placeholders with TODO
- Test code: Skip test directories unless they contain only schema definitions
- Multiple serializers: Create separate schema files per format
Output Organization
{project_root}/
├── schema-report.md # Analysis report
├── schemas/
│ ├── schema.yaml # Schema project config
│ ├── avro/
│ │ └── {topic}-value.avsc
│ ├── json/
│ │ └── {topic}-value.json
│ └── proto/
│ └── {topic}-value.proto
└── terraform/
├── providers.tf
├── variables.tf
├── tags.tf # PII/PRIVATE/SENSITIVE tags
├── schemas.tf # Active schemas (depends_on tags)
├── flagged-auto-register.tf # Commented-out Category C
├── outputs.tf
└── import.sh # Import existing schemas
Reference Documentation
- Detection Patterns — Patterns for finding Kafka apps, dependencies, producers, consumers, serializers
- Schema Inference — Extract schemas from data models, inline data, PII tagging
- Categorization — Category definitions, rollout order, client version requirements
- Terraform Templates — File structure, templates, naming conventions
- Report Template — Required sections, formatting rules, validation checklist
- Code Migration — Serializer/deserializer implementation patterns for Python, Java, JavaScript, Go, and .NET
Execution Approach
- Use Glob to find build files and schema files
- Use Grep for pattern detection (dependencies, producers, serializers, risks)
- Use Read to inspect source files and data models
- Use Write to create schema files, Terraform configs, and report
No need to use Agent tool — this skill is self-contained and uses direct tool calls.
1---2name: kafka-schema-registry3description: Scan a project to identify Kafka applications, extract schemas from data models, tag PII fields, generate Terraform for Confluent Schema Registry registration, and produce a migration report with rollout ordering. Use this skill when a user asks to analyze a folder or repo for Kafka usage, extract schemas, audit producer/consumer configurations, or generate Terraform for Schema Registry.4---56# Kafka Schema Registry Skill78Scan a project to identify Kafka applications, extract schemas, generate Terraform for Schema Registry registration, and produce a comprehensive analysis report.910## When to Use1112Invoke this skill when:13- A user asks to analyze a project for Kafka usage in order to add event schemas or integrate Schema Registry14- A user wants to extract schemas from Kafka producers15- A user wants Terraform to register schemas to Schema Registry16- A user wants to audit Kafka producer/consumer configurations1718## Deliverables1920This skill produces 3 outputs in the target project:21221. **`schema-report.md`** — Full analysis report with findings, risks, and upgrade recommendations232. **`schemas/`** — Extracted schema files (Avro, JSON Schema, Protobuf) with PII tagging243. **`terraform/`** — Terraform configs using Confluent provider to register schemas2526### Optional: Code Migration Assistance2728If the user asks for their application code to be updated to integrate Schema Registry, use the [Code Migration Reference](references/code-migration.md) to update the code with proper Schema Registry integration patterns.2930---3132## High-Level Workflow3334### Phase 0: Initialize3536- Check for existing `schema.yaml` and `schemas/` directory manually37- Note any existing schema infrastructure in the report3839### Phase 1: Project Scan & Kafka Detection40411. **Find build files** — Search for `pom.xml`, `build.gradle`, `requirements.txt`, `package.json`, etc.422. **Detect Kafka dependencies** — Look for `spring-kafka`, `confluent-kafka`, `kafkajs`, etc.433. **Find producers & consumers** — Grep for `KafkaTemplate`, `Producer(`, `producer.send`, etc.444. **Extract topic names** — From string literals, config properties, YAML files455. **Identify serializers** — Find `value.serializer`, `KafkaAvroSerializer`, custom serializers466. **Build app catalog** — Compile findings: app name, language, role, topics, serializer, category4748**Detailed patterns:** [Detection Patterns Reference](references/detection-patterns.md)4950**App catalog structure:**51```yaml52app_name: module name53language: Java | Python | .NET | Go | Node/TS54role: producer | consumer | both55topics: [list of topics]56serializer_class: value.serializer used57custom_serializer: true | false58schema_format: AVRO | JSON | PROTOBUF | UNKNOWN59sr_integrated: true | false60category: A | B | C | D | E # REQUIRED61```6263**Multi-schema topic detection:**64- If multiple data models produce to the same topic, create a wrapper schema with `oneOf`/union/`oneof`65- Generate Terraform with `schema_reference` blocks66- Flag prominently in report6768### Phase 2: Risk Detection6970Search for:71- **`auto.register.schemas=true`** — Uncontrolled schema evolution (Category C)72- **`use.latest.version`** — Eases migration when set73- **Custom serializers** — Bypass SR entirely (Category E)7475Record file path, line number, and affected topics for each occurrence.7677**Patterns:** [Detection Patterns Reference](references/detection-patterns.md#risk-detection)7879### Phase 3: Schema Inference8081For each producer:821. **Check for existing schema files** — `**/*.avsc`, `**/*.proto`, `**/*.schema.json`832. **Infer from data models** — Java classes, Pydantic models, TypeScript interfaces, Go structs843. **Infer from inline data** — HashMap, dict literals, map[string]any, plain objects, JSON strings854. **Convert to schemas** — Map language types to JSON Schema / Avro / Protobuf865. **Tag PII fields** — Scan field names for `email`, `ssn`, `phone`, `address`, etc.8788**PII tagging:** Add `confluent:tags` (`PII`, `PRIVATE`, `SENSITIVE`, `PHI`) to detected fields.8990**Detailed inference patterns:** [Schema Inference Reference](references/schema-inference.md)9192### Phase 4: Categorize Producers9394Classify each producer:9596| Category | Criteria |97|----------|----------|98| **A: Compliant** | Confluent serializer + SR + no auto.register |99| **A→Header** | Already on SR, migrating to headers |100| **B: Schema in code, no SR** | Data models exist, but no SR integration |101| **C: Auto-register** | `auto.register.schemas=true` |102| **D: No schema** | Raw strings/bytes, no data model |103| **E: Custom serializer** | Custom `Serializer<T>` or inline serialization without SR |104105**CRITICAL:** Use exact phrase "Category X" in:106- App catalog field107- Applications Discovered table108- Report section headers109- Terraform comments110- Risk sections111112**Details:** [Categorization Reference](references/categorization.md)113114### Phase 5: Create Schema Files115116**Directory structure:**117```118schemas/119├── avro/120│ └── {topic}-value.avsc121├── json/122│ └── {topic}-value.json123└── proto/124 └── {topic}-value.proto125```126127**File naming:** MUST use **kebab-case** (lowercase with hyphens):128- Value: `{topic}-value.{ext}`129- Key: `{topic}-key.{ext}`130- Examples: `order-events-value.avsc`, `user-notifications-value.json`131132**Initialize:** Create `schema.yaml`.133134**Validate:** Call `schema_lint(path: schemas/, fix: true)` if available.135136### Phase 6: Generate Terraform137138**File structure (MANDATORY separate files):**139```140terraform/141├── providers.tf # Provider config142├── variables.tf # Variable definitions143├── tags.tf # confluent_tag resources (if PII exists)144├── schemas.tf # Active schemas (A, B, E)145├── flagged-auto-register.tf # Category C only (commented out)146├── outputs.tf # Output values147└── import.sh # Import script148```149150**CRITICAL:**151- `schemas.tf` = Categories A, B, E — NOT commented out152- `flagged-auto-register.tf` = Category C ONLY — MUST be commented out153- `tags.tf` = MUST exist if ANY schema uses `confluent:tags`154- Each schema resource MUST have comment block: Topic, App, Source, Category155156**Templates:** [Terraform Templates Reference](references/terraform-templates.md)157158### Phase 7: Generate Report159160Create `schema-report.md` with:161- Executive Summary (metrics + category breakdown)162- **Applications Discovered table** (EXACT format, Category column MANDATORY)163- RISKS (auto-register, custom serializers)164- Producer Upgrade Recommendations (per app, with "Category X" in heading)165- Migration Rollout Ordering (by category)166- PII Fields Detected167- Terraform Resources Generated168- Next Steps checklist169170**CRITICAL formatting requirements:**1711. Applications Discovered = markdown table, NOT narrative sections1722. Every app section MUST say "Category X" explicitly1733. Terraform comment blocks required for every resource174175**Template:** [Report Template Reference](references/report-template.md)176177---178179## Migration Rollout by Category180181- **Category B** (JSON, no SR): Producers first → consumers182- **Category A→Header** (already on SR): Verify consumer versions → producers only183- **Category C** (auto-register): Register via Terraform → disable auto-register → producers fetch latest184- **Category E** (custom serializers): Consumers first (composite deserializer) → producers185186**Details:** [Categorization Reference](references/categorization.md#migration-rollout-order-by-category)187188---189190## Edge Cases191192- **Monorepos:** Treat each service/module with Kafka deps as separate app193- **Multi-topic producers:** Generate one schema resource per topic194- **Shared schemas:** One schema file, multiple Terraform resources reference it195- **No topic names:** If loaded from env vars, use placeholders with TODO196- **Test code:** Skip test directories unless they contain only schema definitions197- **Multiple serializers:** Create separate schema files per format198199---200201## Output Organization202203```204{project_root}/205├── schema-report.md # Analysis report206├── schemas/207│ ├── schema.yaml # Schema project config208│ ├── avro/209│ │ └── {topic}-value.avsc210│ ├── json/211│ │ └── {topic}-value.json212│ └── proto/213│ └── {topic}-value.proto214└── terraform/215 ├── providers.tf216 ├── variables.tf217 ├── tags.tf # PII/PRIVATE/SENSITIVE tags218 ├── schemas.tf # Active schemas (depends_on tags)219 ├── flagged-auto-register.tf # Commented-out Category C220 ├── outputs.tf221 └── import.sh # Import existing schemas222```223224---225226## Reference Documentation227228- [Detection Patterns](references/detection-patterns.md) — Patterns for finding Kafka apps, dependencies, producers, consumers, serializers229- [Schema Inference](references/schema-inference.md) — Extract schemas from data models, inline data, PII tagging230- [Categorization](references/categorization.md) — Category definitions, rollout order, client version requirements231- [Terraform Templates](references/terraform-templates.md) — File structure, templates, naming conventions232- [Report Template](references/report-template.md) — Required sections, formatting rules, validation checklist233- [Code Migration](references/code-migration.md) — Serializer/deserializer implementation patterns for Python, Java, JavaScript, Go, and .NET234235---236237## Execution Approach2382391. Use **Glob** to find build files and schema files2402. Use **Grep** for pattern detection (dependencies, producers, serializers, risks)2413. Use **Read** to inspect source files and data models2424. Use **Write** to create schema files, Terraform configs, and report243244**No need to use Agent tool** — this skill is self-contained and uses direct tool calls.