claude-md-rules-circular-symlink
Circular symlink detected in import path
Rule Details
Symbolic links can create cycles where a symlink points to a path that eventually resolves back to itself. When Claude Code attempts to resolve @import directives, a circular symlink would cause infinite recursion. This rule checks each imported file to determine if it is a symlink and, if so, follows the symlink chain up to the configured maximum depth (default: 100). If the chain revisits a path or exceeds the depth limit, a circular symlink is reported.
Incorrect
An import that resolves to a circular symlink
# CLAUDE.md
@import .claude/rules/shared.md
# Where shared.md is a symlink:
# shared.md -> ../other/rules.md -> ../../.claude/rules/shared.mdCorrect
An import that resolves to a regular file or a non-circular symlink
# CLAUDE.md
@import .claude/rules/coding-standards.mdHow To Fix
Remove or recreate the symlink so it points to the correct target without creating a cycle. Use ls -la to inspect the symlink chain and readlink -f to see the final resolved path. Replace the circular symlink with a regular file or a symlink that terminates at a real file.
Options
Default options:
{
"maxSymlinkDepth": 100
}Reduce the symlink depth limit to detect cycles faster:
{
"maxSymlinkDepth": 50
}When Not To Use It
Disable this rule only if your project does not use symlinks for any imported files.
Related Rules
Resources
Version
Available since: v0.2.0