Developer Guides

Secrets, Git Discipline, and the Mistakes That Kill Projects

Eric Hoyer

Eric Hoyer founded Growth Automations so owner-operators don't have to wrestle with software or go up against big companies alone. He's run WordPress sites for 15 years.

Updated 4 min read
Checklist

The short version

On day one, put .env in .gitignore and block your AI from reading it. Commit before every session, so a bad session costs minutes, not a week. Test the things that would hurt most if they broke quietly.

Some mistakes cost you an afternoon. Others cost you the project, your users’ trust or real money. Three practices prevent the catastrophic kind: git discipline, secrets management and testing. The order matters, so secrets come first.

Day one: keep secrets out of git

Do this before your first commit, not after:

echo ".env" >> .gitignore
echo ".env.*" >> .gitignore
echo "!.env.example" >> .gitignore

The last line keeps the example file trackable while every real .env file stays ignored.

Keep secrets out of the AI’s reach

AI coding tools read the files they can reach, and that includes .env unless you say otherwise. Once a key has been in an AI conversation, you no longer control where it goes.

Where does your
API key live?

Written in the code:
exposed in every commit

.env not in .gitignore:
exposed in git history

.env the AI can read:
exposed to the AI

.env ignored and blocked:
safe for development

Host secret settings or a vault:
safe for production

Every red box is avoidable. In Claude Code, add a deny rule to .claude/settings.json in your project. This is the example from Claude Code’s own settings documentation:

{
  "permissions": {
    "deny": ["Read(./.env)", "Read(./.env.*)"]
  }
}

For production, keep keys in your hosting platform’s secret settings or a vault such as Doppler, 1Password or AWS Secrets Manager. .env is a fine place to start, not to finish.

If a key has ever been in git or an AI conversation, replace it

Deleting the file doesn’t help: the key is still in the git history or the conversation. Create a new key with the provider, switch to it, and revoke the old one. A leaked development key is a contained incident. A leaked production key is not.

Commit before every session

It’s easy to be in flow, shipping fast, and then the AI takes a strange turn and there’s no clean point to go back to. Losing a week of work to one bad session happens to almost everyone who codes with AI seriously.

  1. Run git status and read the list. Nothing in it should be a secret; if it is, fix .gitignore first.
  2. Stage the files: git add -A, safe only once .gitignore is right.
  3. Commit with a breadcrumb: git commit -m "checkpoint: before [feature]".
  4. Push, because your laptop is not a backup: git push.

Three rules: commit before the AI starts, not after it works; commit to a remote; and keep messages short but findable.

When a session goes wrong

Start with the gentlest option that works:

# Put the changes aside, but keep a copy you can get back
git stash

# Throw away changes to one file
git restore path/to/file

`git reset --hard` deletes your uncommitted work for good

Use it only when you’re sure nothing since the last commit is worth keeping. Never use it to undo commits you’ve already pushed and shared; use git revert <commit> instead, which undoes a commit by adding a new one.

# Discard everything since the last commit (cannot be undone)
git reset --hard HEAD

# Go back to an earlier commit that hasn't been pushed
git log --oneline
git reset --hard <hash>

Test what would hurt most

Testing isn’t dogma. It’s about not flying blind. Ask one question before each feature: if this breaks silently in production, how bad is it? The worse the answer, the more tests it needs.

  • Start with the data layer. Tests that run from the command line, with no browser, give the fastest feedback. If the data behaves, half the bugs are already gone.
  • Calibrate the front end. A landing page can be checked by eye. A screen with many states and user actions needs automated tests on its main paths.
  • Ask for tests first:
Write tests first for [feature]. Then write the code to make
them pass. Run the tests and fix until they're all green.

Writing the tests first makes the AI think about expected behaviour before it writes code.

If you have a database, a ten-second smoke test before you build screens on top of it catches connection, permission and schema problems early:

async function smokeTest() {
  const { data, error } = await supabase.from("your_table").select("*").limit(1);
  if (error) throw new Error(`Data layer broken: ${error.message}`);
  console.log("Data layer OK:", data);
}

The three together

Git discipline gives you the safety net to move fast. Secrets management prevents the breach that ends a project overnight. Testing catches silent failures before users do. Skip one and the other two can’t make up for it.


Next: back to the full guide, or start at AI Context Files.

Sources, last checked Nov 21, 2026

Stay in the loop

Get practical guides, workflows, and automation tips delivered to your inbox.

No spam, ever. Unsubscribe anytime.