Observed since 21 Oct, 10:27 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
A pre-commit hook for managing symlinks to AI configuration files stored in a hidden directory
A pre-commit hook for managing symlinks to AI configuration files stored in a hidden directory.
Many AI tools (Claude Code, Gemini, etc.) require configuration files like CLAUDE.md, GEMINI.md, and project-specific files like specs/, templates/, and memory/ to be present at the repository root. However, committing these files directly to your main branch can clutter your repository and create merge conflicts when working across branches.
This pre-commit hook solves this by:
.llm/).gitignore to prevent accidental commits of symlinked filesAdd this to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/shyndman/ai-deroot-pre-commit
rev: v0.0.9 # Use the ref you want to point at
hooks:
- id: setup-managed-symlinks
- id: check-managed-symlinks
- id: update-gitignore-for-symlinks
repos:
- repo: https://github.com/shyndman/ai-deroot-pre-commit
rev: v0.0.9
hooks:
# Sets up symlinks after checkout/merge
- id: setup-managed-symlinks
args:
- --hidden-dir=.llm
- --files=CLAUDE.md,GEMINI.md,specs,templates,memory
- --migrate=move # or copy
# Validates symlinks during normal commits
- id: check-managed-symlinks
args:
- --hidden-dir=.llm
- --files=CLAUDE.md,GEMINI.md,specs,templates,memory
# Ensures .gitignore includes symlinked files
- id: update-gitignore-for-symlinks
args:
- --hidden-dir=.llm
- --files=CLAUDE.md,GEMINI.md,specs,templates,memory
setup-managed-symlinksWhen it runs: post-checkout, post-merge
Creates symlinks from the repository root to files in your hidden directory. This ensures that after switching branches or pulling changes, your LLM configuration files are always available where tools expect them.
Features:
.ai, .llm, etc.)check-managed-symlinksWhen it runs: pre-commit (when hidden directory or .gitignore changes)
Validates that all expected symlinks exist and point to the correct locations. Prevents commits when symlinks are broken or missing.
Features:
update-gitignore-for-symlinksWhen it runs: pre-commit
Automatically adds symlinked files to .gitignore to prevent accidental commits. This hook will modify .gitignore and require you to stage the changes.
Features:
.gitignore.gitignore content--hidden-dirSpecifies the directory where master files are stored.
--hidden-dir=.llm.--filesComma-separated list of files/directories to manage as symlinks.
--files=CLAUDE.md,GEMINI.md,specs,templates,memoryInitial setup:
# Create your hidden directory and files
mkdir .llm
echo "# Claude Configuration" > .llm/CLAUDE.md
mkdir .llm/specs
# Install pre-commit hooks
pre-commit install-hooks
# Create initial symlinks
pre-commit run --hook-stage post-checkout setup-managed-symlinks
After setup, symlinks are created automatically:
git checkout main
# setup-managed-symlinks runs automatically
# Creates: CLAUDE.md -> .llm/CLAUDE.md
# specs -> .llm/specs
The .gitignore is updated automatically:
git add file.py
git commit -m "Add feature"
# update-gitignore-for-symlinks runs
# Adds entries to .gitignore if needed
If you have existing files at the target locations, the setup-managed-symlinks hook will warn you and not overwrite them. You'll need to manually resolve these conflicts by either:
.gitignore if the file should be trackedThe hooks are designed to run at specific stages:
setup-managed-symlinks: post-checkout, post-merge - Ensures symlinks exist after branch operationscheck-managed-symlinks: pre-commit - Validates before commits (only when relevant files change)update-gitignore-for-symlinks: pre-commit - Updates .gitignore before commitsWhen you add or remove files from the --files argument, you must also update the files regex in the check-managed-symlinks hook configuration to ensure it runs at the appropriate times.
If you see errors about broken symlinks:
# Run the setup hook manually
pre-commit run --hook-stage post-checkout setup-managed-symlinks
# Or use pre-commit's built-in command
pre-commit install --hook-type post-checkout
If you encounter permission issues with symlinks, ensure your filesystem supports symbolic links and that you have appropriate permissions in the repository directory.
If .gitignore entries aren't being added automatically:
# Run the gitignore hook manually
pre-commit run update-gitignore-for-symlinks
git add .gitignore
git commit -m "Update .gitignore for managed symlinks"
This project uses the uv_build PEP 517 build backend (pure Python). The package is kept at the repository root (no src/ layout) via:
[build-system]
requires = ["uv_build>=0.9.3,<0.10.0"]
build-backend = "uv_build"
[tool.uv.build-backend]
module-root = ""
module-name = "ai_deroot_pre_commit"
pre-commit installs this hook using its Python language backend by building and installing the package in an isolated environment.
Licensed under the Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0).
--migrateOptionally migrate existing root files into the hidden directory before creating symlinks.
copy or movemove relocates the file/dir into the hidden directorycopy duplicates into the hidden directory; the original is replaced by a symlinkNotes:
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.0.9 | 17 Oct 2025 | 0 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 21 Oct, 10:27 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:f913974e05535f8987c3fc5caf84184d3d57d6386a926879522e4345aeccdf0e