high severityclaude-code

    CLAUDE.md @import Cycle or Broken @include Path — How to Fix Include Resolution

    Error / Silent Skip: @import target missing, circular @include detected, or import depth exceeded 5 hops.

    Direct-Answer Fix Summary

    Claude Code supports @path/to/file.md imports up to 5 recursive hops and skips missing paths or cycles silently. Keep imports strictly one-way (CLAUDE.md -> @AGENTS.md or @docs/topic.md), verify every relative path from the importing file's directory, and never point AGENTS.md back to @CLAUDE.md.

    Broken vs. Fixed Configuration

    Broken: Circular import + dead path
    # CLAUDE.md
    @AGENTS.md
    @/docs/old-testing-guide.md
    
    # AGENTS.md
    @CLAUDE.md   # <-- circular reference!
    Fixed: Acyclic one-way @AGENTS.md pointer
    # CLAUDE.md
    @AGENTS.md
    
    ## Claude Code Specifics
    - Run unit tests via hooks in .claude/settings.json.
    
    # AGENTS.md (canonical leaf — zero back-imports)
    # Project Overview ...
    - When writing tests, read docs/testing.md.

    Why This Happens

    During multi-agent migrations, teams add @AGENTS.md inside CLAUDE.md while an older template inside AGENTS.md still references @CLAUDE.md, creating a cycle. Another frequent mistake is writing @/docs/arch.md with a leading slash or renaming a referenced doc without updating CLAUDE.md.

    Step-by-Step Fix

    1. 01
      Enforce a strict DAG (one-way pointer)

      Make AGENTS.md the leaf source of truth and point CLAUDE.md to @AGENTS.md — never add @CLAUDE.md inside AGENTS.md.

    2. 02
      Use clean relative paths without leading slashes

      Write @docs/testing.md instead of @/docs/testing.md or personal /Users/... absolute paths.

    3. 03
      Flatten import depth to 1–2 levels

      Avoid A -> B -> C -> D chains; Claude Code stops expanding past max depth 5 and debugging becomes opaque.

    4. 04
      Verify all links automatically with AgentLint F5 & F7

      Run agentlint check to catch dead file links and broken @include directives in CI before merge.

    Automated AgentLint Checks That Catch This

    Frequently Asked Questions

    Does @AGENTS.md work inside fenced code blocks?

    No, Claude Code ignores @path tokens inside fenced Markdown code blocks so examples do not accidentally trigger file imports.

    Should I use @AGENTS.md or a git symlink?

    The @AGENTS.md one-line pointer works reliably across Windows, macOS, and Linux without requiring Git core.symlinks configuration.

    Related Troubleshooting Guides