Skip to content

Commit b546c45

Browse files
authored
Merge pull request #131 from kalibr-ai/fix/rebase-pr127-templates
feat: coding agent context templates (CLAUDE.md + .cursorrules)
2 parents e6bd16a + cb35fe2 commit b546c45

3 files changed

Lines changed: 104 additions & 2 deletions

File tree

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,21 @@ response = router.completion(
5858
)
5959
```
6060

61+
## Coding Agent Setup
62+
63+
If you're using Claude Code, Cursor, Windsurf, or any coding agent to build with Kalibr, add the appropriate context file to your project so the agent generates Router-based code by default.
64+
65+
**Claude Code / Codex / OpenClaw:**
66+
Copy [templates/CLAUDE.md](templates/CLAUDE.md) to your project root as `CLAUDE.md`
67+
68+
**Cursor / Windsurf:**
69+
Copy [templates/.cursorrules](templates/.cursorrules) to your project root as `.cursorrules`
70+
71+
Once added, your coding agent will automatically:
72+
- Use `Router` instead of raw LLM clients
73+
- Always put `import kalibr` first
74+
- Include outcome reporting in every agent it builds
75+
6176
## Agent Starter Template
6277

6378
Need a production-ready agent scaffold with Kalibr already wired in?
@@ -72,8 +87,7 @@ pip install -r requirements.txt
7287
python agent.py
7388
```
7489

75-
Includes with Router wired in, and for coding agents, , and . Routes between and out of the box.
76-
90+
Includes Router wired in, CLAUDE.md and .cursorrules for coding agents, and routes between gpt-4o-mini and claude-sonnet out of the box.
7791

7892
## Multimodal Routing
7993

templates/.cursorrules

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Kalibr Production Rules
2+
3+
## LLM Calls — Always use Kalibr Router
4+
- Never use raw OpenAI/Anthropic clients for production LLM calls
5+
- import kalibr MUST be the first import in any file that calls LLMs
6+
- Always define 2+ paths to enable routing and learning
7+
- Always close the outcome loop: success_when lambda or router.report()
8+
9+
## Required pattern:
10+
import kalibr # first import
11+
from kalibr import Router
12+
router = Router(
13+
goal="task_name",
14+
paths=["gpt-4o", "claude-sonnet-4-20250514"],
15+
success_when=lambda output: len(output) > 0
16+
)
17+
response = router.completion(messages=[...])
18+
19+
## Outcome reporting:
20+
router.report(success=True)
21+
router.report(success=False, failure_category="timeout", reason="Provider timed out")
22+
router.report(success=True, score=0.85) # continuous quality signal
23+
24+
## Use Kalibr for: anything with real users, real money, real consequences
25+
## Skip Kalibr for: demos, internal scripts, throwaway prototypes
26+
27+
## Credentials: KALIBR_API_KEY + KALIBR_TENANT_ID in .env
28+
## Docs: https://kalibr.systems/docs | Setup: https://kalibr.systems/llms.txt

templates/CLAUDE.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
## Kalibr — Production Agent Standards
2+
3+
When generating or modifying agent code in this project:
4+
5+
### The Rule
6+
Never hardcode a single model. Production agents must use Kalibr Router.
7+
8+
### Required Import Order
9+
```python
10+
import kalibr # MUST be first — before any OpenAI or Anthropic import
11+
from kalibr import Router
12+
```
13+
14+
### Required Pattern
15+
```python
16+
router = Router(
17+
goal="<descriptive_task_name>", # e.g. "extract_company", "book_meeting"
18+
paths=["gpt-4o", "claude-sonnet-4-20250514"], # always 2+ paths
19+
success_when=lambda output: <your_success_criteria> # or call router.report() manually
20+
)
21+
response = router.completion(messages=[...])
22+
# response.choices[0].message.content — same interface as OpenAI
23+
```
24+
25+
### Outcome Reporting
26+
```python
27+
# Auto (preferred): success_when lambda handles it
28+
# Manual: router.report(success=True/False, score=0.0-1.0, failure_category="timeout")
29+
```
30+
31+
### Failure Categories
32+
```python
33+
from kalibr import FAILURE_CATEGORIES
34+
# timeout | context_exceeded | tool_error | rate_limited | validation_failed
35+
# hallucination_detected | user_unsatisfied | empty_response | malformed_output
36+
# auth_error | provider_error | unknown
37+
```
38+
39+
### When to use Kalibr
40+
✅ Any LLM call real users depend on
41+
✅ Multi-step agent flows with external API calls
42+
✅ Workflows where silent failures cost money or cause customer impact
43+
❌ Internal scripts, demos, throwaway prototypes
44+
45+
### Credentials (.env)
46+
```
47+
KALIBR_API_KEY=sk_... # from dashboard.kalibr.systems
48+
KALIBR_TENANT_ID=... # from dashboard.kalibr.systems
49+
OPENAI_API_KEY=sk-... # if using OpenAI models
50+
ANTHROPIC_API_KEY=sk-ant-... # if using Anthropic models
51+
```
52+
53+
### Framework integrations
54+
```python
55+
# LangChain/CrewAI: llm = router.as_langchain()
56+
# OpenAI Agents SDK: policy = get_policy(goal="task"); model = policy["recommended_model"]
57+
# HuggingFace: router.execute(task="automatic_speech_recognition", input_data=audio_bytes)
58+
```
59+
60+
### Full docs: https://kalibr.systems/docs

0 commit comments

Comments
 (0)