/spring-boot-skills:spring-ai-chatfrom Spring Boot Skills
Adds LLM chat to a Spring Boot 4 Maven project using Spring AI's ChatClient with system prompting, structured output to records, and @Tool tool calling. Supports Ollama or OpenAI. Not for document Q&A or exposing tools to agents.
Ships in Spring Boot Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Adds direct LLM interaction to an existing Spring Boot 4 project: a ChatClient endpoint,
structured output, and tool calling. Document retrieval is a different skill (spring-ai-rag).
SKILL_DIR = directory containing this SKILL.md file.
| Field | Required | Notes |
|---|---|---|
provider | No | ollama (default, local) or openai |
model | No | qwen3:4b for Ollama, gpt-5-mini for OpenAI |
useCase | Yes | what the chat endpoint is for (drives system prompt and tools) |
For OpenAI the user needs OPENAI_API_KEY in the environment. Default to Ollama when unsure.
Next: dependencies.
Add the BOM to pom.xml <dependencyManagement> (skip if spring-ai-rag already added it):
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>2.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Then one starter, by provider:
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-ollama</artifactId>
</dependency>
<!-- or -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-openai</artifactId>
</dependency>
Before writing, confirm 2.0.1 is still the latest:
curl -s "https://repo1.maven.org/maven2/org/springframework/ai/spring-ai-bom/maven-metadata.xml" \
| python3 -c "import sys,re; print(re.findall(r'<version>(.*?)</version>', sys.stdin.read())[-1])"
Ollama runs via Testcontainers in tests (ollama/ollama:0.35.0) — verify the tag before writing:
curl -s "https://hub.docker.com/v2/repositories/ollama/ollama/tags/0.35.0" \
| python3 -c "import json,sys; d=json.load(sys.stdin); print(d['name'], d['last_updated'][:10])"
Next: the chat service.
One ChatClient per use case, built with its system prompt — not a shared raw ChatModel:
package com.example.support;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.stereotype.Service;
@Service
class SupportChatService {
private final ChatClient chat;
SupportChatService(ChatClient.Builder builder) {
this.chat = builder
.defaultSystem("You are the support assistant for an order service. "
+ "Answer briefly. If you do not know, say so.")
.build();
}
String ask(String question) {
return chat.prompt().user(question).call().content();
}
}
Rules:
ChatModel directly.Next: structured output.
Map responses straight to a record:
record Triage(String category, int urgency, String reply) {}
Triage triage(String message) {
return chat.prompt().user(message).call().entity(Triage.class);
}
If the record has no usable constructor mapping (nested generics), add @JsonPropertyDescription
on the record components so the model gets a real schema.
Next: tool calling.
Expose application methods as tools the model can call:
package com.example.support;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.stereotype.Component;
@Component
class OrderTools {
private final OrderRepository orders;
OrderTools(OrderRepository orders) {
this.orders = orders;
}
@Tool(description = "Look up an order's status by its id")
String orderStatus(long orderId) {
return orders.findById(orderId)
.map(o -> "status: " + o.getStatus())
.orElse("no order with id " + orderId);
}
}
Wire it onto the client call:
chat.prompt().user(question).tools(orderTools).call().content();
Rules:
Next: test it.
Unit-test the service with a stubbed ChatClient (no model call in CI). For a live smoke test,
run Ollama via the compose service or Testcontainers — the same pattern spring-ai-rag uses, so
apply its container setup rather than duplicating it here.
Assert behavior, not prose: structured output deserializes, tool gets called when the question requires it (assert repository interaction), unknown questions get an "I don't know".
Next: report.
Report:
spring-ai-rag; if external agents should
call these tools, apply mcp-server.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub dancan254/spring-boot-skills --plugin spring-boot-skills17 skills in this plugin
/api-designAdd OpenAPI docs and REST conventions to an existing Spring Boot 4 Maven project — SpringDoc, API versioning, ProblemDetail error schemas, DTO conventions. Use when asked to add OpenAPI or Swagger, document or version an API, or define REST conventions. Not for auth — use spring-security./devops-scaffoldAdd or update Dockerfile, docker-compose.yml, and GitHub Actions CI for an existing Spring Boot Maven project; reads the project first. Use when asked to dockerize a project, add CI or GitHub Actions, or set up DevOps. Not for security scanning — use security-hardening. Not for new projects — use spring-scaffold./http-resilienceMake outbound HTTP calls resilient in an existing Spring Boot 4 Maven project — circuit breakers, retries, and timeouts with RestClient and Resilience4j, plus tests that prove failures degrade gracefully. Use when asked to add retries or a circuit breaker, call external APIs reliably, or protect against a flaky downstream. Not for inbound rate limiting — use redis-setup.Other plugins' skills for the same job