-
Notifications
You must be signed in to change notification settings - Fork 0
feat(config): centralize environment variable access with Zod validation #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ce38317 to
de20be3
Compare
fd471f2 to
a8afb46
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd471f2f48
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
a8afb46 to
0f0a5d8
Compare
de20be3 to
8e14398
Compare
0f0a5d8 to
809e837
Compare
Greptile Summary
|
| Filename | Overview |
|---|---|
| packages/config/src/env.ts | New centralized env validation module with critical type safety issue in the exported env object using unsafe type assertion |
| packages/config/src/index.ts | Added env validation exports but left existing XDG functions using direct process.env access, creating inconsistency |
Confidence score: 3/5
- This PR requires careful review due to a critical type safety issue in the core environment validation module
- Score lowered due to unsafe type assertion in
envexport that could mask validation errors and incomplete migration leaving directprocess.envusage in XDG functions - Pay close attention to
packages/config/src/env.tsline 210 where the type assertion could cause runtime issues
Sequence Diagram
sequenceDiagram
participant User
participant App as "Application Code"
participant Config as "@outfitter/config"
participant Zod as "Zod Validator"
participant ProcessEnv as "process.env"
User->>App: "Import env from @outfitter/config"
App->>Config: "import { env }"
Config->>Zod: "appEnvSchema.parse(process.env)"
Zod->>ProcessEnv: "Read environment variables"
ProcessEnv-->>Zod: "Raw string values"
Zod->>Zod: "Transform and validate"
Zod-->>Config: "Typed environment object"
Config-->>App: "Pre-parsed env"
App->>App: "Access typed env.NODE_ENV, env.NO_COLOR, etc."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments (1)
-
packages/config/src/index.ts, line 106-107 (link)style: These direct
process.envaccesses should use the new centralized env system to eliminate biome-ignore comments. Are these XDG functions planned to be updated to use the centralized env access in a follow-up PR?
3 files reviewed, 2 comments
809e837 to
213ff0b
Compare
8e14398 to
f363099
Compare
|
Updated color detection to treat NO_COLOR presence as disable and honor FORCE_COLOR numeric levels (0 disables, 1+ enables). |
|
Removed the unnecessary Env type assertion by wiring |
27b3ce5 to
fb1e133
Compare
|
Resubmitted after sync/restack. NO_COLOR/FORCE_COLOR handling and env typing fixes are in place on this branch; no further changes needed here. |
|
Addressed the Greptile note by deriving Env from the schema and typing the schema shape explicitly; env stays validated at module load. Updated the PR with the new commit. |
- Add portSchema, booleanSchema, optionalBooleanSchema for env validation - Add parseEnv() for generic schema-based env parsing - Add getEnvBoolean() for dynamic runtime env reads - Export typed env object with all common env vars - Add 17 tests for env validation Fixes #22 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
b9b892b to
b12f9d2
Compare

Summary
Centralizes all environment variable access in
@outfitter/configwith Zod validation, eliminating scatteredbiome-ignorecomments and providing type-safe env access.Problem
12
biome-ignorecomments across the codebase due to conflict between:noPropertyAccessFromIndexSignature(requiresprocess.env["KEY"])useLiteralKeys(prefersprocess.env.KEY)Solution
Single centralized access point with proper validation:
Changes
New in
@outfitter/configportSchema— Port validation (1-65535) with coercionbooleanSchema— String to boolean ("true"/"1" → true)optionalBooleanSchema— Optional boolean handlingparseEnv<T>()— Generic schema-based env parsinggetEnvBoolean()— Dynamic runtime env readsenv— Pre-parsed typed environment objectUpdated
@outfitter/uigetEnvBoolean()for terminal detectionbiome-ignorecommentsBenefits
env.NODE_ENVtyped as unionTest plan
Fixes #22
🤖 Generated with Claude Code