agentleFS
sergeeeysergeeey/Claude-cod-top-2026/skills/extensions/llm-application-dev/SKILL.md

llm-application-dev

Skill9 starsChanged 7 months agoMITView on GitHub

End-to-end LLM application development: RAG pipelines, prompt engineering patterns, structured outputs, vector databases, embeddings, and LangChain/LangGraph orchestration with Claude. Triggers: /llm-application-dev, rag implementation, prompt engineering, vector database, embeddings, RAG система, промпт инжиниринг, LLM приложение.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Add chain-of-thought — measure delta

    line 220
  2. Distinctive:

    Add few-shot examples (3-5) — measure delta

    line 221
  3. Distinctive:

    Add output schema — measure parse failure rate

    line 222

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- BSV Скил : llm-application-dev TL;DR : RAG пайплайны + промпт-инжиниринг для LLM приложений на Claude/LangChain Вызов : /llm-application-dev, rag implementation, prompt engineering, RAG система НЕ для : обучения моделей, fine-tuning, инфраструктуры GPU-кластеров -->

LLM Application Development

Build production-grade LLM applications: RAG systems, structured outputs, and optimized prompts.

When to Use This Skill

  • Building RAG (Retrieval-Augmented Generation) systems over private documents
  • Optimizing prompts for consistency and reliability in production
  • Implementing structured outputs with Pydantic schemas
  • Choosing and integrating vector databases (Pinecone, Weaviate, Chroma)
  • Selecting embedding models for Claude applications
  • Designing chain-of-thought and few-shot learning systems
  • Debugging hallucinations, inconsistent outputs, or latency issues
  • Building multi-step LLM workflows with LangGraph

Part 1: RAG Implementation

When RAG Beats Fine-Tuning

ScenarioApproach
Proprietary documents, frequent updatesRAG
Stable domain knowledge, latency-criticalFine-tuning
Need citations and source attributionRAG
Behavior/style changeFine-tuning

Vector Database Selection

DBBest forNotes
PineconeProduction, managedServerless tier available
WeaviateHybrid search (dense + sparse)Open-source, self-hosted option
ChromaDevelopment, localLightweight, zero-config
pgvectorExisting Postgres stackSQL joins with vector search
QdrantHigh-throughput filteringRust core, fast payload filters

Embedding Model Selection

ModelProviderDimsNotes
voyage-3-largeVoyage AI1024Anthropic recommended for Claude apps
text-embedding-3-largeOpenAI3072Strong general-purpose
bge-large-en-v1.5BAAI1024Open-source, competitive quality
embed-english-v3.0Cohere1024Good multilingual

Complete RAG Pipeline (LangGraph + Claude)

from langchain_anthropic import ChatAnthropic
from langchain_community.vectorstores import Chroma
from langchain_voyageai import VoyageAIEmbeddings
from langchain_core.prompts import ChatPromptTemplate
from langgraph.graph import START, StateGraph
from typing import TypedDict, List
from langchain_core.documents import Document

# State definition
class RAGState(TypedDict):
    question: str
    context: List[Document]
    answer: str

# Initialize components
embeddings = VoyageAIEmbeddings(model="voyage-3-large")
vectorstore = Chroma(embedding_function=embeddings, persist_directory="./chroma_db")
retriever = vectorstore.as_retriever(search_kwargs={"k": 5})
llm = ChatAnthropic(model="claude-sonnet-4-6")

rag_prompt = ChatPromptTemplate.from_messages([
    ("system", """Answer using only the provided context.
    If the answer is not in the context, say "I don't know."
    Always cite the source document.

    Context:
    {context}"""),
    ("human", "{question}")
])

# Graph nodes
def retrieve(state: RAGState) -> RAGState:
    docs = retriever.invoke(state["question"])
    return {"context": docs}

def generate(state: RAGState) -> RAGState:
    context_text = "\n\n".join(doc.page_content for doc in state["context"])
    chain = rag_prompt | llm
    response = chain.invoke({"question": state["question"], "context": context_text})
    return {"answer": response.content}

# Build graph
graph = StateGraph(RAGState)
graph.add_node("retrieve", retrieve)
graph.add_node("generate", generate)
graph.add_edge(START, "retrieve")
graph.add_edge("retrieve", "generate")
rag_app = graph.compile()

# Run
result = rag_app.invoke({"question": "What is our refund policy?"})
print(result["answer"])

Retrieval Strategies

  1. Dense retrieval — embedding similarity (good for semantic match)
  2. Sparse retrieval — BM25/keyword (good for exact terms, product names)
  3. Hybrid search — combine both with RRF (Reciprocal Rank Fusion)
  4. Multi-query — generate N query variants, union results

Reranking (improves top-k quality significantly)

from langchain_cohere import CohereRerank
from langchain.retrievers import ContextualCompressionRetriever

compressor = CohereRerank(model="rerank-english-v3.0", top_n=3)
compression_retriever = ContextualCompressionRetriever(
    base_compressor=compressor,
    base_retriever=retriever
)

Part 2: Prompt Engineering Patterns

Few-Shot Learning

from langchain_core.prompts import FewShotChatMessagePromptTemplate

examples = [
    {"input": "The product broke after 2 days", "output": "negative"},
    {"input": "Best purchase I've made this year!", "output": "positive"},
    {"input": "It works, nothing special", "output": "neutral"},
]

example_prompt = ChatPromptTemplate.from_messages([
    ("human", "{input}"), ("ai", "{output}")
])

few_shot_prompt = FewShotChatMessagePromptTemplate(
    examples=examples,
    example_prompt=example_prompt,
)

Structured Outputs with Pydantic

from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import ChatPromptTemplate
from pydantic import BaseModel, Field

class SQLQuery(BaseModel):
    query: str = Field(description="The SQL query")
    explanation: str = Field(description="Brief explanation")
    tables_used: list[str] = Field(description="Tables referenced")

llm = ChatAnthropic(model="claude-sonnet-4-6")
structured_llm = llm.with_structured_output(SQLQuery)

prompt = ChatPromptTemplate.from_messages([
    ("system", """You are an expert SQL developer.
    Generate efficient, secure SQL with parameterized queries."""),
    ("user", "Convert this to SQL: {query}")
])

chain = prompt | structured_llm
result = await chain.ainvoke({"query": "Find users registered in the last 30 days"})
print(result.query)        # SELECT * FROM users WHERE created_at > ...
print(result.tables_used)  # ['users']

Chain-of-Thought Patterns

cot_prompt = ChatPromptTemplate.from_messages([
    ("system", """Solve problems step by step.
    Format:
    REASONING: <step-by-step thinking>
    ANSWER: <final answer>"""),
    ("user", "{problem}")
])

System Prompt Design Checklist

  • Role and expertise defined ("You are an expert X")
  • Output format specified (JSON, markdown, plain text)
  • Constraints listed (max length, forbidden topics)
  • Example of desired output included (if non-obvious)
  • Edge case handling specified ("If unsure, say...")

Prompt Optimization Workflow

  1. Baseline: simple zero-shot prompt, measure accuracy on 20 samples
  2. Add chain-of-thought — measure delta
  3. Add few-shot examples (3-5) — measure delta
  4. Add output schema — measure parse failure rate
  5. A/B test variants, track: accuracy, consistency, latency, token cost

Common Pitfalls

PitfallFix
Hallucinated citations in RAGRequire model to quote exact passage before answering
Context window overflowRerank + truncate to top-3 docs, max 4K context
Inconsistent JSON outputUse with_structured_output() instead of text parsing
Over-engineered promptsStart simple; complexity has diminishing returns
No error handling on LLM callsWrap in retry with exponential backoff
Hardcoded prompts in codeStore in version-controlled YAML/JSON files

Production Checklist

  • Retry logic with exponential backoff (transient API errors)
  • Token usage logging per request
  • Prompt version tracked in metadata
  • Latency P50/P95/P99 monitored
  • Fallback behavior when retrieval returns nothing
  • PII scrubbing before sending to external APIs

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.