[BUG] fileSuggestion custom command not working

Resolved 💬 4 comments Opened Feb 3, 2026 by mauriziofonte Closed Mar 4, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The fileSuggestion custom command feature does not work in the VS Code extension and only partially works in CLI mode. When it does work (CLI), the query string is never passed to the custom script.

VS Code Extension

The custom fileSuggestion script is never invoked when using @ autocomplete. The built-in file suggestion is used instead, ignoring the user's configuration entirely.

CLI Mode

The script is invoked correctly, but:

  • CLAUDE_PROJECT_DIR is passed correctly
  • The query is NOT passed via stdin, environment variable, or argument
  • Documentation states the script should receive {"query": "user_input"} via stdin, but stdin is empty

What Should Happen?

  1. VS Code Extension: Should invoke the custom fileSuggestion command when configured
  2. CLI Mode: Should pass the user's query via stdin as JSON {"query": "firefox"} when the user types @firefox

Debugging Methodology

To diagnose this issue, I modified my custom file-suggest.sh script to add comprehensive logging:

1. Diagnostic Beacon (always writes, regardless of debug mode)

BEACON_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/claude/logs/file-suggest-beacon.log"
mkdir -p "$(dirname "$BEACON_FILE")" 2>/dev/null || true
{
    echo "=== BEACON $(date '+%Y-%m-%d %H:%M:%S.%3N') PID=$$ ==="
    echo "  CLAUDE_PROJECT_DIR=${CLAUDE_PROJECT_DIR:-<unset>}"
    echo "  PWD=$(pwd)"
    echo "  Args: $*"
    echo "  stdin is tty: $([ -t 0 ] && echo 'yes' || echo 'no')"
} >> "$BEACON_FILE" 2>/dev/null || true

2. Detailed Debug Logging

Added timestamped logging with timing information:

LOG_FILE="$LOG_DIR/file-suggest-$(date +%Y%m%d-%H%M%S)-$$.log"
LOG_START_TIME=$(date +%s%3N)

log() {
    echo "[$(date '+%H:%M:%S.%3N')] $*" >> "$LOG_FILE"
}

log_timing() {
    local checkpoint="$1"
    local current_time=$(date +%s%3N)
    local elapsed=$((current_time - LOG_START_TIME))
    echo "[$(date '+%H:%M:%S.%3N')] [TIMING +${elapsed}ms] $checkpoint" >> "$LOG_FILE"
}

3. stdin Reading with Timeout

Implemented non-blocking stdin read with 500ms timeout:

if [ ! -t 0 ]; then
    input=""
    log "Attempting to read stdin (non-tty detected)..."
    if read -t 0.5 -r first_line 2>/dev/null; then
        input="$first_line"
        log "  First line received: '${first_line:0:50}'"
        while IFS= read -t 0.1 -r line 2>/dev/null; do
            input+=$'\n'"$line"
        done
    else
        log "  read -t 0.5 returned non-zero (no data or timeout)"
    fi
    log "stdin input received (${#input} bytes): ${input:0:100}..."
fi

Error Messages/Logs

All diagnostic logs are collected through file-suggest.sh and are stored in:

  • Beacon: ~/.cache/claude/logs/file-suggest-beacon.log
  • Debug: ~/.cache/claude/logs/file-suggest-YYYYMMDD-HHMMSS-PID.log

CLI Invocation Log

[14:38:16.518] --- CONTEXT ---
[14:38:16.519] CLAUDE_PROJECT_DIR (raw): /home/{user}/subfolder/my-project
[14:38:16.520] CLAUDE_QUERY: <not set>
[14:38:16.520] Arg $1: <not set>
[14:38:16.521] stdin is tty: no
[14:38:16.537] Attempting to read stdin (non-tty detected)...
[14:38:16.538]   read -t 0.5 returned non-zero (no data or timeout)
[14:38:16.539] stdin input received (0 bytes): ...
[14:38:16.541] Query parsed: '' (source: none)

Beacon Log (CLI only - VS Code never triggers)

=== BEACON 2026-02-03 14:38:16.510 PID=319301 ===
  CLAUDE_PROJECT_DIR=/home/{user}/subfolder/my-project
  PWD=/home/{user}/subfolder/my-project
  Args:
  stdin is tty: no

Manual Test (works correctly)

$ echo '{"query":"test"}' | CLAUDE_PROJECT_DIR=/path/to/project ./file-suggest.sh
# Returns filtered file list in ~80ms

Error Messages/Logs

Steps to Reproduce

VS Code Extension (complete failure)

  1. Add to ~/.claude/settings.json:

``json
{
"fileSuggestion": {
"type": "command",
"command": "/home/{user}/.claude/scripts/file-suggest.sh"
}
}
``

  1. Add diagnostic beacon to script (writes to log on every invocation)
  2. Open VS Code with Claude Code extension
  3. Type @ followed by any text
  4. Check beacon log - no entries appear (script never invoked)

CLI Mode (query not passed)

  1. Same configuration as above
  2. Run claude in terminal
  3. Type @firefox in the prompt
  4. Check beacon log - entry appears but:
  • Args: is empty
  • stdin contains 0 bytes
  • Query is never received

Workaround

VS Code: None - feature appears completely non-functional in extension mode.

CLI: The script can return all project files (unfiltered) since CLAUDE_PROJECT_DIR works. Filtering by query is impossible.

Environment

  • Claude Code Version: 2.1.3
  • Platform: Linux (WSL2 Ubuntu on Windows)
  • OS Version: Linux 6.6.87.2-microsoft-standard-WSL2
  • Terminal/Shell: bash 5.x
  • VS Code: Latest with Claude Code extension

Configuration

~/.claude/settings.json:

{
  "fileSuggestion": {
    "type": "command",
    "command": "/home/{user}/.claude/scripts/file-suggest.sh"
  }
}

Script is executable (chmod +x) and works correctly when invoked manually.

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.29 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

Tested Input Methods

The script was designed to accept query from multiple sources (in priority order):

  1. stdin JSON: {"query": "search_term"} - documented method, never receives data
  2. Command argument: $1 - never passed
  3. Environment variable: CLAUDE_QUERY - never set

Tested Path Formats

  • Tilde path: ~/.claude/scripts/file-suggest.sh - doesn't work
  • Absolute path: /home/{user}/.claude/scripts/file-suggest.sh - doesn't work in VS Code, partially works in CLI

Script Verification

$ ls -la ~/.claude/scripts/file-suggest.sh
-rwxr-xr-x 1 maurizio maurizio 20174 Feb  3 14:06 /home/{user}/.claude/scripts/file-suggest.sh

$ head -1 ~/.claude/scripts/file-suggest.sh
#!/bin/bash

Documentation vs Reality

The settings documentation states:

Input: JSON via stdin with query field Output: Newline-separated file paths

Reality:

  • VS Code: Script never invoked
  • CLI: Script invoked but stdin is empty (0 bytes), query never passed

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗