Skip to content

feat(env): require --env when the project has more than one environment - #79

Merged
Domantas merged 2 commits into
mainfrom
feat/env-mandatory
Oct 14, 2026
Merged

Domantas merged 2 commits into
mainfrom
feat/env-mandatory

Conversation

@Domantas

Copy link
Copy Markdown
Contributor

Owner rule (2026-10-14): a project with only PROD needs no env; a project with more than one environment needs the caller to name one. A coding agent wrote to PROD because it did not know the project had TEST.

  • Project-scoped commands read the project's environments (cached 5 min per project; env list/use/delete and CM-ERRORS-ENVIRONMENTS-001 refresh it). Several envs and none named → exit 2 ENV_REQUIRED with the list; nothing is sent (a dry run fails the same way).
  • Named = --env, --prod (new, short for --env PROD), NORBIX_ENV, or a saved default (norbix env use, profile env) — a saved one is printed on stderr: env: TEST (profile [x]).
  • Envs that cannot be read (key without project:read): runs as before, one stderr warning. Account commands and norbix env … are not checked. whoami shows the env source and the rule.
  • AGENTS.md, agent-contract.md, README and the generated agent skill tell agents to check the environments and pass --env.

Breaking: on a project with more than one environment, a command without an env now stops (exit 2) instead of running in PROD.

Tests: npm test 992 passed (12 new in tests/env-rule.test.ts: single env no flag → no header; multi env no flag → ENV_REQUIRED, nothing sent; --env TEST → norbix-env: TEST; NORBIX_ENV; --prod; saved env printed; dry run; cache read once / dropped by env use, env delete and the env error; unreadable envs → warning).
Task file: /Users/djovaisas/Projects/norbix/docs/tasks/ux-fixes-2026-10-14/env-rule.md (workspace, not a repo). Gateway part shipped in codemash-io/gateway 880be9010.

🤖 Generated with Claude Code

Domantas and others added 2 commits October 14, 2026 18:00
A project with only PROD works as before: no env needed, with or without
--env PROD. A project with several environments needs the env named on
every project-scoped command (--env, --prod, NORBIX_ENV, or a default saved
with `norbix env use` / a profile, which is then printed on stderr);
otherwise the command exits 2 with ENV_REQUIRED and the list, and sends
nothing. The list is read through the same client and cached per project
for 5 minutes; env list/use/delete and CM-ERRORS-ENVIRONMENTS-001 refresh
it. Envs that cannot be read: runs as before with one stderr warning.
`whoami` shows the env source and the rule. Plain SDK/API apps unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…en there are several

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Domantas
Domantas merged commit d414925 into main Oct 14, 2026
11 checks passed
@Domantas
Domantas deleted the feat/env-mandatory branch October 14, 2026 15:09
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.33.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant