Created
October 14, 2025 16:37
-
-
Save kylefox/027b7f51465d9b1bd7c4b93f362b3464 to your computer and use it in GitHub Desktop.
bash function to recursively symlink all `AGENTS.md` → `CLAUDE.md` files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sync_claude_symlinks() { | |
| local dir="${1:-$PWD}" | |
| if [[ ! -d "$dir" ]]; then | |
| print -u2 "sync_claude_symlinks: directory not found: $dir" | |
| return 1 | |
| fi | |
| local base="${dir:A}" | |
| local -a claude_links agents_files | |
| claude_links=("${(@f)$(command find "$base" -type l -name CLAUDE.md -print 2>/dev/null)}") | |
| for link in $claude_links; do | |
| command rm "$link" && printf 'Unlinked %s\n' "${link#$base/}" | |
| done | |
| agents_files=("${(@f)$(command find "$base" -type f -name AGENTS.md -print 2>/dev/null)}") | |
| for file in $agents_files; do | |
| local dir_path="${file:h}" | |
| local claude_path="$dir_path/CLAUDE.md" | |
| command ln -sf AGENTS.md "$claude_path" && printf 'Linked %s -> %s\n' "${file#$base/}" "${claude_path#$base/}" | |
| done | |
| local -a matches | |
| matches=("${(@f)$(command find "$base" \( -name AGENTS.md -o -name CLAUDE.md \) -print 2>/dev/null)}") | |
| if (( ${#matches} )); then | |
| command ls -1 "${matches[@]}" | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment