gateway / rules
Cursor rule608 starsChanged 8 months agoMITView on GitHub
The provider package defines the core interfaces and base classes that all AI providers must implement. It provides a unified abstraction layer for different AI services.
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/gateway.mdcCursor rule
- .cursor/rules/main.mdcCursor rule
- .cursor/rules/providers.mdcCursor rule
- .cursor/rules/types.mdcCursor rule
- add-modelSkill
- review-providerSkill
The file
Show its rules and text
We split this provider.mdc into the rules it gives an agent
17 rules. About 0 are common, 16 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈16
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
ALWAYS: use generic constraints for configuration types
- Distinctive: line 20
ALWAYS: use descriptive provider names
- Distinctive: line 53
ALWAYS: use Zod schemas for model configuration validation
- Distinctive: line 63
ALWAYS: use Zod for configuration validation
- Very specific: line 71
ALWAYS: use descriptive type names ending with OptionsType
- Distinctive: line 73
ALWAYS: use union types for model-specific options
- Distinctive: line 114
ALWAYS: test provider instantiation with valid configurations
- Distinctive: line 115
ALWAYS: test provider instantiation with invalid configurations
- Distinctive: line 116
ALWAYS: test model factory methods
- Distinctive: line 117
ALWAYS: test error handling scenarios
- Distinctive: line 122
ALWAYS: test model instantiation with valid options
- Distinctive: line 123
ALWAYS: test model instantiation with invalid options
- Distinctive: line 124
ALWAYS: test response transformation methods
- Distinctive: line 125
ALWAYS: test error handling for API failures
- Distinctive: line 126
ALWAYS: test configuration validation
- Distinctive: line 133
ALWAYS: use connection pooling for HTTP clients
- Distinctive: line 149
ALWAYS: never log API keys or sensitive credentials
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
--- globs: packages/provider/** alwaysApply: false --- # Provider Package Rules ## Package Overview The provider package defines the core interfaces and base classes that all AI providers must implement. It provides a unified abstraction layer for different AI services. ## Provider Interface Rules ### 1. ProviderV1 Interface - **ALWAYS** implement the `ProviderV1` interface for new providers - **ALWAYS** use generic constraints for configuration types - **ALWAYS** provide both chat and embedding model support - **ALWAYS** implement version tracking with `readonly version = "v1"` - **ALWAYS** use descriptive provider names ### 2. Model Factory Methods - **ALWAYS** implement `chatModelLiterals()` returning available model names - **ALWAYS** implement `chatModelSchemas()` returning Zod schemas - **ALWAYS** implement `chatModel(options)` returning configured instances - **ALWAYS** implement `embeddingModelLiterals()` returning available model names - **ALWAYS** implement `embeddingModelSchemas()` returning Zod schemas - **ALWAYS** implement `embeddingModel(options)` returning configured instances ## Model Implementation Rules ### 1. Chat Model Implementation - **ALWAYS** implement the `ChatModelV1` interface - **ALWAYS** provide model schema with name, provider, and capabilities - **ALWAYS** implement `completeChat()` method for synchronous responses - **ALWAYS** implement `streamChat()` method for streaming responses - **ALWAYS** implement `getModelPricing()` for cost calculation - **ALWAYS** implement `getCompleteChatUrl()`, `getCompleteChatHeaders()`, `getCompleteChatData()` - **ALWAYS** implement `transformCompleteChatResponse()` for response normalization ### 2. Embedding Model Implementation - **ALWAYS** implement the `EmbeddingModelV1` interface - **ALWAYS** provide model schema with name, provider, and capabilities - **ALWAYS** implement `getEmbeddings()` method - **ALWAYS** implement `getEmbeddingsUrl()`, `getEmbeddingsHeaders()`, `getEmbeddingsData()` - **ALWAYS** implement `transformEmbeddingsResponse()` for response normalization ### 3. Model Schema Definition - **ALWAYS** use Zod schemas for model configuration validation - **ALWAYS** include model name, provider, and version information - **ALWAYS** define input/output token limits - **ALWAYS** specify supported features (streaming, tools, etc.) - **ALWAYS** include pricing information when available ## Configuration Management Rules ### 1. Configuration Schemas - **ALWAYS** use Zod for configuration validation - **ALWAYS** provide sensible defaults for optional parameters - **ALWAYS** validate API keys and endpoints - **ALWAYS** support environment variable overrides - **ALWAYS** include configuration examples in documentation ### 2. Configuration Types - **ALWAYS** use descriptive type names ending with `OptionsType` - **ALWAYS** extend base configuration interfaces when appropriate - **ALWAYS** use union types for model-specific options - **ALWAYS** provide configuration builders for complex setups ## Error Handling Rules ### 1. Provider Errors - **ALWAYS** extend `ProviderError` for provider-specific errors - **ALWAYS** include provider name and context in error messages - **ALWAYS** handle API rate limits and quotas gracefully - **ALWAYS** provide retry guidance when appropriate - **ALWAYS** log errors with full context ### 2. Validation Errors - **ALWAYS** validate configuration before making API calls - **ALWAYS** provide clear error messages for invalid configurations - **ALWAYS** suggest fixes for common configuration issues - **ALWAYS** validate model options before instantiation ## Response Transformation Rules ### 1. Chat Response Transformation - **ALWAYS** normalize provider responses to standard format - **ALWAYS** handle different response structures consistently - **ALWAYS** preserve all relevant information from provider - **ALWAYS** implement proper error handling for malformed responses - **ALWAYS** support streaming response transformation ### 2. Embedding Response Transformation - **ALWAYS** normalize embedding vectors to standard format - **ALWAYS** handle different vector dimensions consistently - **ALWAYS** preserve metadata and usage information - **ALWAYS** implement proper error handling for malformed responses ## Testing Rules ### 1. Provider Testing - **ALWAYS** test provider instantiation with valid configurations - **ALWAYS** test provider instantiation with invalid configurations - **ALWAYS** test model factory methods - **ALWAYS** test error handling scenarios - **ALWAYS** mock external API calls ### 2. Model Testing - **ALWAYS** test model instantiation with valid options - **ALWAYS** test model instantiation with invalid options - **ALWAYS** test response transformation methods - **ALWAYS** test error handling for API failures - **ALWAYS** test configuration validation ## Performance Considerations ### 1. Resource Management - **ALWAYS** implement proper cleanup for resources - **ALWAYS** use connection pooling for HTTP clients - **ALWAYS** implement request batching when possible - **ALWAYS** cache frequently used configurations ### 2. Error Recovery - **ALWAYS** implement exponential backoff for retries - **ALWAYS** implement circuit breakers for failing endpoints - **ALWAYS** provide fallback mechanisms when possible - **ALWAYS** monitor provider health and performance ## Security Considerations ### 1. API Key Management - **ALWAYS** validate API keys before use - **ALWAYS** never log API keys or sensitive credentials - **ALWAYS** support secure credential storage - **ALWAYS** implement proper access controls ### 2. Input Validation - **ALWAYS** validate all input parameters - **ALWAYS** sanitize user inputs before API calls - **ALWAYS** implement rate limiting for user requests - **ALWAYS** monitor for suspicious activity patterns ---
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

