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
In this repository38 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- api-contract-validationSkill
- architecture-scannerSkill
- auto-approve-policySkill
- auto-learningSkill
- backend-patternsSkill
- branch-syncSkill
- browser-testSkill
- browseSkill
- build-checkSkill
- cache-refreshSkill
- codebase-explainerSkill
- coding-standardsSkill
- commit-styleSkill
- context-switchingSkill
- continuous-learningSkill
- db-preflightSkill
- eval-harnessSkill
- feature-completenessSkill
- file-indexSkill
- frontend-patternsSkill
- function-extractSkill
- idev-initSkill
- import-graphSkill
- lessons-learnedSkill
- post-creation-verifySkill
- pre-ship-verifySkill
- project-mapSkill
- self-reviewSkill
- session-resumeSkill
- skill-benchmarkSkill
- skilloptSkill
- smart-contextSkill
- strategic-compactSkill
- task-journalSkill
- tdd-workflowSkill
- test-coverageSkill
- test-mapSkill
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
- Distinctive: line 35
Never continue into deeper subdirectories without surfacing this.
- Very specific: line 92
If CLAUDE_SANDBOX_ENABLED=true: briefly note which common operations (rm, git push --force, installs) typically need …
- Very specific: line 105
If anything fails, output each issue on its own line prefixed with [env-preflight] WARN: or [env-preflight] FAIL:.
- Distinctive: line 111
Do NOT fix git auth — report and stop.
- Distinctive: line 112
Do NOT print raw connection strings.
- Distinctive: line 113
Do NOT run this after every prompt — SessionStart only (or explicit user request).
- Distinctive: line 114
Do NOT block the session on warnings — only hard FAIL (e.g., no git repo at all) should stop work.
≈ “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.
Files
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
pwdPass: 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
fiPass: 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
- Do NOT fix git auth — report and stop.
- Do NOT print raw connection strings.
- Do NOT run this after every prompt — SessionStart only (or explicit user request).
- Do NOT block the session on warnings — only hard FAIL (e.g., no git repo at all) should stop work.
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
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.

