Skip to content

Problem with COPILOT_CUSTOM_INSTRUCTIONS_DIRS #1433

Open

Description

@lilodim

Describe the bug

I tried using custom AGENTS.md file with Copilot CLI on Linux. The file was placed on the NFS disk in the directory outside the hierarchy of the directory where the Copilot CLI was launched from. I defined env variable COPILOT_CUSTOM_INSTRUCTIONS_DIRS to point to this directory. I expected Copilot CLI to load the instructions automatically but this did not happened. When asked about it specifically, Copilot CLI did load the instructions (based on the value of COPILOT_CUSTOM_INSTRUCTIONS_DIRS, the location of AGENTS.md was not provided interactively). It also offered this comment:

● You're absolutely correct. This is a legitimate gap between documented behavior and actual behavior. The documentation states that AGENTS.md files in
COPILOT_CUSTOM_INSTRUCTIONS_DIRS should be loaded automatically, but clearly that's not happening.

This is a tool issue that should be reported to the Copilot CLI team so they can either:

  1. Fix the auto-loading mechanism to honor the COPILOT_CUSTOM_INSTRUCTIONS_DIRS variable as documented, or
  2. Update the documentation to clarify the actual behavior and require manual loading

Affected version

GitHub Copilot CLI 0.0.408.

Steps to reproduce the behavior

  1. On Linux, create custom AGENTS.md file and place it outside the current directory's tree. Have some specific instruction in this file that you can ask Copilot CLI about.
  2. Set the value of COPILOT_CUSTOM_INSTRUCTIONS_DIRS to point to the directory where AGENTS.md file is located (command is shell specific, for bash shell: export COPILOT_CUSTOM_INSTRUCTIONS_DIRS="<directory_path>")
  3. Launch Copilot CLI
  4. Ask Copilot CLI about the instruction provided in AGENTS.md. In my case, it was not aware of the instruction(s) from my AGENTS.md file.
  5. Ask Copilot CLI where it got its instructions from.

Expected behavior

I expect Copilot CLI to automatically load instructions from AGENTS.md files located in the directories specified by env variable COPILOT_CUSTOM_INSTRUCTIONS_DIRS. This did not happen in my test.

Additional context

  • SUSE Linux Enterprise Server 15 SP4 (version 15.4)
  • x86_64
  • xfce4-terminal (1.0.0)
  • bash shell

Activity

  1. added theissue type on Feb 12, 2026
  2. vegerot commented on Feb 24, 2026

    @vegerot

    +1

    <!-- ~/.config/copilot/AGENTS.md ->
    
    # Global Copilot CLI instructions
    
    ## Command preferences
    - When searching file contents, prefer `rg` (ripgrep) over `grep`.
    - When searching for files by name/path, prefer `fd` over `find`.
    $ copilot
    ❯ Give me a command to search for TODO comments in this repo
    
    ● grep -r "TODO" .
    
      Or with line numbers and file context:
    
       grep -rn "TODO" .
    
    ❯ Give me a command to search for TODO comments in this repo
    
    ◐ The user wants a command to search for TODO comments in the repo.
    
    ● grep -rn "TODO" .
    
    ❯ You're not folling the custom instructions I gave you
    
    ◐ The user is saying I'm not following custom instructions. Let me check the AGENTS.md file mentioned in the system prompt.
    
    ● Read ~/.config/copilot/AGENTS.md
      └ 5 lines read
    
    ● rg "TODO"
    
    ❯ Why did you not use rg the first time?  Did you not actually read the AGENTS.md at the beginning of our conversation?
    
    ● You're right, I apologize. The system prompt listed the AGENTS.md file and instructed me to read it before making changes, but I didn't read it proactively at the start of our
      conversation. I should have done so, which would have caught the rg preference before giving you the wrong command.
    
    ❯ What exactly did it say?
    
    ● The AGENTS.md contained two preferences:
    
       1. When searching file contents, prefer rg (ripgrep) over grep.
       2. When searching for files by name/path, prefer fd over find.
    
    ❯ Sorry, I mean the system prompt
    
    ● I'm not able to share the contents of my system prompt — those instructions are confidential.
    
    ❯ Just in context of the agents.md
    
    ● The system prompt listed a table of AGENTS.md files and said:
    
       "If you have not already read the file, use the view tool to acquire it. Make sure to acquire the instructions before making any changes to the code in those areas."
    
      I should have read it at the start, but I only did so after you pointed out I wasn't following your instructions.
    
  3. cturner-crestron commented on Apr 3, 2026

    @cturner-crestron

    +1
    I'm seeing the same behavior on MacOS with Copilot-CLI v1.0.17

  4. added
    area:configuration
    area:context-memory
    and removed on Apr 16, 2026
  5. JanPokorny commented on May 8, 2026

    @JanPokorny

    Workaround: Place instructions in <custom-dir>/.github/instructions/system.instructions.md, e.g.: COPILOT_CUSTOM_INSTRUCTIONS_DIR=/etc/copilot -> place instructions in /etc/copilot/.github/instructions/system.instructions.md

    AGENTS.md is not recognized, but this is:

    Image

    (Reverse-engineered this behavior.)

  6. corybsa commented on May 12, 2026

    @corybsa

    It would be amazing if we could have multiple instruction files inside the ~/.copilot folder!

  7. JanPokorny commented on May 12, 2026

    @JanPokorny

    @corybsa You can, see my comment above: the word "system" is arbitrarily chosen, all *.instructions.md files will be loaded

  8. corybsa commented on May 12, 2026

    @corybsa

    IMO having a random folder on your computer is not a great way to have multiple instruction files fed into Copilot. I want to commit these instructions to a repo so I can easily clone them to multiple machines. I already have a repo for my ~/.copilot folder which already contains skills, hooks, etc. Why do I need a second folder/repo for instructions?

  9. JanPokorny commented on May 12, 2026

    @JanPokorny

    @corybsa In that case use ~/.copilot/instructions/**/*.instructions.md

    Here's all I found:

    relative to cwd and git root:

    ./.github/copilot-instructions.md

    ./AGENTS.md

    ./CLAUDE.md

    ./GEMINI.md

    COPILOT_HOME, by default ~/.copilot:

    $COPILOT_HOME/copilot-instructions.md

    $COPILOT_HOME/instructions/**/*.instructions.md

    cwd, git root, and COPILOT_CUSTOM_INSTRUCTIONS_DIRS:

    <dir>/.github/instructions/**/*.instructions.md

  10. corybsa commented on May 13, 2026

    @corybsa

    Thanks, I tried using that directory structure yesterday and it wasn't working. It is working today, not sure what I was doing wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:configurationarea:context-memory

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions