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 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 20:17:39 +00:00
parent 136114db1f
commit 6b3170fea6

View File

@@ -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`.