claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Claude Code not finding custom commands in ~/.claude/commands or ./claude/commands

Open mattmaslin opened this issue 6 months ago • 19 comments

Environment

  • Platform (select one):
    • [X] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
  • Claude CLI version: 0.2.124
  • Operating System: Windows 11 - Ubuntu WSL
  • Terminal: Windows Terminal

Bug Description

Claude Code CLI tool fails to discover and load custom commands stored in the expected directories (~/.claude/commands or ./claude/commands).

Steps to Reproduce

  1. Create a test.md file under ~/.claude/commands or ./claude/commands
  2. Start Claude CLI with claude command
  3. No custom commands appear when trying to access via /user:test or /project:test

Expected Behavior

Files under ~/.claude/commands should load as /user: commands and ./claude/commands should load as /project: commands in the Claude CLI.

Actual Behavior

No custom commands available

Debugging Information

  1. Verified that the command files exist in the correct locations
  2. No error messages are displayed when claude starts or with --debug

Additional Context

Custom commands were functioning correctly in previous versions. This issue appeared after the latest update.

mattmaslin avatar May 21 '25 13:05 mattmaslin

I tested loading claude from a new directory and the /user:* prompts showed up. If I renamed the folder in ~/.claude/projects to a different name, the prompts showed up for existing projects when I restarted Claude

mattmaslin avatar May 21 '25 17:05 mattmaslin

I'm having this same issue.

I don't use /user: commands and mostly have only /project: commands, but I can't seem to get them to load.

This happened with a recent update of about 2 days ago if I'm not mistaken.

nsouto avatar May 21 '25 19:05 nsouto

Same issue, started happening to me today.

davidpp avatar May 21 '25 20:05 davidpp

Hi! Are you running claude from the same directory that your .claude folder is in, or from another directory?

bcherny avatar May 21 '25 20:05 bcherny

Hi! Are you running claude from the same directory that your .claude folder is in, or from another directory?

Yes, running from an existing project with a .claude/commands folder does not load the .md files as /project: command or the user scoped ones.

  1. Running claude for the first time in a new folder loads them correctly
  2. renaming the project file in ~/.claude/projects will fix an older projects.

mattmaslin avatar May 21 '25 21:05 mattmaslin

Started seeing this yesterday. Today with 0.2.126 it seems to have gone from intermittently loading .claude/commands to never loading.

codelahoma avatar May 22 '25 15:05 codelahoma

Same issue

quigles1977 avatar May 22 '25 18:05 quigles1977

I'm having the same issue too. Also with v1

krisquigley avatar May 22 '25 19:05 krisquigley

This fixed the issue for me on MacOS: (I believe its some kind of caching issue)

1. Stop Claude Code

pkill -f claude

2. Backup your commands

cp -r .claude/commands/ ~/Desktop/claude-commands-backup/

3. Remove all Claude Code data

rm -rf ~/.claude/ rm -rf ~/Library/Preferences/com.anthropic.claude-code.plist rm -rf ~/Library/Caches/com.anthropic.claude-code/ rm -rf ~/Library/Application\ Support/Claude\ Code/

4. Reinstall Claude Code

npm uninstall -g @anthropic-ai/claude-code npm install -g @anthropic-ai/claude-code

5. Restore commands

mkdir -p .claude/commands/ cp -r ~/Desktop/claude-commands-backup/* .claude/commands/

quigles1977 avatar May 23 '25 09:05 quigles1977

Same issue here

ctrlbrk42 avatar May 24 '25 08:05 ctrlbrk42

For me, running rm -r ~/.claude/projects/-path-to-your-project (and restarting the session?) resolved the issue where commands were not being recognized with / on WSL Ubuntu.

ywatanabe1989 avatar May 24 '25 10:05 ywatanabe1989

What I ended up doing was modifying .claude/settings.json and adding the 'cleanupPeriodDays' and kept lowering it and re-loading Claude. It eventually got rid of whichever JSONL was causing the problem. Prior to this I tried jq and all passed validation, so who knows. But I am just happy to have my custom commands back.

ctrlbrk42 avatar May 24 '25 11:05 ctrlbrk42

For me, running rm -r ~/.claude/projects/-path-to-your-project (and restarting the session?) resolved the issue where commands were not being recognized with / on WSL Ubuntu.

This seems to be the simplest solution on WSL Ubuntu.

shyraptor avatar May 24 '25 12:05 shyraptor

I ran running into this issue on a Ubuntu machine that is not WSL, but SSH'd via VS Code in from a Windows computer (if that is relevant).

Running rm -rf ~/.claude/projects and relaunching the session fixed it for me.

uditrana avatar May 28 '25 20:05 uditrana

I started using the function below to remove the last n history json file(s) and this seems working.

cld_reset_history() {
    # Delete the latest n JSONL files from Claude project history
    # Usage: cld_reset_history [num_files]
    # Default: deletes 1 file if num_files not specified
    
    GREEN='\033[0;32m'
    YELLOW='\033[0;33m'
    RED='\033[0;31m'
    NC='\033[0m'
    echo_success() { echo -e "${GREEN}$@${NC}"; }
    echo_warning() { echo -e "${YELLOW}$@${NC}"; }
    echo_error() { echo -e "${RED}$@${NC}"; }

    local num_files=${1:-1}
    local current_path="$(realpath $(pwd))"
    local cld_project_name=$(echo "$current_path" | sed 's|/|-|g' | sed 's|\.|-|g' | sed 's|_|-|g')
    local cld_history_dir="$HOME/.claude/projects/$cld_project_name"

    if [ ! -d "$cld_history_dir" ]; then
        echo_error "Claude project directory not found: $cld_history_dir"
        return 1
    fi

    files_to_delete=($(ls -t --color=never "$cld_history_dir"/*.jsonl 2>/dev/null | head -n $num_files))

    if [ ${#files_to_delete[@]} -eq 0 ]; then
        echo_warning "No JSONL files found"
        return 1
    fi

    for file in "${files_to_delete[@]}"; do
        rm -f "$file"
        if [ ! -f "$file" ]; then
            echo_success "Deleted: $(basename $file)"
        else
            echo_error "Failed to remove: $(basename $file)"
        fi
    done
}

ywatanabe1989 avatar May 29 '25 15:05 ywatanabe1989

I'm still seeing this today on version 1.0.31 on macos. What's more concerning is that commands don't work at all, this isn't just an auto-completion/UX issue. For example I have a custom command at ~/.claude/commands/commit.md, and if I type /user:commit in Claude it doesn't even load the file.

sadly the shared workarounds aren't usable for me because I don't even have a projects directory under ~/.claude

Really crazy that such a huge issue has been open for a month with no fix.

rcdailey avatar Jun 21 '25 04:06 rcdailey

Hi @rcdailey

I noticed that the prefix syntax for user/project level specification has been removed in recent versions. The new format appears to be /commit <markdown contents> (user), though I am not sure for MacOS.

ywatanabe1989 avatar Jun 21 '25 04:06 ywatanabe1989

Watch out with newer versions of claude code on macos. For some reason my configuration path changed from

~/.claude to ~/.config/claude

Moving my commands folder to ~/.config/claude fixes the issue of not discovering commands for me.

See #1455

kauffinger avatar Jun 21 '25 13:06 kauffinger

Yes via another issue I realized that nothing was actually broken, there's just apparently a lack of proper documentation updates when changes are made to claude code. I verified everything works great after moving all my files to ~/config/claude.

Thanks for the follow up replies!

rcdailey avatar Jun 21 '25 19:06 rcdailey

Looks like there might be a bug in v1.0.62 on native Windows that makes it not recognize commands anymore. Downgrading and disabling auto updates fixed the issue for me.

npm un -g @anthropic-ai/claude-code   
npm i -g @anthropic-ai/[email protected]
claude config set -g autoUpdates disabled

Just be sure to turn autoUpdates back on once the issue is resolved.

Edit: Looks like that autoUpdate config isn't honored and claude still updates once it starts up 🙄

JustMaier avatar Jul 29 '25 03:07 JustMaier

Looks like there might be a bug in v1.0.62 on native Windows that makes it not recognize commands anymore. Downgrading and disabling auto updates fixed the issue for me.

npm un -g @anthropic-ai/claude-code
npm i -g @anthropic-ai/[email protected] claude config set -g autoUpdates disabled Just be sure to turn autoUpdates back on once the issue is resolved.

Edit: Looks like that autoUpdate config isn't honored and claude still updates once it starts up 🙄

Thank you, this method is very helpful

konbakuyomu avatar Jul 29 '25 04:07 konbakuyomu

This should be resolved in v1.0.63.

ant-kurt avatar Jul 30 '25 01:07 ant-kurt

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Aug 06 '25 14:08 github-actions[bot]