agentleFS
RohiRIKRohiRIK/claude-code-config/skills/PreCommitSanitize/SKILL.md

PreCommitSanitize

Skill10 starsChanged 5 months agoMITView on GitHub

Scan staged files for hardcoded home paths, personal identifiers, symlinks, and runtime state before committing to the ~/.claude repo. USE WHEN staging or committing in ~/.claude, or before pushing a dotfiles/config repo to a public GitHub remote.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Before every git add or git commit in ~/.claude, scan staged files for sensitive personal information that should not be pushed to a public …

    line 10
  2. Very specific:

    If any of these appear in git status as tracked, run git rm --cached <file> and add to .gitignore.

    line 72
  3. Distinctive:

    Before staging, run this scan on all files being committed:

    line 76
  4. Distinctive:

    If matches are found:

    line 83

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Pre-Commit Sanitization

When This Applies

Before every git add or git commit in ~/.claude, scan staged files for sensitive personal information that should not be pushed to a public GitHub repository.

What to Catch

Hardcoded Home Paths

Any absolute path containing a username or home directory:

PatternExampleFix
/Users/<username>//Users/jane/.claude/hooks/...~/.claude/hooks/...
/home/<username>//home/deploy/.claude/...~/.claude/...
C:\Users\<username>\C:\Users\jane\...~\.claude\...

Exception: .gitignore rules may use relative paths that are fine.

Personal Identifiers

PatternExampleAction
Email addressesjane@gmail.comRemove or replace with user@example.com
Social media handleslinkedin.com/in/<handle>Remove unless intentionally public (README author section)
Machine hostnames<Name>-MacBook-Pro.localRemove
Usernames in pathsusername embedded in file contentReplace with ~ or $HOME

Exception: README.md author/contact section may intentionally include social links — confirm before removing.

Symlinks

Rule: No symlink inside ~/.claude/ may be committed to git.

Symlinks are always machine-specific — they point to absolute paths on the local filesystem that don't exist on other machines. Committing them breaks clones and leaks personal paths.

ActionWhen
Add to .gitignore under # Symlinks sectionWhen creating any new symlink inside ~/.claude/
Run git rm --cached <path>If a symlink was accidentally tracked

The hooks/git/pre-commit hook auto-detects and blocks staged symlinks (git mode 120000) and adds them to .gitignore automatically. This is a safety net — always add manually first.

Pattern for .gitignore:

# Symlinks (local-only, machine-specific — never commit symlinks to shared tools)
# Rule: ANY symlink inside ~/.claude/ must be listed here.
skills/MySkilLink

Runtime State Files

Files that are managed by Claude Code at runtime and should not be version-controlled:

File/PatternWhy
plugins/installed_plugins.jsonContains absolute install paths with username
plugins/known_marketplaces.jsonContains absolute install paths with username
plugins/install-counts-cache.jsonRuntime cache
security_warnings_state_*.jsonSession-specific state
stats-cache.jsonRuntime cache
settings.json.bakBackup file
*.db, *.db-shm, *.db-walDatabase files
history.jsonlSession history

If any of these appear in git status as tracked, run git rm --cached <file> and add to .gitignore.

How to Check

Before staging, run this scan on all files being committed:

# Check for hardcoded home paths in staged files
git diff --cached --name-only | xargs grep -n '/Users/\|/home/\|C:\\Users\\' 2>/dev/null

If matches are found:

  1. For settings.json hook commands — these require absolute paths (Claude Code limitation). Add settings.json to .gitignore if it contains paths, or accept this as a known trade-off and document it.
  2. For all other files — replace with ~/.claude/ or $HOME/.claude/.
  3. For comments/docs — use ~/.claude/ notation.

Automated Enforcement

The hooks/git/pre-commit hook runs bunx varlock scan --staged for secret detection. For path sanitization, manually verify before committing or add a grep check to the pre-commit hook:

# Add to hooks/git/pre-commit after varlock scan
if git diff --cached --name-only | xargs grep -l '/Users/' 2>/dev/null | grep -v 'settings.json' | grep -qv '.gitignore'; then
  echo "[pre-commit] WARNING: Hardcoded /Users/ paths found in staged files" >&2
  git diff --cached --name-only | xargs grep -n '/Users/' 2>/dev/null | grep -v 'settings.json' | grep -v '.gitignore' >&2
  echo "[pre-commit] Replace with ~/.claude/ before committing" >&2
  exit 1
fi

Known Trade-offs

settings.json hook commands require absolute paths — Claude Code does not expand ~ or $HOME in hook command strings. Options:

  1. Gitignore settings.json — loses version control on hook config
  2. Accept the path leak — username visible but not a security risk
  3. Use env var in a wrapper — hook commands call a shell script that resolves $HOME

Current decision: keep settings.json tracked, accept that the username is visible. The file contains no secrets — only hook wiring with absolute paths.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.