/eng:envfrom Engineering Skills
Environment configuration for Next.js apps, an API and workers — secrets in env and public per-tier facts in committed constants, `APP_ENV` as the tier, a Zod env guard at boot, `NEXT_PUBLIC_` rules, a names-only `.env.example`, App Hosting secret grants, rotating and responding to a leaked secret, and safe ops scripts. Use when adding a config value, a secret, a grant, a tier, or anything that reads env.
Ships in Engineering Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Configuration splits three ways: secrets in env, public per-tier facts in committed code, and the tier itself in one variable. Each app validates its env at boot, so a missing or malformed value stops the app before it serves a request.
Before applying this skill, read the project's root AGENTS.md, the AGENTS.md closest to the files in question, and any doc they link for this skill's topic. Names, values and choices — budgets, tiers, tokens, voice, paths — come from those files, never from this skill.
One question decides: would leaking this hurt?
site.ts (or a shared constants file when several apps read it), so every tier's values are reviewable in one diff and a new deployment needs no new variables.A public value that isn't a secret has no reason to be an env var, so NEXT_PUBLIC_ variables are rare.
A Client Component gets a per-tier fact as a prop, or from a provider the layout fills: the layout, a Server Component, reads the constant and passes the value down (the client SDK's config, the API's origin). The tier comes from server-only env, so a client module never imports the constants file that reads it.
APP_ENVAPP_ENV names the tier (local, development, staging, production) and is the only switch. Code branches on it, and per-tier constants are keyed by it.NODE_ENV. The framework owns it and it describes the build mode, not where the build runs — a staging build is a production build.Each app has one env.ts: a leaf module that parses process.env with Zod and exports env. It imports only zod, plus server-only in a frontend, so a failed parse is the only thing that can break it.
It fails loudly at boot, with a readable message (z.prettifyError), never by returning undefined later.
A value optional locally but required on a deployed tier is .optional() plus a superRefine that requires it when APP_ENV isn't local. The deployed boot then fails instead of quietly switching a feature off.
import "server-only";
import { z } from "zod";
const EnvSchema = z
.object({
APP_ENV: z.enum(["local", "development", "staging", "production"]),
MAINTENANCE_BYPASS_TOKEN: z.string().min(32).optional(),
})
.superRefine((value, ctx) => {
if (value.APP_ENV !== "local" && !value.MAINTENANCE_BYPASS_TOKEN) {
ctx.addIssue({ code: "custom", path: ["MAINTENANCE_BYPASS_TOKEN"], message: "Required on every deployed tier" });
}
});
const parsed = EnvSchema.safeParse(process.env);
if (!parsed.success) throw new Error(`Invalid environment: ${z.prettifyError(parsed.error)}`);
export const env = parsed.data;
App code imports env, never process.env. The only direct reads are:
env.ts guard itself;next.config.*, which runs before the app and can't import the guard;NEXT_PUBLIC_ value, because the guard is server-only and Next inlines a NEXT_PUBLIC_ read only when it's written out literally.A new direct read outside that list is a finding. A project names its own carve-outs in its docs.
NEXT_PUBLIC_NEXT_PUBLIC_ secret grant needs both build and runtime availability on a host that separates them, because the value is inlined during the build and the server may also read it..env and .env.example.env per app, gitignored: the local secrets and APP_ENV=local. Its values come from the secret manager through a script (env-setup writing the file for the tier named), never passed around by hand — not in chat, an issue, a PR, a commit or an AI tool's prompt..env.example beside it lists every key the app and its scripts read, with no values and no comments, and is committed. A key no longer read is deleted from both..env.example and the keys its env.ts schema reads differ, so a new secret can't ship undocumented. CI has no .env, so the schema is the other side; locally, the same script can also compare .env.apphosting.yaml plus one overlay per tier (apphosting.<tier>.yaml). The overlay sets APP_ENV and any grant only that tier has; the base declares the grants every tier shares, and each project's Secret Manager holds its own value.availability: blocks. Its env guard parses at module load, which next build runs, so a variable limited to RUNTIME is missing during the build and the guard throws.next build. The mechanics of apphosting.yaml and the secrets commands are the official firebase-app-hosting-basics skill's.field-encryption for keys that encrypt stored data)..env. Its project and default bucket come from the runtime, public facts from the same committed constants the apps read, and each secret is a defineSecret(...) mounted from Secret Manager, set once per project.--env=<tier> and has no default to production. Running it without the flag uses local or refuses.Every env var a build reads is listed in the build task's env in turbo.json, or strict mode withholds it and the cache ignores it — see monorepo.
APP_ENV; validate at boot; require deployed-only values with superRefine; keep .env.example to names; grant secrets before the rollout that reads them.process.env outside the carve-outs; set or branch on NODE_ENV; put a secret behind NEXT_PUBLIC_; add comments or values to .env.example; give an ops script a production default; commit a .env file; paste a secret into chat, a ticket or a prompt.devops.monorepo.backend-security; encryption keys → field-encryption.env-audit.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub timonwa/engineering-skills --plugin eng20 skills in this plugin
/agents-mdWrites or updates a project's AGENTS.md and the short AGENTS.md notes in each app and package — what an agent can't work out from the code: commands, structure, conventions that differ from the defaults, workflow, recorded deviations from the house standards and hard constraints, under 200 lines. Use when starting a project, setting up AGENTS.md or CLAUDE.md, or bringing a project's agent instructions up to date./audit-allManually invoked. Runs the house audit suite across the eng, fe and be sets — detects what the repo has, runs every installed audit that applies (codebase, conventions, dependencies, env, security, accessibility, frontend, performance, SEO/AEO/GEO, Storybook, content, API, access control, Firestore, Redis), and rolls their reports into one health report with an overall score and cross-cutting priorities. Each audit still writes its own report./Other plugins' skills for the same job