Skip to main content
rule CX Codex

llm-patterns — Claude Code rule: what it does, how to install

The llm-patterns rule sets patterns for LLM providers in a project. Use it when provider interfaces, model settings, CLI errors, or streamed responses need consistent handling.

MIT ★ 1,319 updated 2026-09-24

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/llm-patterns.md
Open on GitHub

What llm-patterns does

The rule targets src/llm/**. It defines the expected LLMProvider shape with call() and stream(), plus an optional listModels(). Configuration flows from environment variables through src/llm/config.ts into ~/.caliber/config.json.

It also covers seat-based providers: isSeatBased() lets cursor and claude-cli bypass validateModel(). Cursor runs through agent --print --trust --workspace /tmp. The fast-model helper is getFastModel(), while ANTHROPIC_SMALL_FAST_MODEL is scoped to anthropic, vertex, and claude-cli.

Recovery for a missing model lives in src/llm/model-recovery.ts and can use an interactive fallback. Usage goes through trackUsage(), CLI stderr is parsed by src/llm/seat-based-errors.ts, and JSON handling uses extractJson() with parseJsonResponse(). The Claude Code installation path is .claude/rules/llm-patterns.md.

What it helps with

  • define a shared LLM provider contract
  • keep model settings in the expected config flow
  • skip model validation for seat-based providers
  • recover when a selected model is missing
  • parse CLI errors and JSON responses

Example prompts for the agent

  • Review the provider code under src/llm/** against this rule.
  • Add a provider with call() and stream(), and decide whether it needs listModels().
  • Handle a missing model, usage tracking, and JSON parsing using the project patterns.

How to install llm-patterns

Manually: put the files in place

.claude/rules/llm-patterns.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about llm-patterns

How do I install llm-patterns in Claude Code?

Add the rule file at .claude/rules/llm-patterns.md. It applies to files under src/llm/**.

What does llm-patterns do?

It documents the project conventions for LLM providers, configuration, model selection, recovery after provider errors, usage tracking, and JSON parsing.

How are seat-based providers handled?

isSeatBased() identifies them. The cursor and claude-cli providers skip validateModel() under this rule.

Source text

llm-patterns.md · MIT
---
paths:
  - src/llm/**
---

# LLM Provider Patterns

- Providers implement `LLMProvider` from `src/llm/types.ts`: `call()`, `stream()`, optional `listModels()`
- Config: env vars → `~/.caliber/config.json` via `src/llm/config.ts`
- Seat-based: `isSeatBased()` in `src/llm/types.ts` — `cursor` and `claude-cli` skip `validateModel()`
- Cursor: `agent --print --trust --workspace /tmp` in `src/llm/cursor-acp.ts`
- Fast model: `getFastModel()` in `src/llm/config.ts` — `ANTHROPIC_SMALL_FAST_MODEL` scoped to anthropic/vertex/claude-cli
- Model recovery: `src/llm/model-recovery.ts` handles not-found with interactive fallback
- Usage: `trackUsage()` from `src/llm/usage.ts`
- Errors: `src/llm/seat-based-errors.ts` parses stderr from CLI providers
- JSON: `extractJson()`, `parseJsonResponse()` in `src/llm/utils.ts`

© caliber-ai-org · MIT · caliber-ai-org/ai-setup

Similar IDE rules

All IDE rules for Agent setup: memory, context, orchestration →

From the same set17

The whole set →
testing Defines Vitest testing patterns for Caliber, enforcing colocated test suites, environment isolation, and global LLM mocks. CX Codex +1 ★ 1,319repo stars caliber-conventions The caliber-conventions rule sets conventions for Caliber TypeScript CLI development. Use it to guide an agent working on project code, tests, and commits. CX Codex +1 ★ 1,319repo stars testing-patterns testing-patterns is a Claude Code rule for Vitest conventions: test locations, LLM mocks, and running a single spec. CX Codex +1 ★ 1,319repo stars scoring-patterns scoring-patterns defines coding rules for the src/scoring/** directory. It keeps scoring checks deterministic without external network calls or random values. CX Codex +1 ★ 1,319repo stars caliber-pre-commit caliber-pre-commit — a commit-time rule: it checks for the Caliber git hook and, when the hook is absent, syncs and stages your agent config files. CX Codex +1 ★ 1,319repo stars find-skills find-skills discovers community skills from the Caliber registry and installs them directly into your coding session. CX Codex +1 ★ 1,319repo stars save-learning save-learning turns a user's lasting preferences into project learnings. Use it when an agent should carry a rule from one session into the next. CX Codex +1 ★ 1,319repo stars setup-caliber setup-caliber walks a project through Caliber setup: installs the CLI, hooks agent config sync into every commit, and creates the config files your agents are missing. CX Codex +1 ★ 1,319repo stars

Project sponsors

Companies that keep this analytics open