$npx -y skills add Amplicode/spring-skills --skill kafka-configurationConfigures Spring Boot's Kafka starter through application.properties / application.yml. Use this skill when Kafka configuration needs to be created, either standalone or as part of a larger task (e.g. before adding a KafkaTemplate producer or a @KafkaListener consumer).
| 1 | # Preflight: Spring MCP |
| 2 | |
| 3 | This skill is part of the **Spring Agent Toolkit** and is designed to work with the **Spring MCP server** (provided by the Amplicode IntelliJ plugin). Before doing anything else, check your tool list for any Spring MCP tool — they are exposed under the `amplicode` MCP server (e.g. `get_project_summary`, `list_module_dependencies`, `list_application_properties_files`); harnesses that flatten MCP tools into the tool list use the `mcp__amplicode__` prefix on the same names. |
| 4 | |
| 5 | - **If at least one Amplicode tool is available** — MCP is connected. Proceed with the skill below. |
| 6 | - **If none are available** — stop and invoke the **`amplicode-install`** skill (bundled with the Spring Agent Toolkit). It installs the Amplicode plugin and walks the user through the **«Настроить Spring Agent»** welcome-screen button + MCP-client restart. After it completes, the MCP tools become available — resume this skill. |
| 7 | - If `amplicode-install` is not registered in your skill list, tell the user (in their language): *"This skill needs the Amplicode IntelliJ plugin and its MCP server. Install it from https://amplicode.ru/marketplace into IntelliJ IDEA Ultimate/Community or GigaIDE, open any project, click «Настроить Spring Agent» on the Amplicode welcome screen, then restart your MCP client."* |
| 8 | |
| 9 | --- |
| 10 | |
| 11 | # Kafka Configuration |
| 12 | |
| 13 | Wires Spring Boot's Kafka starter through `application.properties` / `application.yml` and, optionally, a generated `KafkaConfiguration` class. Ensures the starter dependency is on the module classpath. |
| 14 | |
| 15 | > **CRITICAL: Code ONLY from `examples/` files. If no matching example — STOP and ask user.** |
| 16 | > **CRITICAL: For questions with a fixed set of choices, prefer `AskUserQuestion` > its analogue > plain text list.** |
| 17 | > **CRITICAL: Read the conversation context BEFORE running Step 1.** Half the questions in Steps 2–3 may already be answered. |
| 18 | |
| 19 | ## Two paths (Step 3 picks) |
| 20 | |
| 21 | - **Path A — `serializerSource = properties`** (default). All six `spring.kafka.*` keys go into the property source: `bootstrap-servers`, `consumer.group-id`, producer key/value serializer, consumer key/value deserializer. `KafkaAutoConfiguration` creates `ProducerFactory`, `ConsumerFactory`, `KafkaTemplate` (bean `kafkaTemplate`), and `kafkaListenerContainerFactory` from them. |
| 22 | - **Path B — `serializerSource = @Configuration`**. Only `bootstrap-servers` + `consumer.group-id` go into the property source. A `KafkaConfiguration` class is generated with four beans: `{prefix}ProducerFactory`, `{prefix}KafkaTemplate`, `{prefix}ConsumerFactory`, `kafkaListenerContainerFactory`. `{prefix}` is the lowercased simple name of `producerValueType`. The listener factory bean name is **fixed** — autoconfig backs off via `@ConditionalOnMissingBean(name = "kafkaListenerContainerFactory")`, any other name leaves the autoconfig factory in place and silently routes `@KafkaListener` to the wrong one. |
| 23 | |
| 24 | ## Defaults |
| 25 | |
| 26 | | Option | Default | Always ask? | |
| 27 | |---|---|---| |
| 28 | | `producerKeyType` / `producerValueType` / `consumerKeyType` / `consumerValueType` | `java.lang.String` | YES — always ask producer key + value; consumer defaults to symmetric | | |
| 29 | | `consumerGroup` | — | YES (mandatory) | |
| 30 | | `bootstrapServers` | `localhost:9092` | NO | |
| 31 | | `serializerSource` | `properties` | YES | |
| 32 | | `className` | `KafkaConfiguration` | NO (only for Path B) | |
| 33 | | `packageName` | `mainPackage` | NO (only for Path B) | |
| 34 | | `language` / `bootVersion` | from `get_project_summary` | NO | |
| 35 | |
| 36 | **Smart defaults.** If the user says "use defaults" / "all defaults" / "minimal configuration" → skip every `Always ask = NO` question. Only ask the mandatory ones (`consumerGroup`, `serializerSource`, and any type the user already mentioned non-default for). |
| 37 | |
| 38 | **Smart answer recognition.** When the user provides a value directly ("for `OrderEvent` messages", "group `orders`"), accept it without asking again. Multiple answers in one message → accept all. |
| 39 | |
| 40 | **Batch questions.** Group related questions into one `AskUserQuestion` call (up to 4 questions). Recommended option first, `(Recommended)` in its label. |
| 41 | |
| 42 | ## Decision-making — context first, then ask |
| 43 | |
| 44 | For every input: try to derive from `get_project_summary`, `list_module_dependencies`, `list_application_properties_files`, prior turns, the user's prompt. Only ask when context yields no clear default. |
| 45 | |
| 46 | 1. **Context unambiguous → decide silently.** `language`, `bootVersion`, `mainPackage`, `bootstrapServers = localhost:9092`, single-file `propsFile`. |
| 47 | 2. **Strong signal → one-line confirmation.** State decision + alternatives; user can accept silently. |
| 48 | 3. **No clear default → `AskUserQuestion`** with recommended option first. |
| 49 | 4. ** |