env-vars

env-vars is a cursor rule for Cursor from maccman/ai-monorepo-scaffold. It costs 12 tokens per session (1,261 once invoked), scanned A, original, MIT.

A project rule explaining how Astro applications define and use environment variables. Environment variables are configuration values supplied outside the source code, often including private secrets.

In plain words
What is it for?
Use it when adding variables such as database URLs, webhook keys, or public API URLs to an Astro project and importing them in the correct environment.
Why use it?
It separates server-only secrets from values that browser code may access, reducing the risk of exposing private configuration.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when adding variables such as database URLs, webhook keys, or public API URLs to an Astro project and importing them in the correct environment.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/maccman/ai-monorepo-scaffold/env-vars
Install

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.

Clone the repo
git clone --depth 1 https://github.com/maccman/ai-monorepo-scaffold

Made for: Cursor.

Wrote 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.

agentmods badge for env-vars

README.md
[![agentmods](https://agentmods.dev/badge/rules/maccman/ai-monorepo-scaffold/env-vars/github.svg)](https://agentmods.dev/rules/maccman/ai-monorepo-scaffold/env-vars)
Your own site
<a href="https://agentmods.dev/rules/maccman/ai-monorepo-scaffold/env-vars"><img src="https://agentmods.dev/badge/rules/maccman/ai-monorepo-scaffold/env-vars/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.

agentmods 80×15 button for env-vars

Your own site · 80×15
<a href="https://agentmods.dev/rules/maccman/ai-monorepo-scaffold/env-vars"><img src="https://agentmods.dev/badge/rules/maccman/ai-monorepo-scaffold/env-vars.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 12 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,261 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00012 $0.01261
Opus 5 $0.00006 $0.00630
Sonnet 5 $0.00002 $0.00252
Haiku 4.5 $0.00001 $0.00126

Measured 9d ago against content hash bc6a33a52e59, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

env-vars 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 9d 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.

.cursor/rules/env-vars.mdc · 154 lines

How it starts

The opening of the file, as written. The whole thing — 154 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Environment Variables (Astro Way): Astro provides type-safe environment variables. Follow these steps:

**1. Define in astro.config.ts:**
```typescript
// astro.config.ts
env: {
  schema: {
    MY_ENV_VAR: envField.string({
      context: 'server',  // 'server' or 'client'
      access: 'secret',   // 'secret' or 'public'
      optional: false,    // true if the variable is optional
    }),
    PUBLIC_API_URL: envField.string({
      context: 'client',
      access: 'public',
      optional: false,
    }),
  },
},
```

**2. Import and use in your code:**
```typescript
// Server-side variables (access: 'secret', context: 'server')
import { DATABASE_URL, MAILGUN_WEBHOOK_SIGNING_KEY } from 'astro:env/server'

// Client-side variables (access: 'public', context: 'client')
import { LIVEKIT_API_KEY } from 'astro:env/client'
```

**Key guidelines:**
- **Server variables** (`context: 'server'`): Only accessible in server-side code, import from `astro:env/server`
- **Client variables** (`context: 'client'`): Accessible in both client and server code, import from `astro:env/client`
- **Secret variables** (`access: 'secret'`): Should never be exposed to the client
- **Public variables** (`access: 'public'`): Can be safely exposed to the client
- All environment variables are type-safe and validated at build time
- Ignore linter errors on recently created env vars. Astro needs to rerun its dev server to update its internal types references first.

**Example usage:**
```typescript
// apps/web/src/server/db.ts
import { setupDb } from '@app/db'
import { DATABASE_URL } from 'astro:env/server'

export const db = setupDb({
  connectionString: DATABASE_URL,
})
```

Passing Environment Variables to tRPC: To make environment variables available in tRPC procedures, follow this pattern:

**1. Define the Env interface in context.ts:**
```typescript
// packages/api/src/context.ts
export interface Env {
  appEndpoint: string
  gcsProjectId: string
  ...
}

export interface Context {
  db: Kysely<DB>
  env: Env
  session: Session | null
  user: SelectableUser | null
}
```

**2. Pass environment variables in the tRPC handler:**
```typescript
// apps/web/src/pages/api/trpc/[trpc].ts
import { LIVEKIT_API_KEY } from 'astro:env/client'
import {
  GCS_BUCKET,
  GCS_CLIENT_EMAIL,
  GCS_PRIVATE_KEY,
  GCS_PROJECT_ID,
  GEMINI_API_KEY,
  LIVEKIT_API_SECRET,
  LIVEKIT_URL,
  PERPLEXITY_API_KEY,
} from 'astro:env/server'

async function createContext({ req }: CreateContextOptions): Promise<Context> {
  const env: Env = {
    appEndpoint: getAppEndpoint(req),
    gcsProjectId: GCS_PROJECT_ID,
   ...
  }

  return { db, session: session ?? null, env, user }
}
```

**3. Access environment variables in tRPC procedures:**
```typescript
// In any tRPC procedure
export const myProcedure = protectedProcedure
  .input(z.object({ /* ... */ }))
  .mutation(async ({ ctx, input }) => {
    // Access env vars through ctx.env
    const gcsProjectId = ctx.env.gcsProjectId
    // ... use the environment variables
  })
```

**Key guidelines for tRPC env vars:**
- Always define new env vars in the `Env` interface in `context.ts`
- Import env vars from Astro's env system in the tRPC handler
- Map them to the `env` object in `createContext`
- Access them via `ctx.env` in any tRPC procedure
- This ensures type safety and centralized env var management

Build and CI Configuration: When adding new environment variables, you must also update build and CI configuration files:

**1. Update turbo.json:**
Add new environment variables to the `env` array under the `build` task so Turborepo can properly cache builds:
```json
// turbo.json
{
  "tasks": {
    "build": {
      "outputs": ["dist/**"],
      "dependsOn": ["^build"],
      "env": [
        "DATABASE_URL",
        "AUTH_SECRET",
        "MY_NEW_ENV_VAR",   // Add your new env var here
        // ... other env vars
      ]
    }
  }
}
```

Read the full file on GitHub · 154 lines

Changes

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.

  1. 9d ago First seen · 154 lines · 12 tokens per session scan A bc6a33a52e59

Subscribe to this mod's changes

env-vars is a cursor rule published in the GitHub repository maccman/ai-monorepo-scaffold (304 stars, last pushed 10mo ago), licensed MIT. It adds 12 tokens to every session and 1,261 once invoked, about $0.0001 per session on Opus 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-08-30.