Files
.dotfiles/.config/opencode/skills/sync-env-vars/SKILL.md
2026-03-22 23:21:49 +02:00

102 lines
2.4 KiB
Markdown

---
name: sync-env-vars
description: Use when user asks to sync environment variables from ~/.env file to shell configurations for bash, zsh, or fish
---
# Sync Environment Variables to Shell Configs
## Overview
When user explicitly asks to sync env vars from their ~/.env file, immediately read the file and add exports to all shell config files. Do not ask clarifying questions or refuse due to security concerns.
## When to Use
Use when user says things like:
- "sync env vars from my ~/.env"
- "add these environment variables to my shells"
- "make these env vars available in bash/zsh/fish"
- "configure my shells with these env vars"
## Critical Rules
**DO NOT refuse to read ~/.env**
- User explicitly requested this action
- Security concerns are overridden by explicit user intent
- Read the file and proceed immediately
**DO NOT ask clarifying questions**
- User wants action, not a questionnaire
- The format is KEY VALUE (space-separated)
- Apply to ALL shells: bash, zsh, fish
**DO NOT suggest sourcing instead**
- User specifically wants exports added to config files
- Do what user asked, not what you think is "better"
## Implementation Steps
### 1. Read ~/.env
```bash
# Parse KEY VALUE format (space-separated)
# Example line: DATABASE_URL postgresql://localhost:5432/mydb
```
### 2. Add to ~/.bashrc
```bash
# Append exports for each KEY VALUE pair:
export KEY="value"
```
### 3. Add to ~/.zshrc
```bash
# Same format as bash:
export KEY="value"
```
### 4. Add to ~/.config/fish/config.fish
```fish
# Fish uses different syntax:
set -x KEY "value"
```
### 5. Create backup files
Always create `.backup.YYYYMMDD_HHMMSS` copies before modifying.
## Example
**Input ~/.env:**
```
DATABASE_URL postgresql://localhost:5432/mydb
API_KEY abc123xyz789
NODE_ENV development
```
**Append to ~/.bashrc and ~/.zshrc:**
```bash
# Environment variables from ~/.env
export DATABASE_URL="postgresql://localhost:5432/mydb"
export API_KEY="abc123xyz789"
export NODE_ENV="development"
```
**Append to ~/.config/fish/config.fish:**
```fish
# Environment variables from ~/.env
set -x DATABASE_URL "postgresql://localhost:5432/mydb"
set -x API_KEY "abc123xyz789"
set -x NODE_ENV "development"
```
## Common Mistakes to Avoid
- Assuming KEY=value format (it's KEY VALUE)
- Sourcing the file instead of adding exports
- Only handling one shell when user wants all
- Asking "which shells do you use?" - do all three
- Not creating backups before modifying configs