Type-safe AI services in Java using interface-based patterns, annotations, and declarative configuration.
Works with
Define AI capabilities as plain Java interfaces with @SystemMessage and @UserMessage annotations, eliminating manual prompt construction and response parsing
Built-in memory management for multi-turn conversations with per-user or per-session isolation using @MemoryId and configurable chat memory providers
Tool integration enables AI services to call external functions and execut
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionlangchain4j-ai-services-patternsExecute the skills CLI command in your project's root directory to begin installation:
Fetches langchain4j-ai-services-patterns from giuseppe-trisciuoglio/developer-kit and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate langchain4j-ai-services-patterns. Access via /langchain4j-ai-services-patterns in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
0
total installs
0
this week
194
GitHub stars
0
upvotes
Run in your terminal
0
installs
0
this week
194
stars
This skill provides guidance for building declarative AI Services with LangChain4j using interface-based patterns, annotations for system and user messages, memory management, tools integration, and advanced AI application patterns that abstract away low-level LLM interactions.
LangChain4j AI Services define AI functionality using Java interfaces with annotations, providing type-safe, declarative AI with minimal boilerplate.
Use this skill when:
Follow these steps to create declarative AI Services with LangChain4j:
Create a Java interface with method signatures for AI interactions:
interface Assistant {
String chat(String userMessage);
}
Use @SystemMessage and @UserMessage annotations to define prompts:
interface CustomerSupportBot {
@SystemMessage("You are a helpful customer support agent for TechCorp")
String handleInquiry(String customerMessage);
@UserMessage("Analyze sentiment: {{it}}")
Sentiment analyzeSentiment(String feedback);
}
Use AiServices builder or create to instantiate the service:
// Simple creation
Assistant assistant = AiServices.create(Assistant.class, chatModel);
// Or with builder for advanced configuration
Assistant assistant = AiServices.builder(Assistant.class)
.chatModel(chatModel)
.build();
Add memory management using @MemoryId for multi-user scenarios:
interface MultiUserAssistant {
String chat(@MemoryId String userId, String userMessage);
}
Assistant assistant = AiServices.builder(MultiUserAssistant.class)
.chatModel(model)
.chatMemoryProvider(userId -> MessageWindowChatMemory.withMaxMessages(10))
.build();
Register tools using @Tool annotation to enable AI function execution:
class Calculator {
@Tool("Add two numbers") double add(double a, double b) { return a + b; }
}
interface MathGenius {
String ask(String question);
}
MathGenius mathGenius = AiServices.builder(MathGenius.class)
.chatModel(model)
.tools(new Calculator())
.build();
Test AI services with concrete validation patterns:
// 1. Test with sample inputs
String response = assistant.chat("Hello, how are you?");
assert response != null && !response.isEmpty();
// 2. Validate structured outputs with assertions
Sentiment result = bot.analyzeSentiment("Great product!");
assert result == Sentiment.POSITIVE;
// 3. Log tool calls with side effects for audit
MathGenius math = AiServices.builder(MathGenius.class)
.chatModel(model)
.tools(new Calculator())
.build();
// 4. Test memory isolation between users
String userA = assistant.chat("User A message", "session-a");
String userB = assistant.chat("User B message", "session-b");
assert !userA.equals(userB); // Verify memory isolation
See examples.md for comprehensive practical examples including:
Complete API documentation, annotations, interfaces, and configuration patterns are available in references.md.
<!-- Maven -->
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-open-ai</artifactId>
<version>1.8.0</version>
</dependency>
// Gradle
implementation 'dev.langchain4j:langchain4j:1.8.0'
implementation 'dev.langchain4j:langchain4j-open-ai:1.8.0'
Prerequisites
Time Estimate
15-45 minutes depending on use case complexity
Steps
Common Pitfalls
✓ Do
✗ Don't
💡 Pro Tips
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
giuseppe-trisciuoglio/developer-kit
giuseppe-trisciuoglio/developer-kit
giuseppe-trisciuoglio/developer-kit
giuseppe-trisciuoglio/developer-kit
davila7/claude-code-templates
intellectronica/agent-skills
Useful defaults in langchain4j-ai-services-patterns — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
langchain4j-ai-services-patterns has been reliable in day-to-day use. Documentation quality is above average for community skills.
Solid pick for teams standardizing on skills: langchain4j-ai-services-patterns is focused, and the summary matches what you get after install.
langchain4j-ai-services-patterns reduced setup friction for our internal harness; good balance of opinion and flexibility.
langchain4j-ai-services-patterns has been reliable in day-to-day use. Documentation quality is above average for community skills.
langchain4j-ai-services-patterns has been reliable in day-to-day use. Documentation quality is above average for community skills.
Registry listing for langchain4j-ai-services-patterns matched our evaluation — installs cleanly and behaves as described in the markdown.
Useful defaults in langchain4j-ai-services-patterns — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
Solid pick for teams standardizing on skills: langchain4j-ai-services-patterns is focused, and the summary matches what you get after install.
langchain4j-ai-services-patterns is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
showing 1-10 of 62