From 6b3170fea6190bc4de702ad7051555d22ce3f66a Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Fri, 13 Feb 2026 20:17:39 +0000 Subject: [PATCH] fix(commands): handle CLAUDE.md symlink in claude-to-agents command Some projects use a symlink from CLAUDE.md to AGENTS.md instead of an @-reference. Add a symlink check as the first precondition so these are detected and replaced with a proper @AGENTS.md reference file. Co-Authored-By: Claude Opus 4.6 --- claude/commands/claude-to-agents.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/claude/commands/claude-to-agents.md b/claude/commands/claude-to-agents.md index 54d1186..0c1aa13 100644 --- a/claude/commands/claude-to-agents.md +++ b/claude/commands/claude-to-agents.md @@ -5,6 +5,7 @@ description: Convert a project's CLAUDE.md into an agent-agnostic AGENTS.md file ## Context - Check if `CLAUDE.md` and `AGENTS.md` exist in the project root. +- Check if `CLAUDE.md` is a symlink (e.g., `ls -la CLAUDE.md`). ## Your Task @@ -14,6 +15,7 @@ Convert this project's `CLAUDE.md` into an `AGENTS.md` file, and replace ## Steps 1. **Verify preconditions**: + - If `CLAUDE.md` is a symlink pointing to `AGENTS.md`, skip to step 8. - If neither `CLAUDE.md` nor `AGENTS.md` exist, abort with an error message. - If `CLAUDE.md` does not exist but `AGENTS.md` does, skip to step 7. - If both exist, abort — suggest using `AGENTS.md` directly or removing it @@ -71,3 +73,13 @@ Convert this project's `CLAUDE.md` into an `AGENTS.md` file, and replace ``` - Report that `CLAUDE.md` was created as a reference to the existing `AGENTS.md`. + +8. **Replace symlink with `@`-reference** (only reached when `CLAUDE.md` is a + symlink to `AGENTS.md`): + - Remove the `CLAUDE.md` symlink. + - Write a new `CLAUDE.md` file containing just: + ``` + @AGENTS.md + ``` + - Report that the symlink was replaced with an `@`-reference to + `AGENTS.md`.