giuseppe-trisciuoglio/developer-kit/langchain4j-rag-implementation-patterns
Claude Code and agent skill by giuseppe-trisciuoglio/developer-kit
- community
Checking that the SKILL.md file is still in the repository.
Provides Retrieval-Augmented Generation (RAG) implementation patterns with LangChain4j for Java. Generates document ingestion pipelines, embedding stores, vector search, and semantic search capabilities. Use when building chat-with-documents systems, document Q&A over PDFs or text files, AI assistants with knowledge bases, semantic search over document repositories, or knowledge-enhanced AI applications with source attribution.
Install
npx vskill@latest install giuseppe-trisciuoglio/developer-kit/langchain4j-rag-implementation-patternsSKILL.md
The same SKILL.md was published earlier as giuseppe-trisciuoglio/developer-kit/langchain4j-rag-implementation-patterns.
LangChain4j RAG Implementation Patterns
Overview
Implements RAG systems with LangChain4j: document ingestion pipelines, embedding stores, and vector search for chat-with-documents and knowledge-enhanced AI applications.
When to Use This Skill
- Building chat-with-documents systems or document Q&A over PDFs, text files, or web pages
- Creating AI assistants with access to company knowledge bases or external sources
- Implementing semantic search or hybrid search over document repositories
- Building domain-specific AI with curated knowledge and source attribution
Instructions
Initialize RAG Project
Create a new Spring Boot project with required dependencies:
pom.xml:
Setup Document Ingestion
Configure document loading and processing with validation:
Validation Checkpoint: After ingestion, verify embedding count matches segment count and test retrieval with a sample query.
Create document ingestion service:
Configure Content Retrieval
Setup content retrieval with filtering:
Validation Checkpoint: After configuration, test retrieval with a known query to verify embeddings are searchable.
Create RAG-Enabled AI Service
Define AI service with context retrieval:
Examples
Basic Document Processing
Multi-Domain Assistant
Hierarchical RAG
Best Practices
Document Segmentation
- Use recursive splitting with 500-1000 token chunks for most applications
- Maintain 20-50 token overlap between chunks for context preservation
- Consider document structure (headings, paragraphs) when splitting
- Use token-aware splitters for optimal embedding generation
Metadata Strategy
- Include rich metadata for filtering and attribution:
- User and tenant identifiers for multi-tenancy
- Document type and category classification
- Creation and modification timestamps
- Version and author information
- Confidentiality and access level tags
Query Processing
- Implement query preprocessing and cleaning
- Consider query expansion for better recall
- Apply dynamic filtering based on user context
- Use re-ranking for improved result quality
Performance Optimization
- Cache embeddings for repeated queries
- Use batch embedding generation for bulk operations
- Implement pagination for large result sets
- Consider asynchronous processing for long operations
Common Patterns
Simple RAG Pipeline
Hybrid Search (Vector + Keyword)
Troubleshooting
Validation Failures
Embedding Count Mismatch: Thrown when segments != embeddings. Check splitter configuration and model availability.
Empty Retrieval Results: Call validateIngestion(testQuery) to verify embeddings are searchable. Check if document was ingested successfully.
Low Retrieval Scores: Verify minScore threshold (default 0.7) is not too high for your use case. Test with known queries.
Common Issues
Poor Retrieval Results
- Check document chunk size and overlap settings
- Verify embedding model compatibility
- Ensure metadata filters are not too restrictive
- Consider adding re-ranking step
- Run validation to confirm embeddings exist
Slow Performance
- Use cached embeddings for frequent queries
- Optimize database indexing for vector stores
- Implement pagination for large datasets
- Consider async processing for bulk operations
High Memory Usage
- Use disk-based embedding stores for large datasets
- Implement proper pagination and filtering
- Clean up unused embeddings periodically
- Monitor and optimize chunk sizes
Constraints and Warnings
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/developer-kit-java/skills/langchain4j-rag-implementation-patterns/SKILL.md
Popularity
- Repository stars
- 345
- Repository forks
- 41
- 7-day trend score
- 29
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 13 Sep 2026, 2 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-rag-implementation-patterns)