langchain4j-rag-implementation-patterns

langchain4j-rag-implementation-patterns is a skill for Claude Code from giuseppe-trisciuoglio/developer-kit. It costs 86 tokens per session (2,556 once invoked), scanned A, original, MIT.

A set of LangChain4j patterns for retrieval-augmented generation (RAG): loading documents, turning them into searchable numerical representations, and retrieving relevant passages for an AI response. It supports document question answering and semantic search, which finds meaning rather than only matching words.

In plain words
What is it for?
Use it to build chat-with-documents systems, question answering over PDFs or text, knowledge-base assistants, semantic or hybrid search, and domain-specific AI applications.
Why use it?
It provides the pieces needed for an assistant to use company or external documents instead of relying only on the model's training. This helps keep answers tied to a selected knowledge collection and can support source attribution.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the developer-kit-java plugin — 52 skills, 11 commands, 9 agents shipped together

Good fit Use it to build chat-with-documents systems, question answering over PDFs or text, knowledge-base assistants, semantic or hybrid search, and domain-specific AI applications.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/giuseppe-trisciuoglio/developer-kit/langchain4j-rag-implementation-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add giuseppe-trisciuoglio/developer-kit --skill langchain4j-rag-implementation-patterns
Clone the repo
git clone --depth 1 https://github.com/giuseppe-trisciuoglio/developer-kit

Made for: Claude Code.

Or install developer-kit-java, the plugin that ships this one along with the rest of its 52 skills, 11 commands, 9 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for langchain4j-rag-implementation-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-rag-implementation-patterns/github.svg)](https://agentmods.dev/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-rag-implementation-patterns)
Your own site
<a href="https://agentmods.dev/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-rag-implementation-patterns"><img src="https://agentmods.dev/badge/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-rag-implementation-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for langchain4j-rag-implementation-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-rag-implementation-patterns"><img src="https://agentmods.dev/badge/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-rag-implementation-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 86 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,556 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 1 Apr 2026
  • Snyk warn 1 Apr 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00086 $0.02556
Opus 5 $0.00043 $0.01278
Sonnet 5 $0.00017 $0.00511
Haiku 4.5 $0.00009 $0.00256

Measured today against content hash b005d76cc11c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

langchain4j-rag-implementation-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/developer-kit-java/skills/langchain4j-rag-implementation-patterns/SKILL.md · 382 lines

How it starts

The opening of the file, as written. The whole thing — 382 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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:

<dependency>
    <groupId>dev.langchain4j</groupId>
    <artifactId>langchain4j-spring-boot-starter</artifactId>
    <version>1.8.0</version>
</dependency>
<dependency>
    <groupId>dev.langchain4j</groupId>
    <artifactId>langchain4j-open-ai</artifactId>
    <version>1.8.0</version>
</dependency>

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.

@Configuration
public class RAGConfiguration {

    @Bean
    public EmbeddingModel embeddingModel() {
        return OpenAiEmbeddingModel.builder()
            .apiKey(System.getenv("OPENAI_API_KEY"))
            .modelName("text-embedding-3-small")
            .build();
    }

    @Bean
    public EmbeddingStore<TextSegment> embeddingStore() {
        return new InMemoryEmbeddingStore<>();
    }
}

Create document ingestion service:

@Service
@RequiredArgsConstructor
public class DocumentIngestionService {

    private final EmbeddingModel embeddingModel;
    private final EmbeddingStore<TextSegment> embeddingStore;

    public void ingestDocument(String filePath, Map<String, Object> metadata) {
        Document document = FileSystemDocumentLoader.loadDocument(filePath);
        document.metadata().putAll(metadata);

        DocumentSplitter splitter = DocumentSplitters.recursive(
            500, 50, new OpenAiTokenCountEstimator("text-embedding-3-small")
        );

        List<TextSegment> segments = splitter.split(document);
        List<Embedding> embeddings = embeddingModel.embedAll(segments).content();
        embeddingStore.addAll(embeddings, segments);

        // Validation: verify embedding count matches segments
        if (embeddings.size() != segments.size()) {
            throw new IllegalStateException("Embedding count mismatch: expected " + segments.size() + ", got " + embeddings.size());
        }
    }

    public boolean validateIngestion(String testQuery) {
        // Validation: test retrieval with sample query
        Embedding queryEmbedding = embeddingModel.embed(testQuery).content();
        List<EmbeddingMatch<TextSegment>> results = embeddingStore.search(
            EmbeddingSearchRequest.builder()
                .queryEmbedding(queryEmbedding)
                .maxResults(1)
                .build()
        ).matches();
        return !results.isEmpty();
    }
}

Read the full file on GitHub · 382 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today First seen · 382 lines · 86 tokens per session scan A b005d76cc11c

Subscribe to this mod's changes

langchain4j-rag-implementation-patterns is a skill published in the GitHub repository giuseppe-trisciuoglio/developer-kit (343 stars, last pushed yesterday), licensed MIT. It adds 86 tokens to every session and 2,556 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-10.

Related

Other skills, from other repositories

unity-llm-integration

Use when adding LLM/chat/RAG features to a Unity game or tool: API keys, prompt assets, safety, latency, and server-side vs client-side calls.

rachitkumarrastogi/unity-mcp-server · 41 tokens

java-spring-ai

Use when the user asks to add AI features, integrate Spring AI or LangChain4J, build a chatbot, implement RAG (retrieval-augmented generation), use vector stores, stream LLM responses, or call AI tools/functions in a Spring Boot project.

ducpm2303/claude-java-plugins · 59 tokens

graphify

Use for any question about a codebase, its architecture, file relationships, or project content — especially when graphify-out/ exists, where the question should be treated as a graphify query first. Turns any input (code, docs, papers, images, videos) into a persistent knowledge graph with god nodes, community…

Graphify-Labs/graphify · 76 tokens

azure-ai-contentunderstanding-py

Azure AI Content Understanding SDK for Python. Use for multimodal content extraction from documents, images, audio, and video. Triggers: "azure-ai-contentunderstanding", "ContentUnderstandingClient", "multimodal analysis", "document extraction", "video analysis", "audio transcription".

microsoft/skills · 64 tokens

azure-search-documents-ts

Build search applications using Azure AI Search SDK for JavaScript (@azure/search-documents). Use when creating/managing indexes, implementing vector/hybrid search, semantic ranking, or building agentic retrieval with knowledge bases.

microsoft/skills · 48 tokens

azure-ai

Use for Azure AI: Search, Speech, OpenAI, Document Intelligence. Helps with search, vector/hybrid search, speech-to-text, text-to-speech, transcription, OCR. WHEN: AI Search, query search, vector search, hybrid search, semantic search, speech-to-text, text-to-speech, transcribe, OCR, convert text to speech.

microsoft/skills · 76 tokens