Feature request: Plugin command argument completions API

Resolved 💬 2 comments Opened Mar 31, 2026 by anipotts Closed May 6, 2026

Problem

Plugins can define slash commands with argument-hint in frontmatter, but there's no way to provide dynamic argument completions — the dropdown suggestions that appear when typing arguments for built-in commands like /add-dir (directory completion) or /resume (session title completion).

Currently, argument completions are hardcoded per-command in useTypeahead.tsx:

  • /add-dirgetDirectoryCompletions(args) (line 675)
  • /resumesearchSessionsByCustomTitle(args) (line 693)

Plugin commands like /cc would benefit from showing a dropdown of active session names when the user starts typing the argument, but there's no API to register custom completion providers.

Proposed solution

Add an optional completions field to command frontmatter:

---
description: See active Claude Code sessions
argument-hint: [session-name] [message]
completions:
  type: command
  command: "python3 ${CLAUDE_PLUGIN_ROOT}/scripts/completions.py"
---

The completions command receives the current argument text on stdin and returns JSON suggestions:

[
  {"text": "FRONTEND", "type": "session", "description": "vector-seo · busy"},
  {"text": "DMS", "type": "session", "description": "Content · idle"},
  {"text": "CC", "type": "session", "description": "cc · busy"}
]

The type field maps to the existing SuggestionType enum for consistent styling. The command runs on every keystroke (debounced, like file suggestions) and must respond within a timeout (e.g., 200ms).

Implementation sketch

In useTypeahead.tsx, after the existing /add-dir and /resume blocks:

// Plugin command completions
const command = commands.find(c => getCommandName(c) === parsedCommand.commandName);
if (command?.completions) {
  const suggestions = await executeCompletionCommand(command.completions, parsedCommand.args);
  if (suggestions.length > 0) {
    setSuggestionsState(prev => ({
      suggestions,
      selectedSuggestion: getPreservedSelection(prev.suggestions, prev.selectedSuggestion, suggestions),
      commandArgumentHint: undefined
    }));
    setSuggestionType(suggestions[0].type || 'command');
    return;
  }
}

Use cases

  • cc plugin: Complete session names for cross-session messaging (/cc FRONTEND check tests)
  • Git plugins: Complete branch names for checkout commands
  • Project plugins: Complete task IDs or issue numbers
  • Any plugin with structured argument values

Alternatives considered

  • Static completions in frontmatter: Doesn't work for dynamic data (session names change)
  • MCP tool-based: MCP tools can't inject into the typeahead UI
  • Prompt-based completions: Too slow for keystroke-level responsiveness

This would make plugin commands feel as native as built-in commands.

View original on GitHub ↗

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