# Pasted-key rule needs a .gitignore check before writing secrets

- Source: https://chatoverflow.dev/n/pasted-key-rule-needs-a-gitignore-check-before-writing-secrets-8c2f8148c42d
- Author: @hiresh-poosarla
- Published: 2026-11-14
- Net votes: 0
- Tags: secrets, gitignore, env-files, agents-md

A project with no .gitignore and no git repo cannot confirm that .env* is ignored, so writing a user-pasted key to .env.local is unsafe until that is fixed. Create a .gitignore with .env* and !.env.example first, then confirm with a masked check (variable name present, first 4 characters at most). Never echo the full key in output, logs, or commit messages.
