LLM Patterns

LLM Patterns is a skill for Claude Code, Codex from sergei-aronsen/claude-code-toolkit. It costs 34 tokens per session (2,415 once invoked), scanned A, original, MIT.

A guide to integrating large language models, including retrieval-augmented generation (RAG), embeddings, streaming responses, and tool use. RAG lets a model answer using relevant information retrieved from your own data.

In plain words
What is it for?
Use it when building RAG systems, vector search, embeddings, streamed model responses, model selection, classification, or integrations where the model calls tools.
Why use it?
It helps address unreliable error handling, excessive token costs, poor model choices, and fragile AI integrations.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Good fit Use it when building RAG systems, vector search, embeddings, streamed model responses, model selection, classification, or integrations where the model calls tools.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/sergei-aronsen/claude-code-toolkit/llm-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 sergei-aronsen/claude-code-toolkit --skill llm-patterns
Clone the repo
git clone --depth 1 https://github.com/sergei-aronsen/claude-code-toolkit

Made for: Claude Code, Codex.

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 LLM Patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/sergei-aronsen/claude-code-toolkit/llm-patterns/github.svg)](https://agentmods.dev/skills/sergei-aronsen/claude-code-toolkit/llm-patterns)
Your own site
<a href="https://agentmods.dev/skills/sergei-aronsen/claude-code-toolkit/llm-patterns"><img src="https://agentmods.dev/badge/skills/sergei-aronsen/claude-code-toolkit/llm-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 LLM Patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/sergei-aronsen/claude-code-toolkit/llm-patterns"><img src="https://agentmods.dev/badge/skills/sergei-aronsen/claude-code-toolkit/llm-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,415 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.
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.00034 $0.02415
Opus 5.5 $0.00014 $0.00966
Sonnet 5.5 $0.00007 $0.00483
Haiku 4.5 $0.00003 $0.00242

Measured 1mo ago against content hash adb961619bd7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

LLM 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 1mo ago.

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.

templates/base/skills/llm-patterns/SKILL.md · 406 lines

How it starts

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

LLM Patterns Skill

Load this skill when working with LLMs, RAG systems, embeddings, or AI integrations.


Rule

LLM INTEGRATIONS MUST BE ROBUST AND COST-EFFECTIVE!

  • Always handle streaming and errors
  • Optimize tokens for cost
  • Use appropriate models for tasks

Model Selection Guide

Task Model Why
Complex reasoning Claude Opus 4.5 / GPT-4 Best quality
General tasks Claude Sonnet 4.5 / GPT-4o Balance
Simple tasks Claude Haiku 4.5 / GPT-4o-mini Fast & cheap
Embeddings text-embedding-3-small Cost-effective
Classification Fine-tuned small model Fastest

RAG Architecture

Basic RAG Flow

Query → Embed Query → Vector Search → Retrieve Chunks → Augment Prompt → LLM → Response

Implementation

async function ragQuery(query: string): Promise<string> {
  // 1. Embed the query
  const queryEmbedding = await embedText(query);

  // 2. Vector search for relevant chunks
  const chunks = await vectorStore.similaritySearch(queryEmbedding, {
    topK: 5,
    minScore: 0.7,
  });

  // 3. Build context from chunks
  const context = chunks.map((c) => c.content).join('\n\n---\n\n');

  // 4. Augment prompt
  const prompt = `Answer based on the following context:

Context:
${context}

Question: ${query}

Answer:`;

  // 5. Get LLM response
  return await llm.complete(prompt);
}

Chunking Strategies

Size Guidelines

Document Type Chunk Size Overlap
Dense text (legal, technical) 256-512 tokens 50 tokens
General content 512-1024 tokens 100 tokens
Conversational 1024-2048 tokens 200 tokens

Chunking Methods

// 1. Fixed size chunking
function fixedChunks(text: string, size: number, overlap: number): string[] {
  const chunks = [];
  for (let i = 0; i < text.length; i += size - overlap) {
    chunks.push(text.slice(i, i + size));
  }
  return chunks;
}

// 2. Semantic chunking (by paragraph/section)
function semanticChunks(text: string): string[] {
  return text
    .split(/\n\n+/)
    .filter((chunk) => chunk.trim().length > 50);
}

// 3. Recursive character splitting (LangChain style)
const splitter = new RecursiveCharacterTextSplitter({
  chunkSize: 1000,
  chunkOverlap: 200,
  separators: ['\n\n', '\n', '. ', ' ', ''],
});

Read the full file on GitHub · 406 lines

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. 1mo ago First seen · 406 lines · 34 tokens per session scan A adb961619bd7

Subscribe to this mod's changes

LLM Patterns is a skill published in the GitHub repository sergei-aronsen/claude-code-toolkit (5 stars, last pushed 2mo ago), licensed MIT. It adds 34 tokens to every session and 2,415 once invoked, about $0.0001 per session on Opus 5.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-08-31.