.gitignore Generator for AI Projects

A .gitignore that keeps secrets and AI junk out of your repo.

  • $19 Free
  • 30 sec
  • No signup
1

Pick your language and AI tools

2

Toggle secret + build patterns to ignore

3

Copy the .gitignore into your repo root

You get: A .gitignore that protects secrets and ignores the right AI files.

Pick your stacks

.gitignore

# Generated by Claude Code Club .gitignore generator

# Node
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
.pnpm-store/
dist/
build/
.cache/
*.tsbuildinfo

# Environment and secrets
.env
.env.*
!.env.example
*.pem
*.key
secrets/
credentials.json

# Claude Code
.claude/settings.local.json
.claude/*.local.json

# macOS
.DS_Store
.AppleDouble
.LSOverride
Icon
._*

# VS Code
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json
*.code-workspace

# Logs and temp files
*.log
logs/
tmp/
temp/
*.tmp

Save this as .gitignore in your repo root. If a file is already tracked, git keep-tracking it - run git rm --cached on it after adding the rule.

Why a .gitignore matters more in AI projects

A .gitignore tells git which files to leave out of version control. In an AI-assisted project the stakes are higher than usual for two reasons. First, tools like Claude Code, Cursor, and aider write local config and cache files into your repo that should not be shared. Second, AI workflows lean heavily on API keys in .env files, and a single committed key can drain a funded account. A tight .gitignore is the cheapest insurance you will ever add to a repo.

The generator above lets you check the stacks and tools you actually use - Node, Python, macOS, VS Code, JetBrains, Claude Code, and more - and stitches them into one clean, commented .gitignore. It groups entries under headers so the file stays readable, and it always includes a way to keep an .env.example while ignoring the real .env.

The secret-safety patterns, explained

  • .env and .env.* - ignore every environment file so no real secrets land in git. This is the single most important line in the file.
  • !.env.example - the leading ! un-ignores a file. This keeps a committed template so teammates know which variables to set, without exposing your values.
  • *.pem and *.key - private keys and certificates should never be tracked.
  • secrets/ and credentials.json - common folders and filenames where keys hide.

A gitignore does not un-track already-committed files

If you already committed a secret, adding it to .gitignore does nothing on its own - git keeps tracking it. Run git rm --cached path/to/file, commit, and treat the key as compromised: rotate it immediately.

What to ignore from Claude Code and other AI tools

Claude Code keeps a .claude folder in your project. You usually want to commit .claude/settings.json so the team shares one config, but you should ignore .claude/settings.local.json and any *.local.json, because those hold machine-specific overrides and sometimes personal paths. The generator's Claude Code block does exactly this - it ignores the local files while leaving the shared settings tracked. Other tools like Cursor, aider, Continue, and Windsurf each drop their own dot-folders, and the AI tools block sweeps those up.

Language and OS blocks

The Node block ignores node_modules, build output, and debug logs. The Python block covers __pycache__, virtual environments, and the caches that pytest, mypy, and ruff leave behind. The OS blocks handle the junk your operating system sprinkles into folders - .DS_Store on macOS, Thumbs.db on Windows - which is noise nobody wants in a diff. Editor blocks for VS Code and JetBrains ignore the bulk of their config while keeping the handful of shared settings worth committing.

How to apply the file

  1. Save the generated text as .gitignore in your repository root.
  2. If nothing is tracked yet, you are done - git respects the rules from the next add onward.
  3. If a file you now want ignored is already tracked, run git rm --cached path and commit the removal.
  4. Add an .env.example with placeholder values so teammates know what to fill in.
  5. Double-check with git status that no secret files appear as staged or tracked.

Keeping the file honest over time

Revisit your .gitignore whenever you add a new tool or language to the project. It is easy for a new AI assistant or a new cache folder to start leaking into commits unnoticed. A quick habit that pays off: before your first commit on a fresh clone, glance at git status and confirm the only untracked things are files you actually intend to add. If something surprising shows up, it belongs in the ignore file.

Frequently asked questions

  • Should I commit the .claude folder?

    Commit .claude/settings.json so your team shares one config, but ignore .claude/settings.local.json and other *.local.json files. Those hold machine-specific overrides that should stay off git.

  • How do I ignore .env but keep an example?

    Ignore .env and .env.*, then add !.env.example to un-ignore the template. The leading exclamation mark re-includes a file that a broader rule matched.

  • I already committed a secret - now what?

    Adding it to .gitignore does not remove it. Run git rm --cached on the file, commit, and rotate the key immediately, since it is in your git history and must be treated as leaked.

  • Does order matter in a .gitignore?

    For negation it does. A !un-ignore rule must come after the broad rule it re-includes. Otherwise, later matching rules can win, so keep exceptions below the patterns they override.

  • Why ignore node_modules if it can be reinstalled?

    Because it is huge, machine-specific, and fully reproducible from package.json and the lockfile. Committing it bloats the repo and creates noisy diffs with zero benefit.

  • Can I use both a global and a project .gitignore?

    Yes. A global gitignore is good for personal OS and editor junk that applies to every repo, while the project .gitignore handles stack-specific and secret patterns the whole team needs.

Liked this tool? The club is the next step.

Join Claude Code Club for $9/month. 650+ lessons, weekly updates, and the workflows behind every tool on this site.

  • No experience needed
  • Cancel anytime
  • Updated weekly