Claude Code sessions often work with production systems, debug logs, and sensitive data. This document provides security guidelines to prevent accidental exposure of sensitive information.
CRITICAL: Always run this checklist before committing or pushing code.
Before running git commit or git push, verify:
# See what will be committed
git status
# Review the actual changes
git diff --cached
# List file names only
git diff --cached --name-only# Scan for common secrets in staged changes
git diff --cached | grep -iE "password|secret|token|api.key|credential|private.key" || echo "β
No obvious secrets found"
# Check for email addresses (potential PII)
git diff --cached | grep -E "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}" || echo "β
No emails found"High-risk file types:
.jsonfiles (often contain data exports, API responses, logs).logfiles (production logs with stack traces, errors).envfiles (credentials and configuration).sqlfiles (database dumps with customer data).txtfiles (notes, exports, debug output)history.*files (conversation logs)- Files in
study-logs/,artifacts/,debug/directories
Questions to ask:
- Does this file contain production error messages?
- Are there customer names, emails, or identifiers?
- Are there internal URLs, IPs, or architecture details?
- Could this reveal security vulnerabilities?
Never commit:
- π΄ Credentials: API keys, tokens, passwords, certificates
- π΄ Customer Data: Names, emails, phone numbers, addresses
- π΄ PHI/PII: Health information, SSNs, financial data
- π΄ Production Logs: Error traces, stack dumps, debug output
- π΄ Internal Details: Server IPs, internal URLs, architecture diagrams
- π΄ Conversation History: Claude Code session logs with sensitive discussions
Safe to commit:
- β Configuration files (without secrets)
- β Documentation and README files
- β Code and scripts (without hardcoded credentials)
- β Templates and examples (with placeholder data)
- β Tests (with mock/fake data only)
Your Claude Code configuration repository should ignore:
# Credentials and secrets
credentials/.env
credentials/services/*.json
# Session notes (may contain sensitive discussions)
session-notes/
**/session-notes/
!templates/session-notes/
# Study logs and debug artifacts (often contain production data)
study-logs/
studies/*/artifacts/
studies/*/output/
debug/
# Conversation history
history.jsonl
*.history
# Shell snapshots (command history)
shell-snapshots/
# Data exports and root JSON files
/*.json
!settings.json
!plugins/config.json
# TODO lists (may contain internal company info)
todos/
# Project tracking (kept local)
projects/Add patterns specific to your tech stack:
# Laravel/PHP
.env
.env.local
storage/logs/
bootstrap/cache/
# Node/JavaScript
.env
.env.local
npm-debug.log
yarn-error.log
# Python
.env
*.pyc
__pycache__/
# Database dumps
*.sql
*.sqlite
*.db
# Debug and log files
*.log
logs/
debug/
tmp/Option 1: Uncommit (safest)
# Undo the commit but keep changes
git reset --soft HEAD~1
# Remove sensitive files from staging
git reset HEAD <sensitive-file>
# Add to .gitignore
echo "<sensitive-file>" >> .gitignore
# Commit again without sensitive files
git add .
git commit -m "Your commit message"Option 2: Amend commit
# Remove file from staging
git reset HEAD <sensitive-file>
# Amend the commit
git add .
git commit --amend
# Add to .gitignore
echo "<sensitive-file>" >> .gitignoreCRITICAL: Act quickly - data may already be exposed
Step 1: Remove from tracking
git rm --cached <sensitive-file>
git commit -m "Remove sensitive file from tracking"Step 2: Purge from history
# Using git filter-branch (built-in)
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch <sensitive-file>' \
--prune-empty --tag-name-filter cat -- --all
# Clean up
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now --aggressiveStep 3: Force push
# WARNING: This rewrites history
git push --force origin <branch>Step 4: Rotate compromised secrets
- If credentials were exposed, rotate them immediately
- Check logs for unauthorized access
- Notify security team if customer data was exposed
Before starting any debugging or study:
# Add patterns to .gitignore first
echo "study-logs/" >> .gitignore
echo "debug-output/" >> .gitignore
echo "*.log" >> .gitignore# Create ignored directories for debugging
mkdir -p ~/.claude-local/debug/
mkdir -p ~/.claude-local/logs/
# Add to global gitignore
echo "~/.claude-local/" >> ~/.gitignore_globalMake it a habit:
- Run
git status- see what's staged - Run
git diff --cached- review actual changes - Ask: "Would I be comfortable with this on GitHub?"
- Only then:
git commit
# Conversation logs (may contain customer names, internal discussions)
history.jsonl
# Study artifacts (often contain production error traces, stack dumps)
study-logs/This helps future you remember WHY files are excluded.
High risk - Often work with production logs, error traces, customer data
Extra precautions:
- Store all debug output in
debug/orstudy-logs/(both ignored) - Never commit error logs or stack traces
- Redact customer names/emails before saving examples
Medium risk - May create test data or debug output
Extra precautions:
- Use fake data in tests (not real customer info)
- Review .env.example files (should have placeholders, not real values)
Medium risk - Configuration changes, may reference internal tools
Extra precautions:
- Check that credentials/README.md doesn't contain actual credentials
- Ensure .gitignore is comprehensive before committing
Low risk - Side projects usually don't have sensitive data
Still verify:
- No accidentally committed API keys
- No personal information you don't want public
# Before committing - security scan
git diff --cached | grep -iE "password|secret|token|api.key|credential"
# See what will be committed
git status && git diff --cached --name-only
# Unstage a sensitive file
git reset HEAD <file>
# Remove file from git but keep local copy
git rm --cached <file>
# Check entire repo for potential secrets (use with caution - slow)
git grep -iE "password|secret|token|api.key" -- '*.json' '*.log' '*.env'
# Verify .gitignore is working
git check-ignore -v <file>When in doubt, DON'T commit.
It's always easier to add a file later than to remove it from git history.
The Three Questions:
- β Is this safe for the public to see?
- β Does this contain any customer or production data?
- β Would I show this file to a stranger?
If you answer "no" or "maybe" to any of these - don't commit it.
Last Updated: October 20, 2025 Reason: Added after production data exposure incident in study-logs/