pgpm-env
Original:🇺🇸 English
Translated
Manage PostgreSQL environment variables with profile support using pgpm env commands. Use when asked to "set up database environment", "load postgres env vars", "run command with database connection", "use supabase locally", or when needing to configure database connection for commands.
2installs
Added on
NPX Install
npx skill4agent add constructive-io/constructive-skills pgpm-envTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →PGPM Env
Manage PostgreSQL environment variables with profile support using the command.
pgpm envWhen to Apply
Use this skill when:
- Setting up environment variables for database connections
- Running commands that need PostgreSQL connection info
- Switching between local Postgres and Supabase profiles
- Deploying PGPM modules with correct database settings
- Running tests or scripts that need database access
Quick Start
Load Environment Variables
bash
eval "$(pgpm env)"This sets the following environment variables:
PGHOST=localhostPGPORT=5432PGUSER=postgresPGPASSWORD=passwordPGDATABASE=postgres
Run Command with Environment
bash
pgpm env pgpm deploy --database mydbThis runs with the PostgreSQL environment variables automatically set.
pgpm deploy --database mydbProfiles
Default Profile (Local Postgres)
bash
eval "$(pgpm env)"| Variable | Value |
|---|---|
| |
| |
| |
| |
| |
Supabase Profile
bash
eval "$(pgpm env --supabase)"| Variable | Value |
|---|---|
| |
| |
| |
| |
| |
Command Reference
Print Environment Exports
bash
pgpm env # Default Postgres profile
pgpm env --supabase # Supabase profileOutput (for shell evaluation):
bash
export PGHOST="localhost"
export PGPORT="5432"
export PGUSER="postgres"
export PGPASSWORD="password"
export PGDATABASE="postgres"Execute Command with Environment
bash
pgpm env <command> [args...]
pgpm env --supabase <command> [args...]Examples:
bash
pgpm env createdb mydb
pgpm env pgpm deploy --database mydb
pgpm env psql -c "SELECT 1"
pgpm env --supabase pgpm deploy --database mydbCommon Workflows
Development Setup
bash
# Start database container
pgpm docker start
# Load environment into current shell
eval "$(pgpm env)"
# Now all commands have database access
createdb myapp
pgpm deploy --database myappRunning Tests
bash
# Run tests with database environment
pgpm env pnpm test
# Or load into shell first
eval "$(pgpm env)"
pnpm testPGPM Deployment
bash
# Deploy to a specific database
pgpm env pgpm deploy --database constructive
# Verify deployment
pgpm env pgpm verify --database constructiveSupabase Local Development
bash
# Start Supabase locally (using supabase CLI)
supabase start
# Load Supabase environment
eval "$(pgpm env --supabase)"
# Deploy modules to Supabase
pgpm deploy --database postgresShell Integration
Bash/Zsh
Add to your shell profile for automatic loading:
bash
# ~/.bashrc or ~/.zshrc
alias pgenv='eval "$(pgpm env)"'
alias pgenv-supa='eval "$(pgpm env --supabase)"'Then use:
bash
pgenv # Load default Postgres env
pgenv-supa # Load Supabase envOne-liner Commands
bash
# Create database and deploy in one command
pgpm env bash -c "createdb mydb && pgpm deploy --database mydb"Environment Variables Reference
The command sets standard PostgreSQL environment variables that are recognized by:
pgpm env- and other PostgreSQL CLI tools
psql - Node.js library
pg - PGPM CLI commands
- Any tool using libpq
| Variable | Description |
|---|---|
| Database server hostname |
| Database server port |
| Database username |
| Database password |
| Default database name |
Troubleshooting
| Issue | Solution |
|---|---|
| "Connection refused" | Ensure database container is running with |
| Wrong database | Check |
| Auth failed | Verify password matches container settings |
| Supabase not connecting | Ensure Supabase is running on port 54322 |
| Env vars not persisting | Use |
References
For related skills:
- Docker container management: See skill
pgpm-docker - Running tests: See skill
pgpm-testing