Skip to content

Feature Request: Support for Custom Commands from ~/.claude/commands/ #302

@Subterrane

Description

@Subterrane

Feature Request: Support for Custom Commands from ~/.claude/commands/

Problem Statement

Currently, GitHub Copilot CLI only loads custom instructions from CLAUDE.md files in the current working directory and its parent directories. This limits the ability to create reusable, context-specific command templates that can be invoked across different projects.

Proposed Solution

Add support for loading custom command files from a standardized location like ~/.claude/commands/ (or ~/.config/copilot-cli/commands/). These command files would act as specialized "expert mode" contexts that can be invoked when needed.

Example Use Case

A user working with multiple microservices in a large codebase could create a command file like ~/.claude/commands/<command>.md that contains:

  • Codebase-specific context and constraints
  • Common investigation workflows
  • Tool authentication references
  • Sub-agent orchestration patterns
  • Known gotchas and patterns

The user could then invoke this with something like /<command> <task> or by having Copilot CLI automatically detect when this context is needed.

Benefits

  1. Reusability: Write once, use across all projects in the same ecosystem
  2. Organization: Keep project-specific CLAUDE.md lean while maintaining rich contextual commands
  3. Shareability: Teams can share standardized command templates
  4. Separation of Concerns:
    • CLAUDE.md = project/directory-specific context
    • ~/.claude/commands/ = reusable expert mode templates

Proposed Implementation

Option 1: Explicit Invocation

User types a command like /<command> investigate memory leak which:

  1. Loads ~/.claude/commands/<command>.md
  2. Appends task arguments ($ARGUMENTS = "investigate memory leak")
  3. Activates that context for the conversation

Option 2: Auto-detection

Copilot CLI scans for .md files in ~/.claude/commands/ at startup and:

  1. Lists available commands in help text
  2. Allows user to reference them explicitly
  3. Potentially suggests relevant commands based on current directory context

Option 3: Configuration File

Add a ~/.config/copilot-cli/config.yml that specifies:

commands:
  path: ~/.claude/commands
  auto_load: false  # or true to load all at startup

Example Command File Structure

# Expert Mode: [Name]

Context and specialized knowledge...

## Sub-Agents
Links to other specialized agents...

## Workflows
Step-by-step investigation patterns...

---

**Task:** $ARGUMENTS

[Instructions to apply the above expertise to complete the task]

Alternative Considerations

  • Security: Ensure command files can't execute arbitrary code, only provide context
  • Naming: Support both /command-name slash syntax and natural language detection
  • Composition: Allow commands to reference or chain other commands
  • Discoverability: copilot --list-commands to show available custom commands

Related Tools

This pattern is inspired by:

  • Cursor AI's agent framework
  • Claude.ai Projects with custom instructions
  • VSCode's task system
  • Shell rc files and profile loading patterns

Would love to hear the team's thoughts on this approach!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions