llm-patterns

llm-patterns is a skill for Claude Code, Codex from kouroshez/coding-os. It costs 135 tokens per session (4,160 once invoked), scanned B, original, Apache-2.0.

A practical guide to building features powered by large language models (LLMs), such as chat, summarisation, search-based answers, and data extraction. It covers prompts, testing, safety checks, cost control, and multi-step AI workflows.

In plain words
What is it for?
Use it when designing an LLM feature, a retrieval-augmented generation system that searches documents before answering, an evaluation setup, safety rules, or an AI agent that uses tools.
Why use it?
LLM features can produce inconsistent, unsafe, expensive, or inaccurate results. This guide helps you design checks and tests for those problems.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when designing an LLM feature, a retrieval-augmented generation system that searches documents before answering, an evaluation setup, safety rules, or an AI agent that uses tools.

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

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/kouroshez/coding-os/llm-patterns/github.svg)](https://agentmods.dev/skills/kouroshez/coding-os/llm-patterns)
Your own site
<a href="https://agentmods.dev/skills/kouroshez/coding-os/llm-patterns"><img src="https://agentmods.dev/badge/skills/kouroshez/coding-os/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/kouroshez/coding-os/llm-patterns"><img src="https://agentmods.dev/badge/skills/kouroshez/coding-os/llm-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 135 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,160 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. 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.00135 $0.04160
Opus 5.5 $0.00054 $0.01664
Sonnet 5.5 $0.00027 $0.00832
Haiku 4.5 $0.00014 $0.00416

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

Security

Grade B, and why

llm-patterns scanned grade B with 1 finding 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.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/estimate_tokens.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Instruction-override phrasingmediumPrompt injection

Text telling the model to disregard its earlier instructions or safety rules is the shape of a prompt injection, whoever wrote it.

The model knows to treat `<article>` as the document and `<question>` as the instruction. Crucially this also defends against **prompt injection** (a malicious article saying "ignore previous instructions and …" is conta

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

src/core/skills/llm-patterns/SKILL.md · 411 lines

How it starts

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

LLM Patterns — Production-Grade AI Features

A practical playbook for shipping LLM-powered features that work reliably, cost-controllably, and don't hallucinate on critical paths. Provider-neutral; references Anthropic Claude Opus 4.7 / Sonnet 4.6 / Haiku 4.5 (2026 generation) and OpenAI as anchors.

When to Use This Skill

  • Designing a new LLM-powered feature (chat, summarization, classification, extraction, code-gen).
  • Building a RAG (Retrieval-Augmented Generation) system.
  • Writing an evaluation harness for an LLM feature.
  • Adding guardrails / safety / hallucination mitigation.
  • Choosing between provider / model tier / fine-tuning / prompt-only.
  • Designing an agentic loop (tool use, multi-turn planning).
  • Cost-optimizing a working LLM feature.

Skip when: implementing pure deterministic logic. Use this only when LLM truly outperforms rules-based code on the task.

The Eight Layer Stack

   Application                     ← UI, UX, error handling
   ─────────────────────────────
   Orchestration                   ← Tool loop, multi-step, retries
   ─────────────────────────────
   Guardrails                      ← Input validation, output filtering
   ─────────────────────────────
   Retrieval (RAG)                 ← Context fetching from KB
   ─────────────────────────────
   Prompt construction             ← System + context + question
   ─────────────────────────────
   Provider SDK                    ← anthropic, openai, etc.
   ─────────────────────────────
   Eval + Telemetry                ← Quality + cost + latency monitoring
   ─────────────────────────────
   Model                           ← Opus / Sonnet / Haiku / GPT-4o / etc.

Skipping any layer creates a failure mode. Skipping eval is the most common skip — and the most expensive.

Provider + Model Selection (2026 baseline)

Need Default Why
Complex reasoning, code architecture, long horizons claude-opus-4-8 Best reasoning, 1M context, most expensive
Production default — chat, summaries, code edits claude-sonnet-4-6 Strong reasoning, ~5× cheaper than Opus, 200K context
Cheap, fast classification / extraction / heuristics claude-haiku-4-5-20251001 Fast, cheap; fine for narrow tasks
Multi-modal vision (charts, screenshots, OCR) claude-sonnet-4-6 or gpt-4o Both vision-capable in 2026
Embeddings text-embedding-3-large (OpenAI) / voyage-3-large (Voyage) Anthropic doesn't ship embedding models — pair with one

Read the full file on GitHub · 411 lines

Files

What ships with it

3 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. 1mo ago First seen · 411 lines · 135 tokens per session scan B 2882a5494987

Subscribe to this mod's changes

llm-patterns is a skill published in the GitHub repository kouroshez/coding-os (7 stars, last pushed yesterday), licensed Apache-2.0. It adds 135 tokens to every session and 4,160 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it B with 1 finding (instruction-override phrasing). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

ontology-constraint-and-knowledge-injection

A method for deciding how an ontology’s knowledge should reach an AI model: directly in its instructions, through RAG, or through fine-tuning. RAG retrieves relevant information at answer time; fine-tuning changes the model using training examples.

SuperChason/ontology-driven-ai-data-management-skills · 100 tokens

dspy

DSPy: declarative LM programs, auto-optimize prompts, RAG.

NousResearch/hermes-agent · 19 tokens

ai-engineering-toolkit

Overview of six AI engineering workflows: prompt evaluation (8-dimension scoring), context budget planning, RAG pipeline design, agent security audit (65-point checklist), eval harness building, and product sense coaching.

sickn33/agentic-awesome-skills · 47 tokens

llm-app-patterns

Production-ready patterns for building LLM applications. Covers RAG pipelines, agent architectures, prompt IDEs, and LLMOps monitoring. Use when designing AI applications, implementing RAG, building agents, or setting up LLM observability.

davila7/claude-code-templates · 54 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

llm-ops

LLM Operations -- RAG, embeddings, vector databases, fine-tuning, prompt engineering avancado, custos de LLM, evals de qualidade e arquiteturas de IA para producao.

davila7/claude-code-templates · 44 tokens