skills/fp-kstream-design/SKILL.md
Kafka Streams topology design using Kafka Stream Algebra (KSA). Use this skill when designing, planning, or reviewing a Kafka Streams topology. Triggers: "design a topology", "kafka architecture", "stream processing design", "how should I model this as streams", "what pattern should I use", "topology review", "KSA", "Kafka Stream Algebra", or any request to diagram, plan, or reason about a Kafka-based backend service before writing code. Do NOT use for implementation, coding, or testing — use fp-kstream-implement for those.
npx skillsauth add mpurbo/purbo-skills fp-kstream-designInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Design deterministic, replay-safe, cost-efficient Kafka Streams topologies using KSA patterns.
Before responding, load the shared reference:
cat ${SKILL_PATH}/references/KSA.md
This is the authoritative source for all patterns, principles, and constraints.
Gather from the user (ask if missing):
Map to KSA recipes (KSA.md §4):
| Problem involves… | Recipe | |-------------------|--------| | Cleaning/validating inbound events | 01 — Validation & Normalization | | Duplicate events from upstream | 02 — Deduplication | | Splitting events to different consumers | 03 — Routing & Fan-Out | | Looking up reference data | 04 — Data Enrichment | | Reference data + historical computation | 05 — Enrichment + Stateful | | Counting, rate limiting, windowed metrics | 06 — Windowed Aggregation | | Entity lifecycle (order, payment, KYC) | 07 — Per-Key State Machine | | Cross-service coordination with rollback | 08 — Saga Orchestrator | | Building a read model or search index | 09 — CQRS Projection | | Bug fix replay or data backfill | 10 — Event Replay |
Arrange recipes left to right:
Source → [Ingress] → [Enrichment] → [Computation] → [Egress] → Sink
Not every stage needed. Only include what the problem requires.
Produce a Mermaid flowchart LR using the KSA symbol legend (KSA.md §3):
[TopicName] — Kafka topic[TopicName*] — compacted topic (KTable source)(Processor) — stateless processor{{Processor}} — stateful processor((Join)) — stream–table join[[Sink]] — side-effect boundary{Decision?} — conditional branchFor every topology, explicitly document:
Estimate per KSA.md §7.4:
| Factor | Estimate | Red Flag | |--------|----------|----------| | State store size/key | value × keys × retention | > 50 GB/instance | | Changelog overhead | store size × replication | > 100 GB total | | Repartition count | selectKey/through calls | > 2 on high-volume | | KTable restore time | topic size / throughput | > 10 minutes | | Partition count | all internal + output topics | > 500 total |
Multiple red flags → recommend alternatives (KSA.md §7.3).
Verify against KSA.md §6 before signing off.
Always produce:
| Anti-Pattern | Why It's Wrong | Suggest | |-------------|----------------|---------| | HTTP calls inside processor | Breaks replay determinism | KTable enrichment | | DB queries inside processor | Same as above | Compacted topic | | No declared missing-state policy | Undeclared behavior = design defect | Ask: "what happens when KTable has no entry?" | | Partition key mismatch | Join key ≠ partition key | Repartition (flag cost) | | Unbounded state stores | No TTL = unbounded growth | Ask about retention | | GlobalKTable for large data | Loads ALL data on EVERY instance | Regular KTable with partition-aligned joins | | Multiple repartitions on same stream | Each doubles I/O | Redesign key strategy | | Stateful where stateless suffices | Unnecessary state store overhead | Remove state store |
development
Use when turning a user's early brain-dump, product idea, architecture prompt, or "write a high-level system spec" request into a System Spec markdown document. This is Step 1 of the spec-driven workflow and should be used alongside superpowers:brainstorming when available. It decomposes the system into independently developable subsystems, defines contract boundaries, maps subsystem dependencies and parallelization order, and includes Mermaid dependency diagrams. Use this before subsystem-design-spec and before any OpenSpec artifacts. Trigger on phrases like "high-level system spec", "system specification", "system spec", "brain-dump to spec", "turn this into a spec", "write the spec", "architecture spec", "identify subsystems", "subsystem boundaries", "subsystem dependencies", "contract boundaries", "input/output contracts", "development order", "parallel development", "dependency map", "mermaid diagram", "docs/spec/system-spec.md", and any request to create a System Spec for Step 1 Brainstorming.
development
Use when creating or iterating on a detailed per-subsystem technical design specification from a system spec, before starting OpenSpec workflow. Triggers: "design spec", "subsystem spec", "write the spec for S1", "phase breakdown", "implementation phases", "mid-level spec", "technical design". Encodes opinionated progressive phase discipline with FP progression and contract boundaries. Do NOT use for high-level system specs (use brainstorming) or for OpenSpec artifacts (use openspec directly).
development
Use when setting up or updating OpenSpec's config.yaml for a project, or when OpenSpec workflow isn't picking up development disciplines (TDD, progressive phases, FP conventions). Triggers: "configure openspec", "setup openspec", "openspec config", "why didn't openspec use TDD", "openspec not invoking skills", "grounding config". Generates config.yaml with project context and skill invocation rules across sessions. Do NOT use for non-OpenSpec projects or for general CLAUDE.md configuration.
documentation
Apply consistent pastel color styling to mermaid diagrams. Use whenever creating or editing mermaid diagrams in documentation, specs, or PRDs.