environment_variable

A code rule that requires all environment-variable access to go through one backend constants file. Environment variables are settings supplied outside the program, such as API keys or configuration values.

In plain words
What is it for?
Adding environment variables, updating the example configuration, and passing settings from the backend into services and SDKs.
Why use it?
It prevents configuration reads from being scattered throughout the code and makes settings easier to find, change, and audit.

Cursor rule for Cursor

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.

agentmods
npx agentmods add rules/modelengine-group/nexent/environment_variable
Clone the repo
git clone --depth 1 https://github.com/ModelEngine-Group/nexent

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 408 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00000 $0.00408
Opus 5 $0.00000 $0.00204
Sonnet 5 $0.00000 $0.00082
Haiku 4.5 $0.00000 $0.00041

Measured yesterday against content hash 453c1fecf886, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

environment_variable 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 yesterday.

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/environment_variable.mdc · 47 lines

What it actually says

Environment Variables: Single Source of Truth

All environment variable access must go through backend/consts/const.py. No direct os.getenv() or os.environ.get() calls elsewhere.

Do

# backend/consts/const.py
APPID = os.getenv("APPID", "")
TOKEN = os.getenv("TOKEN", "")

# other modules
from consts.const import APPID, TOKEN

Don't

# direct calls in other modules
import os
appid = os.getenv("APPID")
token = os.environ.get("TOKEN")

Architecture

  • Single source: Only backend/consts/const.py may read env vars.
  • SDK (sdk/): Never read env. Accept configuration via parameters. Remove from_env().
  • Services (backend/services/): Read from consts.const; pass config to SDK.
  • Apps (backend/apps/): Read from consts.const; pass through to services/SDK. No business logic here.

Migration checklist

  1. Add new vars to backend/consts/const.py.
  2. Update .env.example.
  3. Remove all direct os.getenv()/os.environ.get() outside const.py.
  4. Import from consts.const in backend modules.
  5. Pass configuration as parameters to SDK.
  6. Remove from_env() methods from config classes.
  7. Update service constructors to read from const.py.

Validation

  • No direct env access outside const.py.
  • No from_env() in config classes.
  • All env vars defined in const.py.
  • SDK modules accept configuration via parameters.
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. yesterday First seen · 47 lines · 0 tokens per session scan A 453c1fecf886

Subscribe to this mod's changes

environment_variable is a cursor rule published in the GitHub repository ModelEngine-Group/nexent (5,841 stars, last pushed 3d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 408 tokens. 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.