Overhaul internal structure and improve typesafety#511
Conversation
…introducing `SchemaShape` and `EnvSchemaWithType` across packages.
🦋 Changeset detectedLatest commit: aa0027f The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughIntroduces two new internal packages ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (7)📓 Common learnings📚 Learning: 2025-11-29T22:11:39.931ZApplied to files:
📚 Learning: 2025-11-29T22:11:39.931ZApplied to files:
📚 Learning: 2025-11-24T16:04:11.901ZApplied to files:
📚 Learning: 2025-11-29T08:00:08.044ZApplied to files:
📚 Learning: 2025-11-24T16:04:11.901ZApplied to files:
📚 Learning: 2025-11-24T16:04:11.901ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
📦 Bundle Size Report
✅ All size limits passed! |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
packages/internal/types/src/schema.ts (1)
1-5: Add JSDoc comments for public type APIs.These types form the public API foundation for schema definitions across the codebase. Consider adding JSDoc comments to document:
- Purpose of
SchemaShape(represents an object with string keys and unknown values)- Purpose of
EnvSchemaWithType(the full ArkType schema type including validation methods)- Usage examples showing how these types integrate with
createEnvand plugin APIsExample:
import { type } from "arktype"; +/** + * Runtime ArkType schema representing an object with string keys and unknown values. + * This serves as the base schema shape for environment variable definitions. + */ export const SchemaShape = type({ "[string]": "unknown" }); + +/** + * Type representing the inferred shape from SchemaShape. + * Used as a constraint for environment schema objects. + */ export type SchemaShape = typeof SchemaShape.infer; + +/** + * Type representing an ArkType schema with validation methods. + * This is the full schema type including runtime validation capabilities. + */ export type EnvSchemaWithType = typeof SchemaShape;As per coding guidelines: Use JSDoc comments for public APIs.
packages/vite-plugin/src/index.ts (1)
59-67: Type assertions documented appropriately.The TODO comment clearly explains why the explicit type parameter and assertion are needed (to avoid TypeScript's "excessively deep" error). The
<SchemaShape>envcast on line 67 is the same pattern used inbun-plugin/src/index.ts(line 28), maintaining consistency.One minor observation: consider extracting the filtering logic into a shared utility if this pattern appears in more plugins in the future.
packages/bun-plugin/src/index.ts (1)
189-189: Consider narrowing theanytype for dynamically loaded schemas.The
schema: anydeclaration loses type safety for dynamically imported schemas. While runtime validation viacreateEnvwill still catch errors, you could add a runtime check before callingprocessEnvSchema:- let schema: any; + let schema: EnvSchemaWithType | undefined;Then validate the loaded module exports a compatible type before use. This would provide clearer error messages if the loaded schema is malformed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
.changeset/smooth-lamps-go.md(1 hunks).changeset/twelve-tigers-sell.md(1 hunks)packages/arkenv/src/create-env.test.ts(5 hunks)packages/arkenv/src/create-env.ts(2 hunks)packages/bun-plugin/src/index.test.ts(1 hunks)packages/bun-plugin/src/index.ts(3 hunks)packages/internal/types/README.md(1 hunks)packages/internal/types/package.json(1 hunks)packages/internal/types/src/index.ts(1 hunks)packages/internal/types/src/schema.ts(1 hunks)packages/vite-plugin/src/index.ts(4 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
packages/arkenv/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/arktype.mdc)
packages/arkenv/**/*.ts: Use ArkType'stype()function to define schemas in environment variable definitions
Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Use the scoped$type system for custom types defined inscope.ts
Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Use union types for enums in ArkType schemas (e.g.,"'dev' | 'prod'") instead of separate enum definitions
Leverage ArkType's built-in types (e.g.,string.host,number.port) where possible in environment schemas
Convert ArkType validation errors toArkEnvErrorfor user-friendly error messages that include variable name and expected type
Files:
packages/arkenv/src/create-env.test.tspackages/arkenv/src/create-env.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)
**/*.{ts,tsx}: Prefertypeoverinterfacefor type definitions in TypeScript
Use TypeScript 5.1+ features when appropriate
Leverageconsttype parameters for better inference in TypeScript
Use JSDoc comments for public APIs
Use tabs for indentation (configured in Biome)
Use double quotes for strings (configured in Biome)
Organize imports automatically (Biome handles this)
Avoid explicit types when TypeScript can infer them (noInferrableTypeserror)
Useas constwhere appropriate for immutable values (useAsConstAssertionerror)
Don't reassign function parameters (noParameterAssignerror)
Place default parameters last in function signatures (useDefaultParameterLasterror)
Always initialize enum values (useEnumInitializerserror)
Declare one variable per statement (useSingleVarDeclaratorerror)
Avoid unnecessary template literals (noUnusedTemplateLiteralerror)
PreferNumber.parseIntover globalparseInt(useNumberNamespaceerror)
Use kebab-case for TypeScript filenames (e.g.,create-env.ts)
Use camelCase for function names (e.g.,createEnv)
Use PascalCase for type names (e.g.,ArkEnvError)
Use UPPER_SNAKE_CASE for environment variables and constants
Include examples in JSDoc comments when helpful for public APIs
Document complex type logic with JSDoc comments
UseArkEnvErrorfor environment variable validation errors
Provide clear, actionable error messages that include the variable name and expected type
**/*.{ts,tsx}: UsecreateEnv(schema)as the main function for validated environment objects, available as the default export
Use built-in validators (host, port, url, email) fromsrc/types.tswhen available instead of custom validation
UseArkEnvErrorfor environment variable errors, not generic errors
Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Use logical grouping for related environment variables in schemas
Use descriptive env...
Files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.tspackages/bun-plugin/src/index.test.tspackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/internal/types/src/index.tspackages/bun-plugin/src/index.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)
Co-locate tests with components:
Component.tsxnext toComponent.test.tsx
**/*.test.{ts,tsx}: Test individual functions, components, and hooks in isolation with mocked dependencies in unit tests
Keep unit tests fast with execution under 100ms per test
Co-locate unit tests with source files using naming convention:source.ts→source.test.ts
Focus component tests on public API, user behavior, state transitions, and accessibility rather than styling or implementation details
Query component tests by role, name, label, and text using accessibility-first selectors
Use Vitest as the test framework for unit and integration tests
Use Testing Library withuser-eventfor real user simulation in component tests
**/*.test.{ts,tsx}: Test individual functions, components, and hooks in isolation with mocked dependencies using the*.test.tsor*.test.tsxsuffix
Mockprocess.envin tests for different scenarios and save/restore original env inbeforeEach/afterEachhooks
Use Vitest'sdescribe/itstructure in test files
Test edge cases including invalid and missing environment variable values
Use Vitest for testing framework
Files:
packages/arkenv/src/create-env.test.tspackages/bun-plugin/src/index.test.ts
packages/arkenv/src/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Main library implementation should be in
src/create-env.ts, built-in validators insrc/types.ts, error handling insrc/errors.ts, and utilities insrc/utils.ts
Files:
packages/arkenv/src/create-env.test.tspackages/arkenv/src/create-env.ts
**/*.{ts,tsx,json,md}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use Biome for linting and formatting instead of ESLint and Prettier
Files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.tspackages/internal/types/README.mdpackages/internal/types/package.jsonpackages/bun-plugin/src/index.test.tspackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/internal/types/src/index.tspackages/bun-plugin/src/index.ts
**/README.md
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Document environment requirements in README files
Files:
packages/internal/types/README.md
**/package.json
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use workspace:* protocol for workspace dependencies between packages
Files:
packages/internal/types/package.json
{packages,apps,tooling}/**/package.json
📄 CodeRabbit inference engine (.cursor/rules/pnpm.mdc)
When referencing workspace packages in dependencies, use the
workspace:*protocol instead of version numbers
Files:
packages/internal/types/package.json
**/index.ts
📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)
Use barrel exports (
index.ts) for package entry points
Files:
packages/vite-plugin/src/index.tspackages/internal/types/src/index.tspackages/bun-plugin/src/index.ts
🧠 Learnings (40)
📓 Common learnings
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `createEnv(schema)` as the main function for validated environment objects, available as the default export
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use logical grouping for related environment variables in schemas
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts.changeset/twelve-tigers-sell.md.changeset/smooth-lamps-go.mdpackages/internal/types/README.mdpackages/internal/types/package.jsonpackages/bun-plugin/src/index.test.tspackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/internal/types/src/index.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `createEnv(schema)` as the main function for validated environment objects, available as the default export
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.tspackages/bun-plugin/src/index.test.tspackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts.changeset/smooth-lamps-go.mdpackages/internal/types/README.mdpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/internal/types/src/index.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts.changeset/smooth-lamps-go.mdpackages/internal/types/README.mdpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/internal/types/src/index.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts.changeset/twelve-tigers-sell.md.changeset/smooth-lamps-go.mdpackages/internal/types/README.mdpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/internal/types/src/index.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts.changeset/smooth-lamps-go.mdpackages/internal/types/README.mdpackages/internal/types/package.jsonpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/internal/types/src/index.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts.changeset/smooth-lamps-go.mdpackages/internal/types/README.mdpackages/internal/types/package.jsonpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/internal/types/src/index.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to packages/arkenv/src/**/*.ts : Main library implementation should be in `src/create-env.ts`, built-in validators in `src/types.ts`, error handling in `src/errors.ts`, and utilities in `src/utils.ts`
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/README.mdpackages/internal/types/package.jsonpackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.tspackages/internal/types/README.mdpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/internal/types/src/index.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable errors, not generic errors
Applied to files:
packages/arkenv/src/create-env.test.tspackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Mock `process.env` in tests for different scenarios and save/restore original env in `beforeEach`/`afterEach` hooks
Applied to files:
packages/arkenv/src/create-env.test.tspackages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Test edge cases including invalid and missing environment variable values
Applied to files:
packages/arkenv/src/create-env.test.tspackages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts.changeset/smooth-lamps-go.mdpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/internal/types/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use logical grouping for related environment variables in schemas
Applied to files:
packages/arkenv/src/create-env.test.tspackages/vite-plugin/src/index.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable validation errors
Applied to files:
packages/arkenv/src/create-env.test.tspackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas
Applied to files:
packages/internal/types/src/schema.ts.changeset/twelve-tigers-sell.md.changeset/smooth-lamps-go.mdpackages/internal/types/README.mdpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.tspackages/internal/types/src/index.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Achieve coverage goals: environment variable parsing and validation, type checking and error handling, default value handling, custom type validation, plugin integration with Vite, and real project build testing using examples as fixtures
Applied to files:
.changeset/smooth-lamps-go.md
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use the scoped `$` type system for custom types defined in `scope.ts`
Applied to files:
.changeset/smooth-lamps-go.mdpackages/internal/types/README.mdpackages/internal/types/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use PascalCase for type names (e.g., `ArkEnvError`)
Applied to files:
packages/internal/types/README.md
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to packages/*/package.json : Packages in packages/ directory must be published to npm and require changesets for versioning, proper exports, and type definitions
Applied to files:
packages/internal/types/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to package.json : The project uses `pnpm10.20.0` as specified in the `packageManager` field
Applied to files:
packages/internal/types/package.json
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to **/package.json : Use workspace:* protocol for workspace dependencies between packages
Applied to files:
packages/internal/types/package.json
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Always run `pnpm changeset` for version bumps in published packages - never skip changesets
Applied to files:
packages/internal/types/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to package.json : Configure only built dependencies (native modules) in `pnpm.onlyBuiltDependencies`, including: biomejs/biome, sentry/cli, swc/core, tailwindcss/oxide, vercel/speed-insights, esbuild, and sharp
Applied to files:
packages/internal/types/package.json
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to tooling/*/package.json : Tooling in tooling/ directory contains development and testing tools that are not published to npm and excluded from changesets
Applied to files:
packages/internal/types/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to {packages,apps,tooling}/**/package.json : When referencing workspace packages in dependencies, use the `workspace:*` protocol instead of version numbers
Applied to files:
packages/internal/types/package.json
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to pnpm-workspace.yaml : Use pnpm for package management with workspace support
Applied to files:
packages/internal/types/package.json
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: packages/arkenv should not depend on other workspace packages; packages/vite-plugin depends on arkenv; apps/www may depend on workspace packages
Applied to files:
packages/internal/types/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to {package.json,pnpm-lock.yaml,pnpm-workspace.yaml} : Always use `pnpm` for all package management operations in this monorepo (never use `npm` or `yarn` commands), except for standalone example projects in the `examples/` folder
Applied to files:
packages/internal/types/package.json
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/package.json : Use `bun install` instead of `npm install`, `yarn install`, or `pnpm install` in package.json scripts
Applied to files:
packages/internal/types/package.json
📚 Learning: 2025-11-29T08:57:24.056Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: examples/with-bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-29T08:57:24.056Z
Learning: Applies to examples/with-bun-react/**/*.test.{ts,tsx,js,jsx} : Use test syntax from `bun:test` with `test` and `expect` functions
Applied to files:
packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.test.{ts,tsx,js,jsx} : Use `bun:test` for unit and integration testing with `test` and `expect` from the built-in test module
Applied to files:
packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-29T08:57:24.056Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: examples/with-bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-29T08:57:24.056Z
Learning: Applies to examples/with-bun-react/**/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests
Applied to files:
packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.test.{ts,tsx,js,jsx} : Use `import { test, expect } from "bun:test"` for writing tests
Applied to files:
packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests
Applied to files:
packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests
Applied to files:
packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.{ts,tsx,js,jsx} : Bun automatically loads .env files, so don't use `dotenv` library
Applied to files:
packages/bun-plugin/src/index.test.tspackages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/index.ts : Use barrel exports (`index.ts`) for package entry points
Applied to files:
packages/internal/types/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Leverage `const` type parameters for better inference in TypeScript
Applied to files:
packages/internal/types/src/index.ts
🧬 Code graph analysis (4)
packages/internal/types/src/schema.ts (3)
packages/arkenv/src/type.ts (1)
type(3-3)packages/arkenv/src/type.test.ts (7)
it(4-218)envType(29-47)envType(86-108)envType(202-217)envType(171-190)envType(5-9)envType(17-21)packages/arkenv/src/scope.test.ts (1)
stringType(46-50)
packages/bun-plugin/src/index.test.ts (2)
packages/arkenv/src/index.test.ts (2)
vi(65-81)vi(25-35)packages/arkenv/src/type.test.ts (3)
envType(5-9)envType(29-47)envType(171-190)
packages/vite-plugin/src/index.ts (3)
packages/bun-plugin/src/index.ts (1)
arkenv(131-142)packages/internal/types/src/schema.ts (3)
SchemaShape(3-3)SchemaShape(4-4)EnvSchemaWithType(5-5)packages/arkenv/src/create-env.ts (2)
EnvSchema(7-7)createEnv(35-53)
packages/arkenv/src/create-env.ts (3)
packages/arkenv/src/scope.ts (1)
$(9-19)packages/internal/types/src/schema.ts (3)
SchemaShape(3-3)SchemaShape(4-4)EnvSchemaWithType(5-5)packages/internal/types/src/infer-type.ts (1)
InferType(9-17)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test-e2e (a11y)
- GitHub Check: test-e2e (e2e)
🔇 Additional comments (15)
packages/internal/types/README.md (1)
3-3: LGTM!Documentation updated appropriately to reflect ArkType integration in the internal types package.
Also applies to: 7-7
.changeset/smooth-lamps-go.md (1)
1-8: LGTM!Changeset appropriately documents the type stability improvements for the plugin packages.
packages/bun-plugin/src/index.test.ts (1)
57-57: LGTM!The
as constassertion improves type inference for the environment schema, ensuring literal types are preserved with the newSchemaShape-based type system..changeset/twelve-tigers-sell.md (1)
1-7: LGTM!Changeset appropriately documents the addition of new schema types to the internal types package.
packages/internal/types/src/index.ts (1)
9-12: LGTM!Barrel export pattern is appropriate for the package entry point, consolidating type exports from sub-modules.
packages/internal/types/src/schema.ts (1)
3-3: The ArkType index signature syntax is correct. The pattern"[string]": "unknown"is the correct ArkType syntax for defining an object with arbitrary string keys and values of typeunknown, mirroring TypeScript's{[key: string]: unknown}syntax. No changes needed.packages/vite-plugin/src/index.ts (2)
1-2: LGTM!The imports are correctly updated to bring in the new type definitions from
@repo/types, aligning with the centralized type system introduced in this PR.
43-49: Function overloads are well-structured.The overload pattern correctly supports both
EnvSchema<T>for literal schema objects andEnvSchemaWithTypefor pre-defined ArkType schemas. This mirrors the approach increate-env.tsandbun-plugin, maintaining consistency across the codebase.packages/arkenv/src/create-env.ts (3)
1-7: Type system foundation is well-designed.The
EnvSchema<def>type alias usingat.validate<def, (typeof $)["t"]>correctly integrates with ArkType's validation system and the project's custom scope. This provides compile-time schema validation while maintaining the readability goals from the coding guidelines.
23-38: Overload structure provides good type inference.The three overloads handle the key use cases:
- Raw schema objects with
const Tfor literal type inference- Pre-built
EnvSchemaWithTypefor dynamic schemas- Implementation signature accepting both
The
const T extends SchemaShapeconstraint withdistill.Outreturn type ensures proper type narrowing. This aligns with ArkType's type inference patterns as noted in the learnings.
41-52: Runtime schema detection is correct.The check
typeof def === "function" && "assert" in defproperly distinguishes ArkType instances from raw schema objects. The use of$.type.raw()for plain objects integrates with the scoped type system defined inscope.ts.Error handling correctly throws
ArkEnvErrorfor validation failures, as required by the coding guidelines.packages/bun-plugin/src/index.ts (4)
2-4: LGTM!Imports are correctly updated to include the new centralized types from
@repo/types, consistent with the other plugin packages.
12-37: Helper function is well-structured with clear documentation.The
processEnvSchemafunction correctly:
- Uses the generic
T extends SchemaShapeconstraint- Documents the type assertion workaround with a TODO
- Filters environment variables by the
BUN_PUBLIC_prefix- Returns a properly typed
Map<string, string>The explicit type parameter
createEnv<T>(options, process.env)on line 21 mirrors the approach invite-plugin, maintaining consistency.
89-92: Generic catch is appropriate here.The empty
catchblock handles any file read errors gracefully by returningundefined, allowing Bun to handle the file with its default behavior. This is a reasonable fallback for a build plugin.
127-134: Function overloads match the established pattern.The overload structure is consistent with
vite-pluginandcreate-env.ts, supporting bothEnvSchema<T>andEnvSchemaWithType. The explicit<T>parameter onprocessEnvSchema<T>(options)correctly propagates the type.
… and restructure `arkenv` for publishing.
… `createEnv` tests
…ations in tests.
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pnpm-workspace.yaml (1)
1-6: Remove workspace dependencies from packages/arkenv.
packages/arkenvviolates the workspace constraint by depending on internal workspace packages (@repo/keywords, @repo/scope, @repo/types) in devDependencies. Per the monorepo rules,packages/arkenvshould not depend on other workspace packages. Either these dependencies must be moved to production code with proper exports, or the internal packages should be inlined into arkenv's source.
♻️ Duplicate comments (1)
packages/internal/scope/tsdown.config.ts (1)
1-10: Configuration duplication noted.This configuration is identical to
packages/internal/keywords/tsdown.config.ts. See the review comment on that file for a suggested refactoring approach to extract shared configuration.
🧹 Nitpick comments (2)
packages/internal/keywords/tsdown.config.ts (1)
1-10: Consider extracting shared tsdown configuration.This configuration is identical to
packages/internal/scope/tsdown.config.ts. Consider creating a shared base configuration to follow DRY principles and simplify maintenance.Example approach - create a shared config file:
// packages/internal/shared-tsdown.config.ts import { defineConfig } from "tsdown"; export const sharedConfig = defineConfig({ format: ["esm", "cjs"], minify: true, fixedExtension: false, dts: { resolve: ["@repo/types"], }, sourcemap: false, // if consistency is desired });Then import and extend in each package config:
import { sharedConfig } from "../shared-tsdown.config"; export default sharedConfig;packages/vite-plugin/src/index.ts (1)
6-20:InferTypeappears to duplicate@repo/typesdefinition.The
InferTypeutility type defined here (lines 10-18) mirrors the implementation inpackages/internal/types/src/infer-type.ts. Consider importing from@repo/typesto maintain a single source of truth.-import type { EnvSchemaWithType, SchemaShape } from "@repo/types"; +import type { EnvSchemaWithType, InferType, SchemaShape } from "@repo/types"; import { createEnv, type EnvSchema } from "arkenv"; import type { type } from "arktype"; import { loadEnv, type Plugin } from "vite"; -/** - * Extract the inferred type from an ArkType type definition by checking its call signature. - * When a type definition is called, it returns either the validated value or type.errors. - */ -type InferType<T> = T extends ( - value: Record<string, string | undefined>, -) => infer R - ? R extends type.errors - ? never - : R - : T extends type.Any<infer U, infer _Scope> - ? U - : never; - export type ImportMetaEnvAugmented<T> = InferType<T>;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (29)
.gitignore(1 hunks)arkenv.code-workspace(1 hunks)packages/arkenv/.gitignore(0 hunks)packages/arkenv/package.json(1 hunks)packages/arkenv/package/LICENSE(1 hunks)packages/arkenv/package/README.md(1 hunks)packages/arkenv/package/package.json(1 hunks)packages/arkenv/src/create-env.ts(2 hunks)packages/arkenv/src/type.ts(1 hunks)packages/arkenv/tsdown.config.ts(1 hunks)packages/bun-plugin/src/index.ts(3 hunks)packages/internal/keywords/README.md(1 hunks)packages/internal/keywords/package.json(1 hunks)packages/internal/keywords/src/index.test.ts(1 hunks)packages/internal/keywords/tsconfig.json(1 hunks)packages/internal/keywords/tsdown.config.ts(1 hunks)packages/internal/keywords/turbo.json(1 hunks)packages/internal/keywords/vitest.config.ts(1 hunks)packages/internal/scope/README.md(1 hunks)packages/internal/scope/package.json(1 hunks)packages/internal/scope/src/index.test.ts(1 hunks)packages/internal/scope/src/index.ts(1 hunks)packages/internal/scope/tsconfig.json(1 hunks)packages/internal/scope/tsdown.config.ts(1 hunks)packages/internal/scope/turbo.json(1 hunks)packages/internal/scope/vitest.config.ts(1 hunks)packages/internal/types/src/schema.ts(1 hunks)packages/vite-plugin/src/index.ts(4 hunks)pnpm-workspace.yaml(2 hunks)
💤 Files with no reviewable changes (1)
- packages/arkenv/.gitignore
✅ Files skipped from review due to trivial changes (7)
- packages/internal/scope/src/index.test.ts
- packages/internal/keywords/README.md
- packages/internal/scope/README.md
- packages/arkenv/package/LICENSE
- packages/arkenv/package/package.json
- packages/internal/keywords/tsconfig.json
- arkenv.code-workspace
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/internal/types/src/schema.ts
🧰 Additional context used
📓 Path-based instructions (12)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)
**/*.{ts,tsx}: Prefertypeoverinterfacefor type definitions in TypeScript
Use TypeScript 5.1+ features when appropriate
Leverageconsttype parameters for better inference in TypeScript
Use JSDoc comments for public APIs
Use tabs for indentation (configured in Biome)
Use double quotes for strings (configured in Biome)
Organize imports automatically (Biome handles this)
Avoid explicit types when TypeScript can infer them (noInferrableTypeserror)
Useas constwhere appropriate for immutable values (useAsConstAssertionerror)
Don't reassign function parameters (noParameterAssignerror)
Place default parameters last in function signatures (useDefaultParameterLasterror)
Always initialize enum values (useEnumInitializerserror)
Declare one variable per statement (useSingleVarDeclaratorerror)
Avoid unnecessary template literals (noUnusedTemplateLiteralerror)
PreferNumber.parseIntover globalparseInt(useNumberNamespaceerror)
Use kebab-case for TypeScript filenames (e.g.,create-env.ts)
Use camelCase for function names (e.g.,createEnv)
Use PascalCase for type names (e.g.,ArkEnvError)
Use UPPER_SNAKE_CASE for environment variables and constants
Include examples in JSDoc comments when helpful for public APIs
Document complex type logic with JSDoc comments
UseArkEnvErrorfor environment variable validation errors
Provide clear, actionable error messages that include the variable name and expected type
**/*.{ts,tsx}: UsecreateEnv(schema)as the main function for validated environment objects, available as the default export
Use built-in validators (host, port, url, email) fromsrc/types.tswhen available instead of custom validation
UseArkEnvErrorfor environment variable errors, not generic errors
Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Use logical grouping for related environment variables in schemas
Use descriptive env...
Files:
packages/internal/scope/vitest.config.tspackages/arkenv/src/type.tspackages/arkenv/tsdown.config.tspackages/internal/keywords/src/index.test.tspackages/internal/keywords/tsdown.config.tspackages/bun-plugin/src/index.tspackages/internal/scope/src/index.tspackages/internal/scope/tsdown.config.tspackages/vite-plugin/src/index.tspackages/internal/keywords/vitest.config.tspackages/arkenv/src/create-env.ts
**/*.{ts,tsx,json,md}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use Biome for linting and formatting instead of ESLint and Prettier
Files:
packages/internal/scope/vitest.config.tspackages/internal/scope/turbo.jsonpackages/arkenv/src/type.tspackages/arkenv/tsdown.config.tspackages/internal/scope/tsconfig.jsonpackages/internal/keywords/src/index.test.tspackages/internal/keywords/tsdown.config.tspackages/bun-plugin/src/index.tspackages/internal/scope/src/index.tspackages/arkenv/package/README.mdpackages/internal/keywords/package.jsonpackages/internal/scope/package.jsonpackages/internal/scope/tsdown.config.tspackages/vite-plugin/src/index.tspackages/internal/keywords/turbo.jsonpackages/internal/keywords/vitest.config.tspackages/arkenv/package.jsonpackages/arkenv/src/create-env.ts
packages/arkenv/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/arktype.mdc)
packages/arkenv/**/*.ts: Use ArkType'stype()function to define schemas in environment variable definitions
Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Use the scoped$type system for custom types defined inscope.ts
Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Use union types for enums in ArkType schemas (e.g.,"'dev' | 'prod'") instead of separate enum definitions
Leverage ArkType's built-in types (e.g.,string.host,number.port) where possible in environment schemas
Convert ArkType validation errors toArkEnvErrorfor user-friendly error messages that include variable name and expected type
Files:
packages/arkenv/src/type.tspackages/arkenv/tsdown.config.tspackages/arkenv/src/create-env.ts
packages/arkenv/src/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Main library implementation should be in
src/create-env.ts, built-in validators insrc/types.ts, error handling insrc/errors.ts, and utilities insrc/utils.ts
Files:
packages/arkenv/src/type.tspackages/arkenv/src/create-env.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)
Co-locate tests with components:
Component.tsxnext toComponent.test.tsx
**/*.test.{ts,tsx}: Test individual functions, components, and hooks in isolation with mocked dependencies in unit tests
Keep unit tests fast with execution under 100ms per test
Co-locate unit tests with source files using naming convention:source.ts→source.test.ts
Focus component tests on public API, user behavior, state transitions, and accessibility rather than styling or implementation details
Query component tests by role, name, label, and text using accessibility-first selectors
Use Vitest as the test framework for unit and integration tests
Use Testing Library withuser-eventfor real user simulation in component tests
**/*.test.{ts,tsx}: Test individual functions, components, and hooks in isolation with mocked dependencies using the*.test.tsor*.test.tsxsuffix
Mockprocess.envin tests for different scenarios and save/restore original env inbeforeEach/afterEachhooks
Use Vitest'sdescribe/itstructure in test files
Test edge cases including invalid and missing environment variable values
Use Vitest for testing framework
Files:
packages/internal/keywords/src/index.test.ts
**/index.ts
📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)
Use barrel exports (
index.ts) for package entry points
Files:
packages/bun-plugin/src/index.tspackages/internal/scope/src/index.tspackages/vite-plugin/src/index.ts
**/README.md
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Document environment requirements in README files
Files:
packages/arkenv/package/README.md
**/package.json
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use workspace:* protocol for workspace dependencies between packages
Files:
packages/internal/keywords/package.jsonpackages/internal/scope/package.jsonpackages/arkenv/package.json
{packages,apps,tooling}/**/package.json
📄 CodeRabbit inference engine (.cursor/rules/pnpm.mdc)
When referencing workspace packages in dependencies, use the
workspace:*protocol instead of version numbers
Files:
packages/internal/keywords/package.jsonpackages/internal/scope/package.jsonpackages/arkenv/package.json
{package.json,pnpm-lock.yaml,pnpm-workspace.yaml}
📄 CodeRabbit inference engine (.cursor/rules/pnpm.mdc)
Always use
pnpmfor all package management operations in this monorepo (never usenpmoryarncommands), except for standalone example projects in theexamples/folder
Files:
pnpm-workspace.yaml
pnpm-workspace.yaml
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use pnpm for package management with workspace support
Files:
pnpm-workspace.yaml
packages/*/package.json
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Packages in packages/ directory must be published to npm and require changesets for versioning, proper exports, and type definitions
Files:
packages/arkenv/package.json
🧠 Learnings (68)
📓 Common learnings
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use the scoped `$` type system for custom types defined in `scope.ts`
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 498
File: apps/playgrounds/node/index.ts:2-2
Timestamp: 2025-12-05T20:33:10.676Z
Learning: ArkType 2.1.28+ supports Standard Schema specification, allowing interoperability with other Standard Schema-compliant validation libraries (e.g., Zod, Valibot) within the same schema definition
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to **/*.test.{ts,tsx} : Use Vitest as the test framework for unit and integration tests
Applied to files:
packages/internal/scope/vitest.config.tspackages/internal/keywords/src/index.test.tspnpm-workspace.yamlpackages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Use Vitest for testing framework
Applied to files:
packages/internal/scope/vitest.config.tspackages/internal/keywords/src/index.test.tspnpm-workspace.yamlpackages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Use Vitest's `describe`/`it` structure in test files
Applied to files:
packages/internal/scope/vitest.config.tspackages/internal/keywords/src/index.test.tspackages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to packages/vite-plugin/src/**/*.test.ts : Use fixture-based testing pattern with `__fixtures__` directory for Vite plugin tests
Applied to files:
packages/internal/scope/vitest.config.tspackages/internal/keywords/src/index.test.tspnpm-workspace.yamlpackages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to packages/vite-plugin/src/**/*.test.ts : Test Vite plugin using the `with-vite-react-ts` example as a fixture and validate plugin works with real Vite projects
Applied to files:
packages/internal/scope/vitest.config.tspackages/internal/keywords/src/index.test.tspnpm-workspace.yamlpackages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to turbo.json : Turborepo tasks are defined in turbo.json with common tasks: build, dev, typecheck, test, and test:e2e
Applied to files:
packages/internal/scope/turbo.jsonpackages/internal/keywords/turbo.json
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Monorepo directory structure must follow: packages/ (published npm packages), apps/ (applications), examples/ (example projects), tooling/ (development tools), and turbo.json at root
Applied to files:
packages/internal/scope/turbo.jsonpackages/internal/keywords/turbo.json
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas
Applied to files:
packages/arkenv/src/type.tspackages/internal/scope/tsconfig.jsonpackages/bun-plugin/src/index.tspackages/internal/scope/src/index.tspackages/internal/keywords/package.jsonpackages/internal/scope/package.jsonpackages/internal/scope/tsdown.config.tspackages/vite-plugin/src/index.tspackages/arkenv/package.jsonpackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use the scoped `$` type system for custom types defined in `scope.ts`
Applied to files:
packages/arkenv/src/type.tspackages/internal/scope/tsconfig.jsonpackages/internal/scope/src/index.tspackages/internal/keywords/package.jsonpackages/internal/scope/package.jsonpackages/internal/scope/tsdown.config.tspackages/arkenv/package.jsonpackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Applied to files:
packages/arkenv/src/type.tspackages/arkenv/tsdown.config.tspackages/bun-plugin/src/index.tspackages/arkenv/package/README.mdpackages/internal/keywords/package.jsonpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Applied to files:
packages/arkenv/src/type.tspackages/arkenv/tsdown.config.tspackages/bun-plugin/src/index.tspackages/internal/scope/src/index.tspackages/arkenv/package/README.mdpackages/internal/keywords/package.jsonpackages/internal/scope/package.jsonpackages/internal/scope/tsdown.config.tspackages/vite-plugin/src/index.tspackages/arkenv/package.jsonpackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions
Applied to files:
packages/arkenv/src/type.tspackages/bun-plugin/src/index.tspackages/internal/scope/src/index.tspackages/arkenv/package/README.mdpackages/internal/keywords/package.jsonpackages/internal/scope/package.jsonpackages/vite-plugin/src/index.tspackages/arkenv/package.jsonpackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions
Applied to files:
packages/arkenv/src/type.tspackages/arkenv/tsdown.config.tspackages/bun-plugin/src/index.tspackages/internal/scope/src/index.tspackages/vite-plugin/src/index.tspackages/arkenv/package.jsonpackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas
Applied to files:
packages/arkenv/src/type.tspackages/internal/keywords/src/index.test.tspackages/bun-plugin/src/index.tspackages/internal/scope/src/index.tspackages/arkenv/package/README.mdpackages/internal/keywords/package.jsonpackages/internal/scope/package.jsonpackages/vite-plugin/src/index.tspackages/arkenv/package.jsonpackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type
Applied to files:
packages/arkenv/src/type.tspackages/bun-plugin/src/index.tspackages/arkenv/package/README.mdpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to packages/arkenv/src/**/*.ts : Main library implementation should be in `src/create-env.ts`, built-in validators in `src/types.ts`, error handling in `src/errors.ts`, and utilities in `src/utils.ts`
Applied to files:
packages/arkenv/src/type.tspackages/bun-plugin/src/index.tspackages/arkenv/package/README.mdpackages/internal/keywords/package.jsonpackages/internal/scope/package.jsonpackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use PascalCase for type names (e.g., `ArkEnvError`)
Applied to files:
packages/arkenv/src/type.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use TypeScript 5.1+ features when appropriate
Applied to files:
packages/arkenv/tsdown.config.tspackages/internal/scope/tsconfig.jsonpackages/internal/keywords/tsdown.config.tspackages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use TypeScript for the primary language throughout the project
Applied to files:
packages/internal/scope/tsconfig.jsonpackages/internal/keywords/tsdown.config.tspackages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Organize imports automatically (Biome handles this)
Applied to files:
packages/internal/scope/tsconfig.jsonpackages/internal/keywords/tsdown.config.tspackages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to packages/*/package.json : Packages in packages/ directory must be published to npm and require changesets for versioning, proper exports, and type definitions
Applied to files:
packages/internal/scope/tsconfig.jsonpackages/internal/keywords/package.jsonpackages/internal/scope/package.jsonpackages/arkenv/package.json
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use JSDoc comments for public APIs
Applied to files:
packages/internal/scope/tsconfig.jsonpackages/internal/keywords/tsdown.config.tspackages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use logical grouping for related environment variables in schemas
Applied to files:
packages/internal/scope/tsconfig.jsonpackages/bun-plugin/src/index.tspackages/internal/scope/tsdown.config.tspackages/vite-plugin/src/index.ts
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to tooling/*/package.json : Tooling in tooling/ directory contains development and testing tools that are not published to npm and excluded from changesets
Applied to files:
packages/internal/scope/tsconfig.jsonpackages/internal/keywords/package.jsonpackages/internal/scope/package.jsonpnpm-workspace.yamlpackages/arkenv/package.json
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Avoid explicit types when TypeScript can infer them (`noInferrableTypes` error)
Applied to files:
packages/internal/scope/tsconfig.json
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx,json,md} : Use Biome for linting and formatting instead of ESLint and Prettier
Applied to files:
packages/internal/scope/tsconfig.jsonpackages/internal/keywords/tsdown.config.tspackages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Test edge cases including invalid and missing environment variable values
Applied to files:
packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use built-in validators (host, port, url, email) from `src/types.ts` when available instead of custom validation
Applied to files:
packages/internal/keywords/src/index.test.tspackages/internal/scope/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Use integration tests with `*.integration.test.ts` or `*.integration.test.tsx` suffix to test how multiple units work together without mocking their interactions
Applied to files:
packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.test.{ts,tsx,js,jsx} : Use `import { test, expect } from "bun:test"` for writing tests
Applied to files:
packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Test how multiple units (components, hooks, functions) work together without mocking their interactions in integration tests
Applied to files:
packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Integration tests should verify interactions between multiple units (like components + hooks + services) without mocking their interactions
Applied to files:
packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Use `*.integration.test.ts` suffix to distinguish integration tests from unit tests
Applied to files:
packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-29T08:57:24.056Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: examples/with-bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-29T08:57:24.056Z
Learning: Applies to examples/with-bun-react/**/*.test.{ts,tsx,js,jsx} : Use test syntax from `bun:test` with `test` and `expect` functions
Applied to files:
packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.test.{ts,tsx,js,jsx} : Use `bun:test` for unit and integration testing with `test` and `expect` from the built-in test module
Applied to files:
packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-29T08:57:24.056Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: examples/with-bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-29T08:57:24.056Z
Learning: Applies to examples/with-bun-react/**/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests
Applied to files:
packages/internal/keywords/src/index.test.tspackages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Prefer `type` over `interface` for type definitions in TypeScript
Applied to files:
packages/internal/keywords/tsdown.config.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/index.ts : Use barrel exports (`index.ts`) for package entry points
Applied to files:
packages/internal/keywords/tsdown.config.tspackages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use kebab-case for TypeScript filenames (e.g., `create-env.ts`)
Applied to files:
packages/internal/keywords/tsdown.config.tspackages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use descriptive environment variable names that indicate purpose and format
Applied to files:
packages/internal/keywords/tsdown.config.tspackages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use UPPER_SNAKE_CASE for environment variables and constants
Applied to files:
packages/internal/keywords/tsdown.config.tspackages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `createEnv(schema)` as the main function for validated environment objects, available as the default export
Applied to files:
packages/internal/keywords/tsdown.config.tspackages/bun-plugin/src/index.tspackages/internal/scope/tsdown.config.tspackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable errors, not generic errors
Applied to files:
packages/bun-plugin/src/index.tspackages/arkenv/package/README.mdpackages/internal/keywords/package.jsonpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable validation errors
Applied to files:
packages/bun-plugin/src/index.tspackages/arkenv/package/README.mdpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition
Applied to files:
packages/bun-plugin/src/index.tspackages/internal/scope/src/index.tspackages/arkenv/package/README.mdpackages/vite-plugin/src/index.tspackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.{ts,tsx,js,jsx} : Bun automatically loads .env files, so don't use `dotenv` library
Applied to files:
packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/README.md : Document environment requirements in README files
Applied to files:
packages/arkenv/package/README.md
📚 Learning: 2025-09-10T19:35:18.179Z
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 136
File: .changeset/vast-bananas-win.md:2-3
Timestamp: 2025-09-10T19:35:18.179Z
Learning: The arkenv package is currently in v0.x.x (pre-1.0) development phase, where breaking changes are acceptable in minor version bumps according to semantic versioning conventions.
Applied to files:
packages/arkenv/package/README.md
📚 Learning: 2025-09-09T17:37:19.650Z
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).
Applied to files:
packages/arkenv/package/README.md
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Achieve coverage goals: environment variable parsing and validation, type checking and error handling, default value handling, custom type validation, plugin integration with Vite, and real project build testing using examples as fixtures
Applied to files:
packages/arkenv/package/README.mdpackages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to **/package.json : Use workspace:* protocol for workspace dependencies between packages
Applied to files:
packages/internal/scope/package.jsonpackages/arkenv/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to {packages,apps,tooling}/**/package.json : When referencing workspace packages in dependencies, use the `workspace:*` protocol instead of version numbers
Applied to files:
packages/internal/scope/package.jsonpnpm-workspace.yamlpackages/arkenv/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to package.json : The project uses `pnpm10.20.0` as specified in the `packageManager` field
Applied to files:
packages/internal/scope/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to package.json : Configure only built dependencies (native modules) in `pnpm.onlyBuiltDependencies`, including: biomejs/biome, sentry/cli, swc/core, tailwindcss/oxide, vercel/speed-insights, esbuild, and sharp
Applied to files:
packages/internal/scope/package.jsonpnpm-workspace.yamlpackages/arkenv/package.json
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: packages/arkenv should not depend on other workspace packages; packages/vite-plugin depends on arkenv; apps/www may depend on workspace packages
Applied to files:
packages/internal/scope/package.jsonpnpm-workspace.yamlpackages/arkenv/package.json
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Applied to files:
packages/vite-plugin/src/index.tspackages/arkenv/src/create-env.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to pnpm-workspace.yaml : Use pnpm for package management with workspace support
Applied to files:
pnpm-workspace.yamlpackages/arkenv/package.json
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Always run `pnpm changeset` for version bumps in published packages - never skip changesets
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.html : Use HTML imports with `Bun.serve()` and don't use Vite for frontend bundling and development
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.{ts,tsx,js,jsx,html,css} : Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild` for bundling
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to tooling/playwright-www/**/*.spec.ts : Use Playwright for end-to-end tests
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.{html,tsx,jsx} : Use HTML imports with `Bun.serve()` instead of Vite for frontend development
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to tooling/playwright-www/**/*.spec.ts : Test complete user workflows and validate real browser behavior across Chromium, Firefox, and WebKit in end-to-end tests
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to tooling/playwright-www/**/*.{ts,tsx} : End-to-end tests should be located in `tooling/playwright-www/` and test complete user workflows in real browsers with no mocking
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to **/*.test.{ts,tsx} : Test individual functions, components, and hooks in isolation with mocked dependencies in unit tests
Applied to files:
pnpm-workspace.yaml
🧬 Code graph analysis (3)
packages/vite-plugin/src/index.ts (4)
packages/arkenv/src/type.ts (1)
type(3-3)packages/vite-plugin/src/types.ts (1)
ImportMetaEnvAugmented(56-59)packages/internal/types/src/schema.ts (3)
EnvSchemaWithType(5-5)SchemaShape(3-3)SchemaShape(4-4)packages/arkenv/src/create-env.ts (2)
EnvSchema(7-7)createEnv(35-53)
packages/internal/keywords/turbo.json (1)
.github/actions/size-limit/src/config.ts (2)
Config(2-10)Config(13-39)
packages/arkenv/src/create-env.ts (4)
packages/arkenv/src/index.ts (2)
EnvSchema(1-1)createEnv(13-13)packages/internal/scope/src/index.ts (1)
$(9-19)packages/internal/types/src/schema.ts (3)
EnvSchemaWithType(5-5)SchemaShape(3-3)SchemaShape(4-4)packages/internal/types/src/infer-type.ts (1)
InferType(9-17)
🪛 LanguageTool
packages/arkenv/package/README.md
[style] ~129-~129: Using many exclamation marks might seem excessive (in this case: 5 exclamation marks for a text that’s 2639 characters long)
Context: ...the project by starring it on GitHub! You are also welcome to directly [cont...
(EN_EXCESSIVE_EXCLAMATION)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test-e2e (e2e)
- GitHub Check: test-e2e (a11y)
🔇 Additional comments (21)
.gitignore (1)
45-46: LGTM!Adding esbuild-generated debugging artifacts to
.gitignoreis a standard housekeeping practice that aligns with the PR's package config updates.packages/internal/scope/turbo.json (1)
1-10: Per-package Turbo configuration is correct and consistent.The configuration properly extends the root Turbo config using the
["//"]syntax and defines a locally-scopedsizetask. This pattern is consistently applied across packages/arkenv, packages/internal/keywords, and packages/internal/scope, with identical configurations. Disabling cache for thesizetask is appropriate for an analysis task, and thedependsOn: ["build"]dependency is correct. The explanatory comment accurately reflects the intent—defining the task per-package prevents unnecessary builds of all packages when runningturbo run size.packages/internal/scope/vitest.config.ts (1)
1-7: LGTM!The Vitest configuration is correctly structured and follows the standard pattern for defining a project-specific test configuration. The test name "@repo/scope" properly identifies this internal package's tests within the monorepo.
packages/internal/keywords/vitest.config.ts (1)
1-7: LGTM!The Vitest configuration is correctly structured and follows the same pattern as the scope package configuration. The test name "@repo/keywords" properly identifies this internal package's tests within the monorepo. Consistent configuration structure across internal packages aids maintainability.
pnpm-workspace.yaml (2)
8-30: Catalog formatting change: quote style normalization.Lines 9–17 show quote style changes (double to single quotes) for consistency. This is purely cosmetic and aligns with maintainability best practices. No version changes or functional impact.
32-35: Overrides section reordering noted.The overrides block has been reorganized (moved to the bottom of the file). The entries (
@playwright/test,import-in-the-middle,require-in-the-middle) remain unchanged in content. This is a stylistic change with no functional impact on pnpm's resolution behavior.packages/internal/keywords/src/index.test.ts (1)
2-2: LGTM!The import path change from
"./types"to"./index"follows the barrel export pattern, making the package's public API clearer and more maintainable.packages/internal/keywords/turbo.json (1)
1-10: LGTM!The per-package Turbo configuration correctly defines a
sizetask with build dependency and disabled caching, preventing unnecessary package builds during size checks.packages/arkenv/src/type.ts (1)
1-1: LGTM!The import path change to
"@repo/scope"aligns with the new internal package structure, improving modularity and maintainability.packages/internal/scope/src/index.ts (1)
1-1: LGTM!The import source change to
"@repo/keywords"correctly uses the new internal package for built-in validators, maintaining separation of concerns.Based on learnings: This follows ArkType's scoped type system pattern for defining custom types.
packages/internal/scope/tsconfig.json (1)
1-19: LGTM!The TypeScript configuration correctly sets up strict compilation options with bundler module resolution, appropriate for an internal library package using tsdown for builds.
packages/arkenv/package.json (1)
43-44: Remove workspace package dependencies that violate architectural boundaries.arkenv imports
@repo/scopeinsrc/type.tsandsrc/create-env.ts, making it a runtime dependency rather than just a dev tool. Since the architectural guidelines explicitly state thatpackages/arkenvshould not depend on other workspace packages, these imports create coupling that violates the project's boundaries. The$type system from@repo/scopeis embedded into arkenv's public API through these imports.Either:
- Move the necessary type definitions from
@repo/scopedirectly into arkenv, or- Establish an exception in the architectural rules if
@repo/scopeis intended as a shared internal utilityThe
@repo/keywordsand@repo/typesdevDependencies should also be audited for similar coupling.packages/arkenv/package/README.md (1)
1-133: Well-structured README with comprehensive documentation.The README effectively covers:
- Branding and ecosystem positioning
- Clear code examples using ArkType syntax (aligning with project conventions)
- Installation instructions for all major package managers
- Requirements section with TypeScript and moduleResolution constraints
- Links to plugins and further documentation
The static analysis hint about exclamation marks is a false positive for README marketing content—the tone is appropriate for engaging documentation.
packages/vite-plugin/src/index.ts (2)
60-66: Overload structure correctly handles both schema types.The overload ordering (specific
EnvSchemaWithTypefirst, then genericEnvSchema<T>) follows TypeScript best practices for function overloading, ensuring proper type inference for both use cases.
76-84: Type assertions documented as workaround—acceptable interim solution.The explicit
createEnv<T>call and<SchemaShape>envcast are documented via the TODO comment as workarounds for "excessively deep" instantiation errors. This is a reasonable approach while maintaining runtime correctness. Consider tracking this as technical debt to revisit when ArkType/TypeScript provides better inference.packages/bun-plugin/src/index.ts (3)
12-21: Generic constraint and TODO documentation align with vite-plugin pattern.The
processEnvSchema<T extends SchemaShape>signature and the documented workaround for deep instantiation errors are consistent with the vite-plugin implementation, ensuring uniform behavior across plugins.
89-92: Empty catch block intentionally ignores file read errors.The
catch {}without an error variable correctly follows the existing behavior of returningundefinedto let Bun handle unreadable files. This is a valid pattern per recent TypeScript/JavaScript support for empty catch bindings.
127-134: Overloads correctly mirror vite-plugin structure.The three-signature pattern (
EnvSchemaWithType,EnvSchema<T>, implementation) maintains API consistency across the plugin ecosystem.packages/arkenv/src/create-env.ts (3)
1-7: Clean import reorganization with proper type separation.The imports are well-organized:
- Internal scope from
@repo/scope- Public types from
@repo/types- ArkType utilities as
atnamespace alias (avoiding collision with localtype)- Local
typefrom./typefor error checkingThe
EnvSchema<def>type alias correctly usesat.validatefor compile-time schema validation against the scoped type system.
23-38: Overload structure provides comprehensive type inference.The four signatures handle:
EnvSchemaWithType(pre-defined ArkType) →InferType<T>EnvSchema<T>(raw schema object) →distill.Out<at.infer<T, ...>>- Union type for flexibility
- Implementation with default
env = process.envThis pattern enables type-safe usage for both raw schema objects and pre-constructed ArkType definitions, aligning with the PR objective to improve input types.
39-52: Runtime validation logic correctly preserved.The implementation:
- Detects ArkType definitions via
typeof def === "function" && "assert" in def- Falls back to
$.type.raw()for raw schema objects- Throws
ArkEnvErroron validation failures (per coding guidelines)This maintains backward compatibility while supporting the new overloaded signatures.
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
packages/arkenv/src/create-env.test.ts (1)
169-173: Avoidas neverhere; it defeats the improved typing.
Envis already the result oftype({ INVALID_PORT: "number.port" })and should be assignable to theEnvSchemaWithTypebranch ofcreateEnv. Casting it toneverbypasses the very type guarantees this PR is adding and mirrors the earlier concern about heavy casts.Please try removing the cast and fixing types at the
createEnv/EnvSchemaWithTypelevel if needed instead of escaping withas never:- expect(() => createEnv(Env as never)).toThrow(/INVALID_PORT/); + expect(() => createEnv(Env)).toThrow(/INVALID_PORT/);If this still doesn’t type‑check, it’s a strong signal the generics around
SchemaShape/EnvSchemaWithTypeneed a small adjustment rather than a cast.
🧹 Nitpick comments (1)
packages/internal/types/src/schema.ts (1)
1-6: Clarify value vs type alias naming forSchemaShape.You export both a value and a type alias named
SchemaShape. TypeScript allows this, but it’s easy to misread which one is being referenced. If the runtimeSchemaShapeinstance is only used to derive the alias, consider either not exporting it or renaming one of them (e.g.SchemaShapeTypefor the type alias orschemaShapeTypefor the value) to keep the intent obvious.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (3)
packages/arkenv/src/create-env.test.ts(5 hunks)packages/internal/types/package.json(1 hunks)packages/internal/types/src/schema.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/internal/types/package.json
🧰 Additional context used
📓 Path-based instructions (5)
packages/arkenv/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/arktype.mdc)
packages/arkenv/**/*.ts: Use ArkType'stype()function to define schemas in environment variable definitions
Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Use the scoped$type system for custom types defined inscope.ts
Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Use union types for enums in ArkType schemas (e.g.,"'dev' | 'prod'") instead of separate enum definitions
Leverage ArkType's built-in types (e.g.,string.host,number.port) where possible in environment schemas
Convert ArkType validation errors toArkEnvErrorfor user-friendly error messages that include variable name and expected type
Files:
packages/arkenv/src/create-env.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)
**/*.{ts,tsx}: Prefertypeoverinterfacefor type definitions in TypeScript
Use TypeScript 5.1+ features when appropriate
Leverageconsttype parameters for better inference in TypeScript
Use JSDoc comments for public APIs
Use tabs for indentation (configured in Biome)
Use double quotes for strings (configured in Biome)
Organize imports automatically (Biome handles this)
Avoid explicit types when TypeScript can infer them (noInferrableTypeserror)
Useas constwhere appropriate for immutable values (useAsConstAssertionerror)
Don't reassign function parameters (noParameterAssignerror)
Place default parameters last in function signatures (useDefaultParameterLasterror)
Always initialize enum values (useEnumInitializerserror)
Declare one variable per statement (useSingleVarDeclaratorerror)
Avoid unnecessary template literals (noUnusedTemplateLiteralerror)
PreferNumber.parseIntover globalparseInt(useNumberNamespaceerror)
Use kebab-case for TypeScript filenames (e.g.,create-env.ts)
Use camelCase for function names (e.g.,createEnv)
Use PascalCase for type names (e.g.,ArkEnvError)
Use UPPER_SNAKE_CASE for environment variables and constants
Include examples in JSDoc comments when helpful for public APIs
Document complex type logic with JSDoc comments
UseArkEnvErrorfor environment variable validation errors
Provide clear, actionable error messages that include the variable name and expected type
**/*.{ts,tsx}: UsecreateEnv(schema)as the main function for validated environment objects, available as the default export
Use built-in validators (host, port, url, email) fromsrc/types.tswhen available instead of custom validation
UseArkEnvErrorfor environment variable errors, not generic errors
Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Use logical grouping for related environment variables in schemas
Use descriptive env...
Files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)
Co-locate tests with components:
Component.tsxnext toComponent.test.tsx
**/*.test.{ts,tsx}: Test individual functions, components, and hooks in isolation with mocked dependencies in unit tests
Keep unit tests fast with execution under 100ms per test
Co-locate unit tests with source files using naming convention:source.ts→source.test.ts
Focus component tests on public API, user behavior, state transitions, and accessibility rather than styling or implementation details
Query component tests by role, name, label, and text using accessibility-first selectors
Use Vitest as the test framework for unit and integration tests
Use Testing Library withuser-eventfor real user simulation in component tests
**/*.test.{ts,tsx}: Test individual functions, components, and hooks in isolation with mocked dependencies using the*.test.tsor*.test.tsxsuffix
Mockprocess.envin tests for different scenarios and save/restore original env inbeforeEach/afterEachhooks
Use Vitest'sdescribe/itstructure in test files
Test edge cases including invalid and missing environment variable values
Use Vitest for testing framework
Files:
packages/arkenv/src/create-env.test.ts
packages/arkenv/src/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Main library implementation should be in
src/create-env.ts, built-in validators insrc/types.ts, error handling insrc/errors.ts, and utilities insrc/utils.ts
Files:
packages/arkenv/src/create-env.test.ts
**/*.{ts,tsx,json,md}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use Biome for linting and formatting instead of ESLint and Prettier
Files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts
🧠 Learnings (23)
📓 Common learnings
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use the scoped `$` type system for custom types defined in `scope.ts`
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 498
File: apps/playgrounds/node/index.ts:2-2
Timestamp: 2025-12-05T20:33:10.676Z
Learning: ArkType 2.1.28+ supports Standard Schema specification, allowing interoperability with other Standard Schema-compliant validation libraries (e.g., Zod, Valibot) within the same schema definition
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `createEnv(schema)` as the main function for validated environment objects, available as the default export
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Mock `process.env` in tests for different scenarios and save/restore original env in `beforeEach`/`afterEach` hooks
Applied to files:
packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to packages/arkenv/src/**/*.ts : Main library implementation should be in `src/create-env.ts`, built-in validators in `src/types.ts`, error handling in `src/errors.ts`, and utilities in `src/utils.ts`
Applied to files:
packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use `as const` where appropriate for immutable values (`useAsConstAssertion` error)
Applied to files:
packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Avoid explicit types when TypeScript can infer them (`noInferrableTypes` error)
Applied to files:
packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use descriptive environment variable names that indicate purpose and format
Applied to files:
packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Leverage `const` type parameters for better inference in TypeScript
Applied to files:
packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Test edge cases including invalid and missing environment variable values
Applied to files:
packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Provide clear, actionable error messages that include the variable name and expected type
Applied to files:
packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Avoid unnecessary template literals (`noUnusedTemplateLiteral` error)
Applied to files:
packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use logical grouping for related environment variables in schemas
Applied to files:
packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable validation errors
Applied to files:
packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas
Applied to files:
packages/arkenv/src/create-env.test.tspackages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use the scoped `$` type system for custom types defined in `scope.ts`
Applied to files:
packages/internal/types/src/schema.ts
🧬 Code graph analysis (2)
packages/arkenv/src/create-env.test.ts (3)
packages/arkenv/src/type.ts (1)
type(3-3)packages/arkenv/src/create-env.ts (1)
createEnv(35-53)packages/arkenv/src/index.ts (1)
createEnv(13-13)
packages/internal/types/src/schema.ts (2)
packages/arkenv/src/type.ts (1)
type(3-3)packages/internal/scope/src/index.ts (1)
$(9-19)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: test-e2e (e2e)
- GitHub Check: test-e2e (a11y)
- GitHub Check: test-build (lts/*)
🔇 Additional comments (4)
packages/arkenv/src/create-env.test.ts (4)
117-123: Good switch to passing ArkTypetype()definitions directly.Defining
const Env = type({ ... })and callingcreateEnv(Env)exercises the newEnvSchemaWithTypepath and keeps tests aligned with the public API.
132-141: Letting TypeScript inferenvmember types is preferable here.Reusing
Env = type({ ... })and then assigningconst str = env.TEST_STRING; const port = env.TEST_PORT;without explicit annotations ensures the test actually relies on the new type inference instead of duplicating types manually, which matches the “avoid inferrable types” guideline.
150-160: Nice coverage for reusing a singleEnvdefinition.Using the same
Envtype definition with different custom env objects (env1,env2) is a solid regression test for the “define once, reuse everywhere” story aroundtype()output. No issues spotted.
177-188: Custom env +type()definitions test looks solid.This case nicely validates that
createEnvworks with ArkTypeEnvdefinitions and a custom env object (including parsing"8080"into anumber.port). The scenario is representative of real plugin usage; no changes needed.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @arkenv/bun-plugin@0.0.2 ### Patch Changes - #### Fix "Type instantiation is excessively deep" error _[`#511`](#511) [`0a44dcd`](0a44dcd) [@yamcodes](https://github.com/yamcodes)_ Fixed "Type instantiation is excessively deep and possibly infinite" errors when using the plugins with complex ArkType schemas. This was [reported](#497) in the ArkEnv Vite Plugin along with [ArkType 2.1.28](https://github.com/arktypeio/arktype/blob/HEAD/ark/type/CHANGELOG.md#2128), and was fixed by an overall improvement of type stability including optimizing how generics are passed to the validation logic. <details><summary>Updated 1 dependency</summary> <small> </small> - `arkenv@0.7.6` </details> ## @arkenv/vite-plugin@0.0.19 ### Patch Changes - #### Fix "Type instantiation is excessively deep" error _[`#511`](#511) [`0a44dcd`](0a44dcd) [@yamcodes](https://github.com/yamcodes)_ Fixed "Type instantiation is excessively deep and possibly infinite" errors when using the plugins with complex ArkType schemas. This was [reported](#497) in the ArkEnv Vite Plugin along with [ArkType 2.1.28](https://github.com/arktypeio/arktype/blob/HEAD/ark/type/CHANGELOG.md#2128), and was fixed by an overall improvement of type stability including optimizing how generics are passed to the validation logic. <details><summary>Updated 1 dependency</summary> <small> </small> - `arkenv@0.7.6` </details> ## @repo/types@0.0.1 ### Patch Changes - #### Add Schema types _[`#511`](#511) [`0a44dcd`](0a44dcd) [@yamcodes](https://github.com/yamcodes)_ Add Schema types to internal types package, including `EnvSchemaWithType` and `SchemaShape`. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Closes #501
Summary by CodeRabbit
Release Notes
Bug Fixes
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.