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

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.

agentmods
npx agentmods add skills/kouroshez/coding-os/llm-patterns
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.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.svg" alt="Measured on agentmods" 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. Scan, not verified.
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 $0.00135 $0.04160
Opus 5 $0.00068 $0.02080
Sonnet 5 $0.00027 $0.00832
Haiku 4.5 $0.00014 $0.00416

Measured 3d ago against content hash 2882a5494987, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 3d 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. 3d 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 (6 stars, last pushed 3d ago), licensed Apache-2.0. It adds 135 tokens to every session and 4,160 once invoked, about $0.0007 per session on Opus 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

graph-mutation-plan

Cookbook for composing an applygraphmutations plan — stable entitykey patterns, the canonical label/edge vocabulary, evidence/invalidation/confidence discipline, and a worked example. Load this when building a non-trivial mutation plan.

potpie-ai/potpie · 51 tokens

potpie-infra-architecture

Use for project infra and architecture context: environments, adapters, runtime configuration, deployments, service dependencies, datastores, API contracts, ownership, incidents, and dependency blast radius.

potpie-ai/potpie · 43 tokens

alfworld-receptacle-finder

Searches for a suitable empty or appropriately occupied receptacle (like a shelf or table) to place an object. Use when you are holding an object that needs to be stored or placed and must find a receptacle that meets the placement criteria. Examines candidate receptacles by navigating to and inspecting each one until…

zjunlp/SkillNet · 76 tokens

alfworld-search-pattern-executor

Systematically searches a sequence of likely locations for a target object based on common sense. Use when you need to find a specific object and know which receptacles to check but not which one contains it. Takes a list of candidate receptacles, orchestrates navigation and inspection, and outputs when the target is…

zjunlp/SkillNet · 74 tokens

ux-ui-analyze-single-page

Analyze exactly one captured UI page (from uxuimap screenshots + request JSON) and immediately write/update uxuimap/pages/{page}.md in neutral descriptive language. Use when asked to analyze screenshots, rewrite corresponding analysis immediately, or avoid memory/context saturation.

raphaelmansuy/edgequake · 58 tokens

scienceworld-growth-focuser

Use when you have planted a seed or need to track a plant's growth stage (sprouting, flowering, reproduction). Applies the 'focus on' action to a specific plant or biological entity to signal intent and monitor its development. Trigger after planting or when you need to observe life cycle progression in the…

zjunlp/SkillNet · 71 tokens