agentleFS
qiaoshouqingqiaoshouqing/skills/env-sync/SKILL.md

env-sync

Skill1 starsChanged 4 months agoMITView on GitHub

Sync .env files from git root repository to worktrees. Use when asked to sync env, copy env, environment file, or when working in a git worktree that is missing a .env file. Automatically detects missing .env in worktrees.

  • Reads credentials

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. ieeecsopen/mcp-cs★ 3same name
    2. FPVE-Webdev/claude-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository6 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 8 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    ALWAYS ask before overwriting: - if .env already exists, confirm with user first

    line 23
  2. Distinctive:

    Validate paths: - ensure the root path exists and is a valid git repository

    line 24
  3. Distinctive:

    No arbitrary paths: - only sync from the actual git root repository

    line 25
  4. Distinctive:

    If not a worktree, inform user this skill is for git worktrees only.

    line 36
  5. Distinctive:

    Always inform user what was done

    line 114
  6. Distinctive:

    If .env already exists: MUST ask user before overwriting

    line 115
  7. Distinctive:

    If root .env doesn't exist: tell user the path checked

    line 116
  8. Distinctive:

    Never display .env file contents

    line 117

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Env Sync - Git Worktree Environment File Synchronization

This skill syncs .env files from a git root repository to git worktrees.

When to Use

  • User asks to sync env or copy env
  • User mentions missing environment variables or .env file
  • Working in a git worktree that lacks a .env file
  • User asks to set up environment for a worktree

Security Rules

  1. NEVER display .env file contents - they contain secrets
  2. ALWAYS ask before overwriting - if .env already exists, confirm with user first
  3. Validate paths - ensure the root path exists and is a valid git repository
  4. No arbitrary paths - only sync from the actual git root repository

Instructions for Agent

Step 1: Check if in a Git Worktree

# Check if .git is a file (worktree) or directory (regular repo)
[ -f .git ] && echo "worktree" || echo "not-worktree"

If not a worktree, inform user this skill is for git worktrees only.

Step 2: Find and Validate Root Repository

# Read gitdir and extract root path
GITDIR=$(cat .git | grep "^gitdir:" | sed 's/gitdir: //')
ROOT_REPO=$(echo "$GITDIR" | sed 's/\.git\/worktrees\/.*//')

# Validate: must be a real git repository
if [ -d "${ROOT_REPO}/.git" ]; then
  echo "Valid root: $ROOT_REPO"
else
  echo "Invalid root path - not a git repository"
  exit 1
fi

Step 3: Check for Existing .env

# IMPORTANT: Always check before copying
if [ -f ./.env ]; then
  echo "WARNING: .env already exists in this worktree"
  # ASK USER before proceeding
fi

If .env exists: STOP and ask user "Do you want to overwrite the existing .env file?"

Step 4: Copy .env (only after user confirmation if needed)

if [ -f "${ROOT_REPO}/.env" ]; then
  cp "${ROOT_REPO}/.env" ./.env
  echo "Synced .env from $ROOT_REPO"
else
  echo "No .env found in root repository: $ROOT_REPO"
fi

Complete Safe Script

# Safe env sync with validation
if [ ! -f .git ]; then
  echo "Not a git worktree"
  exit 1
fi

GITDIR=$(cat .git | grep "^gitdir:" | sed 's/gitdir: //')
ROOT=$(echo "$GITDIR" | sed 's/\.git\/worktrees\/.*//')

# Validate root is a git repo
if [ ! -d "${ROOT}/.git" ]; then
  echo "Invalid: $ROOT is not a git repository"
  exit 1
fi

# Check if .env exists at root
if [ ! -f "${ROOT}/.env" ]; then
  echo "No .env in root: $ROOT"
  exit 1
fi

# Check if local .env exists - MUST ASK USER
if [ -f ./.env ]; then
  echo "WARNING: .env already exists here. Ask user before overwriting."
  exit 0
fi

# Safe to copy
cp "${ROOT}/.env" ./.env
echo "Synced .env from $ROOT"

Response Guidelines

  • Always inform user what was done
  • If .env already exists: MUST ask user before overwriting
  • If root .env doesn't exist: tell user the path checked
  • Never display .env file contents
  • Report only: file exists/copied, line count, file size

Error Handling

SituationAction
Not a worktreeInform user, no action
Invalid root pathWarn user, no action
No root .envTell user path, suggest checking
.env existsAsk user before overwrite
Permission deniedSuggest checking permissions

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.