Skip to main content
rule CX Codex

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

llm-layer pins the conventions for model-provider code: the LLMProvider interface, config lookup, seat-based handling and usage tracking. Scoped to src/llm/**.

MIT ★ 1,319 updated 2026-09-24

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/llm-layer.mdc
Open on GitHub

What llm-layer does

The rule holds the conventions for code under src/llm/**, the part of the project that talks to model providers. A provider implements LLMProvider from src/llm/types.ts with call(), stream() and an optional listModels(). Settings resolve through src/llm/config.ts: environment variables first, then ~/.caliber/config.json.

Seat-based providers (cursor and claude-cli) are marked by isSeatBased(), and validateModel() is not applied to them. Cursor is launched as agent --print --trust --workspace /tmp in src/llm/cursor-acp.ts. The rest of the map: getFastModel() for the fast model, src/llm/model-recovery.ts for recovery, src/llm/seat-based-errors.ts for errors, trackUsage() from src/llm/usage.ts.

The frontmatter sets globs: src/llm/**, so the rule only fires inside that folder. Edits elsewhere in the repo get no guidance from it.

What it helps with

  • add a new provider without breaking existing ones
  • trace whether a setting comes from env or ~/.caliber/config.json
  • tell a seat-based provider from a regular one
  • hook usage tracking into a provider with trackUsage()
  • recover a model after a provider error

Example prompts for the agent

  • Add an openrouter provider under src/llm/ that implements LLMProvider with call() and stream()
  • Why does validateModel() skip cursor? Read src/llm/types.ts
  • Wire trackUsage() into the new provider

How to install llm-layer

Manually: put the files in place

.cursor/rules/llm-layer.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about llm-layer

How do I install llm-layer in Claude Code?

Place the rule file at .claude/rules/llm-layer.md.

What does llm-layer do?

It sets the conventions for provider code in src/llm/**: the LLMProvider interface, where config comes from and how usage tracking is wired.

Do seat-based providers go through model validation?

validateModel() does not run against them. isSeatBased() in src/llm/types.ts marks them, and the rule names cursor and claude-cli as the seat-based ones.

Source text

llm-layer.mdc · MIT
---
description: LLM provider implementation patterns
globs: src/llm/**
---

- 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, claude-cli)
- Cursor: `agent --print --trust --workspace /tmp` in `src/llm/cursor-acp.ts`
- Fast model: `getFastModel()` in `src/llm/config.ts`
- Model recovery: `src/llm/model-recovery.ts` · Errors: `src/llm/seat-based-errors.ts`
- Usage: `trackUsage()` from `src/llm/usage.ts`
- `validateModel()` skips seat-based providers

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

Similar IDE rules

All IDE rules for AI and ML →

From the same set17

The whole set →
caliber-onboarding caliber-onboarding — a rule for Claude Code and Codex that checks whether Caliber configs are synced before the agent responds to your first message. If sync is not set up, it offers to run /setup-caliber in about 30 seconds. CX Codex +1 ★ 1,319repo stars 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 llm-patterns 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. 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

More in the catalog

Project sponsors

Companies that keep this analytics open