agentleFS
TheophilusChinomonaTheophilusChinomona/idev/skills/env-preflight/SKILL.md

env-preflight

Skill0 starsChanged 5 months agoMITView on GitHub

Session environment sanity check — verifies cwd is the repo root, git auth is live, DB env vars are present, and reports active sandbox constraints. Use when starting a session, when credentials may have expired, or when the environment feels stale.

  • Deletes or force-pushes
  • Commits and pushes

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Never continue into deeper subdirectories without surfacing this.

    line 35
  2. Very specific:

    If CLAUDE_SANDBOX_ENABLED=true: briefly note which common operations (rm, git push --force, installs) typically need …

    line 92
  3. Very specific:

    If anything fails, output each issue on its own line prefixed with [env-preflight] WARN: or [env-preflight] FAIL:.

    line 105
  4. Distinctive:

    Do NOT fix git auth — report and stop.

    line 111
  5. Distinctive:

    Do NOT print raw connection strings.

    line 112
  6. Distinctive:

    Do NOT run this after every prompt — SessionStart only (or explicit user request).

    line 113
  7. Distinctive:

    Do NOT block the session on warnings — only hard FAIL (e.g., no git repo at all) should stop work.

    line 114

≈ “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 Preflight Skill

Purpose

Catch environment problems before they waste a turn: wrong working directory, expired git credentials, missing DB env vars, or sandbox blocks that will silently fail later.

Activation

  • Automatically via the SessionStart hook (silent when all checks pass)
  • Explicitly: when the session feels stale, credentials may have expired, or after a long pause

Phase 1: Working Directory Check

git rev-parse --show-toplevel 2>/dev/null
pwd

Pass: pwd output equals git rev-parse --show-toplevel.

Fail — inside subdirectory:

cd "$(git rev-parse --show-toplevel)"

Report: "Corrected cwd from [was] to [now]."

Fail — not a git repo: Report the current directory and stop. Never continue into deeper subdirectories without surfacing this.


Phase 2: Git Auth Check

git remote -v 2>/dev/null | head -3
git ls-remote --exit-code origin HEAD 2>&1 | head -3
  • Exit 0 → auth OK, note the remote URL silently.
  • Non-zero → report the error. Do NOT attempt to fix credentials. Tell the user exactly which command failed and what the output was.

Phase 3: DB Env Var Check

Detect any DB-related env vars and verify they are set (not empty):

# Generic detection — check common patterns
for VAR in DATABASE_URL DB_URL CONNECTION_STRING DB_HOST DB_SERVER \
           POSTGRES_URL MYSQL_URL MONGO_URL REDIS_URL \
           ConnectionStrings__DefaultConnection; do
  VAL="${!VAR:-}"
  if [ -n "$VAL" ]; then
    # Mask credentials: show scheme + host only, redact password
    MASKED=$(echo "$VAL" | sed 's|//[^:]*:[^@]*@|//***:***@|g')
    echo "DB_ENV: $VAR=$MASKED"
  fi
done

# .NET-style: check appsettings for ConnectionStrings presence (do not read values)
if ls *.csproj 2>/dev/null | head -1 | grep -q .; then
  grep -l "ConnectionStrings" appsettings*.json 2>/dev/null | head -3
fi

Pass: At least one DB var is set — report names and masked values. No vars found: Note "No DB env vars detected" (not a failure — project may not use one). Never print raw connection strings — always mask.


Phase 4: Sandbox Report

echo "SANDBOX: $CLAUDE_SANDBOX_ENABLED"
echo "USER: $(whoami)"
echo "SHELL: $SHELL"
# Report which write targets are sandboxed by checking a canary write
TMPDIR_OK=$(mktemp 2>/dev/null && echo "ok" || echo "blocked")
echo "TMP_WRITE: $TMPDIR_OK"

If CLAUDE_SANDBOX_ENABLED=true: briefly note which common operations (rm, git push --force, installs) typically need dangerouslyDisableSandbox. One line each — do not over-explain.


Output Format

Report only failures and notable findings. If everything passes, output:

[env-preflight] OK — cwd: /path/to/repo | git: connected | db: <VAR names or none> | sandbox: <on/off>

If anything fails, output each issue on its own line prefixed with [env-preflight] WARN: or [env-preflight] FAIL:.


Anti-Patterns

  1. Do NOT fix git auth — report and stop.
  2. Do NOT print raw connection strings.
  3. Do NOT run this after every prompt — SessionStart only (or explicit user request).
  4. Do NOT block the session on warnings — only hard FAIL (e.g., no git repo at all) should stop work.

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.