Skip to main content

Claude/ChatGPT Prompt to Design a Kafka Topic and Schema Strategy

Kafka topic design for an event domain: naming, partitioning, retention, compaction, Schema Registry evolution rules, and example producer/consumer code.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt sets the model up as a senior streaming-data engineer and asks for a concrete Kafka topic and schema strategy with real producer and consumer code -- not a high-level overview. You provide [use_case], [throughput], and [ordering_needs], and it returns topic naming, a partitioning strategy, retention and compaction settings, a Schema Registry plan, consumer group design, and working code.

The partition key is the decision the structure is built around. [ordering_needs] forces the model to justify which key it picks: strict per-entity ordering means keying on that entity, while loose ordering allows round-robin spreading. [throughput] informs partition count and whether one key risks hot-spotting under load. [use_case] defines the event domain and therefore how many topics make sense. By demanding the model defend the key against the ordering guarantee, the prompt avoids the default mistake of round-robin everything, and it ties retention and compaction choices to the way each topic is actually consumed.

When to use it

  • You're designing an event backbone and need a defensible partition-key choice.
  • You must preserve per-entity ordering (e.g. per-order) and want the keying to prove it.
  • You're worried about hot partitions under peak load and need a throughput-aware layout.
  • You need Schema Registry evolution rules (backward vs forward compatible) written down.
  • You want retention and compaction settings justified per topic, not copy-pasted defaults.
  • You need starter producer and consumer code with serialization already wired in.
  • You're adding consumers later and want rebalance behaviour predictable from the start.

Example output

You get a topic config table (names, partition counts, retention, compaction), the schema in Avro or Protobuf with its evolution rules spelled out, then producer and consumer code with serialization and consumer-group config wired in. The code is meant to run and illustrate the keying and rebalance behaviour, not to be a snippet you still have to assemble. Together the table and code give you both the design rationale and the runnable proof of it.

Pro tips

  • State [ordering_needs] precisely -- strict per-order ordering versus best-effort changes the key and the partition count.
  • Give a realistic [throughput] (e.g. 50k events/sec peak) so partition counts and hot-spot warnings are sized to your load.
  • Describe [use_case] as the full domain (orders and payments events) so the model decides topic count sensibly.
  • Replay a day of events through a new consumer before you call the schema final -- evolution bugs only show on real history.
  • If the model defaults to round-robin, push back and make it tie the key choice to your stated ordering guarantee.
  • Ask it to spell out the backward-vs-forward compatibility rule for your registry so a producer change can't break consumers silently.
  • Pin down consumer-group design up front so rebalance behaviour is predictable when you add consumers later.

Frequently Asked Questions

How does this prompt decide the partition key?
It ties the key choice directly to your `[ordering_needs]`. Strict per-entity ordering forces keying on that entity, while looser ordering allows spreading load. The prompt asks the model to justify the key against the ordering guarantee rather than defaulting to round-robin.
Does it return real producer and consumer code?
Yes. The prompt explicitly asks for working producer and consumer code with serialization wired in, alongside a topic config table and the schema. The code illustrates the keying and rebalance behaviour so you can see the strategy in practice, not just read it.
Can it handle high-throughput topics without hot partitions?
The `[throughput]` variable informs partition count and whether a chosen key risks hot-spotting under load. Provide a realistic peak figure so the model sizes partitions and warns about skew honestly rather than assuming even distribution.
Does it cover schema evolution?
Yes, it specifies the schema via Schema Registry in Avro or Protobuf and states the evolution rules, distinguishing backward from forward compatibility. Replay real historical events through a new consumer before finalizing, since evolution bugs tend to surface only on actual data.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Data Engineering & ETL Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support