Script Environment Setup

Loads .env.local files before executing standalone TypeScript scripts via dynamic imports.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/rylezhou/arlis --skill script-environment-setup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Script Environment Setup
Source: https://github.com/rylezhou/arlis/tree/main/.agent/skills/script-env-setup
Command: npx skills add https://github.com/rylezhou/arlis --skill script-environment-setup

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the common issue where standalone scripts fail to load environment variables correctly due to import hoisting, leading to process.env being undefined.

Core Features & Use Cases

  • Prevents Import Hoisting Issues: Ensures environment variables are loaded before application modules are evaluated.
  • Dynamic Imports: Utilizes await import() for modules that depend on environment variables.
  • Use Case: When running a verification script that needs to access a database connection string defined in .env.local, this Skill ensures the connection string is available.

Quick Start

Use the script environment setup skill to load your .env.local file before running your verification script.

Frequently Asked Questions about Script Environment Setup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why are environment variables undefined in my TypeScript standalone scripts?

Environment variables are undefined in TypeScript standalone scripts due to import hoisting, which evaluates application modules before the dotenv configuration loads, resulting in empty process.env objects.

How do I load environment variables before module execution in TypeScript scripts?

To load environment variables before module execution in TypeScript scripts, use dynamic imports with await import() for application modules that depend on process.env, ensuring deterministic configuration availability.

How do I use dotenv with dynamic imports in migration scripts?

Use dotenv with dynamic imports in migration scripts by loading your .env.local file first, then employing await import() for application modules requiring those environment variables to prevent undefined process.env errors.

What is the best way to ensure deterministic environment variable availability in utility scripts?

The best way to ensure deterministic environment variable availability in utility scripts is employing dynamic imports to circumvent import hoisting issues, loading configuration settings before application module evaluation begins.

Can I use this script environment setup for verification processes accessing database connection strings?

Yes, you can use this script environment setup for verification processes accessing database connection strings, as it securely loads .env.local files before running scripts that require configuration settings.