ehs-ims-conventions

A set of development rules for an environmental, health, and safety management application. It covers permissions, database changes, API organization, and audit records.

In plain words
What is it for?
Use it when adding or changing database schemas, tRPC API procedures, role permissions, migrations, audit logging, or compliance-related features.
Why use it?
It keeps regulated data changes consistent, permission-checked, recorded, and backed by the project's PostgreSQL database.

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/safetymp/autonomous-ehs-management/ehs-ims-conventions
Clone the repo
git clone --depth 1 https://github.com/SafetyMP/Autonomous-EHS-Management

Made for: Cursor.

Per session 722 This file is loaded in full into every session.
When invoked 722 The same file — it is already loaded in full.
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.00722 $0.00722
Opus 5 $0.00361 $0.00361
Sonnet 5 $0.00144 $0.00144
Haiku 4.5 $0.00072 $0.00072

Measured 2d ago against content hash 1fed50f14e92, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

ehs-ims-conventions 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 2d 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/ehs-ims-conventions.mdc · 47 lines

How it starts

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

Autonomous EHS — agent & developer conventions

Single system of record

  • PostgreSQL + Drizzle is authoritative for commitments, statuses, approvals, and audit-relevant facts.
  • Never introduce “TypeScript-only” columns or tables: every schema change needs a Drizzle migration (npm run db:generate) and a deploy path.

RBAC

  • Permission keys live in src/lib/rbac.ts (PERMISSIONS). New procedures must call assertPermission (or equivalent) with the correct key.
  • Do not bypass RBAC for “internal” routes; agent/tool callers must use the same checks with a service identity if you add one later.

tRPC

  • Routers live under src/server/trpc/routers/. Register in src/server/trpc/root.ts.
  • Prefer clear procedure names: list, get, create, update, updateStatus — match existing routers (e.g. incident, capa, document).
  • Mutations that change regulated data should write audit_log via writeAuditLog where the codebase already does for other entities.
  • Compliance- or retention-affecting work (incident lifecycle, data_retention_policy, RAG PII, COMPLIANCE.md, compliance.* routers): follow .cursor/skills/corporate-compliance-data-governance/SKILL.md and the requestable rule compliance-data-governance.

Drizzle

  • Schema: src/server/db/schema.ts. Match naming and relation patterns already used (enums, updatedAt, FK onDelete).
  • After editing schema, run npm run db:generate and commit the new SQL under drizzle/migrations/.

Tests and risky areas

  • Do not change auth session shape, proxy/dashboard auth gating, or env validation without updating Vitest and smoke E2E expectations.
  • RBAC matrices and seed scripts: changing PERMISSIONS requires scripts/seed.ts / migration of permission rows for existing orgs.

AI / LLM (when added)

  • Structured outputs: validate model JSON against Zod schemas shared with or mirrored from API inputs — never trust free-form prose into the DB without parsing.
  • Tool use: assistants must call typed tRPC or internal server handlers, not ad-hoc SQL or filesystem paths.
  • Gateway: route all provider calls through src/lib/ai/gateway.ts (or successor); no scattered fetch to model APIs.
  • Safety: tie expensive AI routes to Upstash rate limits (src/server/ratelimit.ts). Redact PII in prompts and logs where required.
  • Human-in-the-loop: do not auto-close investigations, auto-verify CAPA effectiveness, or silently commit regulatory classification without product policy.

Read the full file on GitHub · 47 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. 2d ago First seen · 47 lines · 722 tokens per session scan A 1fed50f14e92

Subscribe to this mod's changes

ehs-ims-conventions is a cursor rule published in the GitHub repository SafetyMP/Autonomous-EHS-Management (5 stars, last pushed 2d ago), licensed Apache-2.0. It adds 722 tokens to every session, about $0.0036 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-31.