- ALL API keys and secrets MUST be stored in
.envfile only - Never commit
.envfile to git (already in.gitignore) - Use
.env.exampleas a template (no real keys)
The following secrets are required in .env:
GOOGLE_API_KEY- Google AI Studio API keySLACK_BOT_TOKEN- Slack bot OAuth token (starts withxoxb-)SLACK_APP_TOKEN- Slack app-level token (starts withxapp-)SLACK_SIGNING_SECRET- Slack signing secretLANGCHAIN_API_KEY- (Optional) LangSmith API key
- Go to https://aistudio.google.com/app/apikey
- Sign in with Google account
- Click "Create API Key"
- Copy the key (starts with
AIzaSy...) - Add to
.env:GOOGLE_API_KEY=AIzaSy...
- Go to https://api.slack.com/apps
- Select your app
- Get tokens from "OAuth & Permissions" and "Basic Information"
Before committing code, verify no secrets are exposed:
# Check git status (should NOT show .env)
git status
# Search for potential API key patterns
grep -r "AIzaSy" . --exclude-dir=.git --exclude="*.md" --exclude=".env"
grep -r "xoxb-" . --exclude-dir=.git --exclude="*.md" --exclude=".env"
# Verify .env is in .gitignore
grep "^\.env$" .gitignore-
Immediately revoke the leaked key:
- Google AI Studio: https://aistudio.google.com/app/apikey (delete the key)
- Slack: Regenerate tokens in your app settings
-
Generate new key and update
.env -
Remove from git history (if committed):
# Use git filter-branch or BFG Repo-Cleaner # Then force push (destructive operation)
✅ DO:
- Store all secrets in
.env - Use
.env.examplefor documentation - Add
.envto.gitignore - Rotate keys periodically
- Use different keys for dev/prod
❌ DON'T:
- Commit
.envfile - Put keys in code comments
- Put keys in TODO, README, or other docs
- Share keys via chat/email (use secure channels)
- Use production keys for testing
✅ .env file in .gitignore
✅ .env.example contains placeholders only
✅ No API keys in tracked files (TODO.txt, README.md, etc.)
✅ All secrets properly isolated
Run this command to verify no secrets in tracked files:
git ls-files | xargs grep -l "AIzaSy\|xoxb-\|xapp-" || echo "✅ No secrets found in tracked files"