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.
git clone --depth 1 https://github.com/PaulJPhilp/EffectPatternsWrote 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.
[](https://agentmods.dev/rules/pauljphilp/effectpatterns/configure-cors-for-apis)<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/configure-cors-for-apis"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/configure-cors-for-apis/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/configure-cors-for-apis"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/configure-cors-for-apis.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.01160 | $0.01160 |
| Opus 5.5 | $0.00464 | $0.00464 |
| Sonnet 5.5 | $0.00232 | $0.00232 |
| Haiku 4.5 | $0.00116 | $0.00116 |
Grade A, and why
configure-cors-for-apis scanned grade A with 0 findings 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 1mo ago.
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.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 189 lines — stays where its author put it; the contents beside it link to each section on GitHub.
description: Configure CORS headers to allow legitimate cross-origin requests while blocking unauthorized ones. globs: "**/*.ts" alwaysApply: true
Configure CORS for APIs
Rule: Configure CORS headers to allow legitimate cross-origin requests while blocking unauthorized ones.
Example
import { Effect } from "effect"
import { HttpServerRequest, HttpServerResponse } from "@effect/platform"
// ============================================
// 1. CORS configuration
// ============================================
interface CorsConfig {
readonly allowedOrigins: ReadonlyArray<string> | "*"
readonly allowedMethods: ReadonlyArray<string>
readonly allowedHeaders: ReadonlyArray<string>
readonly exposedHeaders?: ReadonlyArray<string>
readonly credentials?: boolean
readonly maxAge?: number
}
const defaultCorsConfig: CorsConfig = {
allowedOrigins: "*",
allowedMethods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"],
allowedHeaders: ["Content-Type", "Authorization", "X-Request-Id"],
exposedHeaders: ["X-Request-Id", "X-Response-Time"],
credentials: false,
maxAge: 86400, // 24 hours
}
// ============================================
// 2. Check if origin is allowed
// ============================================
const isOriginAllowed = (
origin: string | undefined,
allowedOrigins: ReadonlyArray<string> | "*"
): boolean => {
if (!origin) return false
if (allowedOrigins === "*") return true
return allowedOrigins.includes(origin)
}
// ============================================
// 3. Add CORS headers to response
// ============================================
const addCorsHeaders = (
response: HttpServerResponse.HttpServerResponse,
origin: string | undefined,
config: CorsConfig
): HttpServerResponse.HttpServerResponse => {
let result = response
// Set allowed origin
if (config.allowedOrigins === "*") {
result = HttpServerResponse.setHeader(result, "Access-Control-Allow-Origin", "*")
} else if (origin && isOriginAllowed(origin, config.allowedOrigins)) {
result = HttpServerResponse.setHeader(result, "Access-Control-Allow-Origin", origin)
result = HttpServerResponse.setHeader(result, "Vary", "Origin")
}
// Set allowed methods
result = HttpServerResponse.setHeader(
result,
"Access-Control-Allow-Methods",
config.allowedMethods.join(", ")
)
// Set allowed headers
result = HttpServerResponse.setHeader(
result,
"Access-Control-Allow-Headers",
config.allowedHeaders.join(", ")
)
// Set exposed headers
if (config.exposedHeaders?.length) {
result = HttpServerResponse.setHeader(
result,
"Access-Control-Expose-Headers",
config.exposedHeaders.join(", ")
)
}
// Set credentials
if (config.credentials) {
result = HttpServerResponse.setHeader(
result,
"Access-Control-Allow-Credentials",
"true"
)
}
// Set max age for preflight cache
if (config.maxAge) {
result = HttpServerResponse.setHeader(
result,
"Access-Control-Max-Age",
String(config.maxAge)
)
}
return result
}
// ============================================
// 4. CORS middleware
// ============================================
const withCors = (config: CorsConfig = defaultCorsConfig) =>
<E, R>(
handler: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>
): Effect.Effect<
HttpServerResponse.HttpServerResponse,
E,
R | HttpServerRequest.HttpServerRequest
> =>
Effect.gen(function* () {
const request = yield* HttpServerRequest.HttpServerRequest
const origin = request.headers["origin"]
// Handle preflight OPTIONS request
if (request.method === "OPTIONS") {
const preflightResponse = HttpServerResponse.empty({ status: 204 })
return addCorsHeaders(preflightResponse, origin, config)
}
// Check if origin is allowed
if (
origin &&
config.allowedOrigins !== "*" &&
!isOriginAllowed(origin, config.allowedOrigins)
) {
return HttpServerResponse.json(
{ error: "CORS: Origin not allowed" },
{ status: 403 }
)
}
// Process request and add CORS headers to response
const response = yield* handler
return addCorsHeaders(response, origin, config)
})
// ============================================
// 5. Usage examples
// ============================================
// Allow all origins (development)
const devCors = withCors({
...defaultCorsConfig,
allowedOrigins: "*",
})
// Specific origins (production)
const prodCors = withCors({
allowedOrigins: [
"https://myapp.com",
"https://admin.myapp.com",
],
allowedMethods: ["GET", "POST", "PUT", "DELETE"],
allowedHeaders: ["Content-Type", "Authorization"],
credentials: true,
maxAge: 3600,
})
// Apply to handlers
const myHandler = Effect.succeed(
HttpServerResponse.json({ message: "Hello!" })
)
const corsEnabledHandler = devCors(myHandler)
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.
- 1mo ago First seen · 189 lines · 1,160 tokens per session scan A a4ad7852cf8d
configure-cors-for-apis is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (807 stars, last pushed 4mo ago), licensed MIT. It adds 1,160 tokens to every session, about $0.0046 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other cursor rules, from other repositories
django-python
Rules for writing Python services at PostHog (Python servers powered by the Django framework).
python--typescript-guide-cursorrules-prompt-file
Cursor rules for Python development with TypeScript guide integration.
standard-nestjs-module-hierarchy
Establish a consistent NestJS module structure in the API application where each resource is encapsulated in its own module with proper hierarchical organization to enhance maintainability, scalabilit... .
nestjs-best-practices
../../.claude/rules/nestjs-best-practices.md.
nestjs
This guide provides opinionated, actionable best practices for building robust, scalable, and maintainable NestJS applications using TypeScript, emphasizing modern patterns and common pitfalls.
nestjs
ContextOS rules for nestjs.