Skip to content

Add support for github copilot cli #593

Closed

Description

@gkorland

Activity

  1. jeziellopes commented on Mar 15, 2026

    @jeziellopes
    Contributor

    PR #605 implements this: #605

    Two-layer integration:

    1. Custom instructions — .github/copilot-instructions.md is loaded at every session start and instructs Copilot to prefix commands with rtk. Zero setup needed.

    2. preToolUse hook — .github/hooks/rtk-rewrite.json intercepts raw bash tool calls. Since Copilot CLI hooks can only allow/deny (not rewrite like Claude Code), it uses a deny-with-suggestion pattern:

    git status → denied: "Token savings: use `rtk git status` instead"
    cargo test → denied: "Token savings: use `rtk cargo test` instead"
    

    Copilot reads the reason and re-runs with the rtk prefix.

    Measured gains (validated Copilot CLI session)

    Command Savings Tokens saved
    rtk cargo test 99.9% 15.8K
    rtk cargo clippy --all-targets 93.3% 5.9K
    rtk git diff HEAD~1 81.2% 2.6K
    rtk gh pr list 67.0% 0.8K
    Session total (24 commands) 83.5% avg ~23.3K
  2. added
    awaiting-information
    effort-large
    enhancement
    and removed
    enhancement
    awaiting-information
    effort-large
    on Mar 20, 2026
  3. pszymkowiak commented on Mar 20, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    ✨ Category feature
    🟢 Priority low
    🎯 Confidence 82%

    Summary

    Feature request to add support for GitHub Copilot CLI as a wrapped/handled command; minimal detail provided but intent is clear.


    Triaged automatically by wshm · This is an automated analysis, not a human review.

  4. akaihola commented on Apr 8, 2026

    @akaihola

    What about using "bashEnv": true in ~/.copilot/config/json, and pointing $BASH_ENV to a shell init file which generates shell aliases for commands supported by RTK?

    Here's an example of generating a shell init file
    cat > ~/.copilot/shell-init.sh << 'EOF'
    command -v rtk &>/dev/null || return 0
    for cmd in git gh ls tree grep find diff wc cargo go npm npx pnpm pip \
               docker kubectl curl wget vitest pytest tsc lint prettier ruff \
               mypy prisma next aws psql dotnet rubocop rspec rake; do
      alias "$cmd=rtk $cmd"
    done
    EOF

    The challenge would be how to apply $BASH_ENV to only Copilot CLI sessions – e.g. with a wrapper script or a shell alias.

    Here's an example wrapper script
    BASH_ENV=~/.copilot/shell-init.sh copilot "$@"
  5. mvilrokx commented on May 5, 2026

    @mvilrokx

    Love the tool and the deny-with-suggestion approach works well as a fallback.

    Just wanted to share that Copilot CLI's preToolUse hook actually does support transparent command rewrites via modifiedArgs in the output JSON. The official docs confirm this:

    https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-hooks-reference#pretooluse-decision-control

    Field Values Description
    modifiedArgs object Substitute tool arguments to use instead of the originals.

    So instead of returning a deny-with-suggestion, the hook can return:

    {"permissionDecision": "allow", "modifiedArgs": {"command": "rtk git status"}}

    I tested this with a thin wrapper script that extracts the bash command, calls rtk rewrite, and returns the result via modifiedArgs, it works transparently, no retry round-trip needed.

    Happy to share the wrapper script or submit a PR if that would be helpful!

  6. mvilrokx commented on May 5, 2026

    @mvilrokx

    Created a PR for 👆

  7. zul-hypefast commented on May 13, 2026

    @zul-hypefast

    @jeziellopes @pszymkowiak Any plan to integrate this for Copilot CLI using the new method?

  8. KuSh commented on Sep 5, 2026

    @KuSh
    Collaborator

    GitHub Copilot support landed in #605 as the native rtk hook copilot subcommand (VS Code Copilot Chat and Copilot CLI, Windows included), and the transparent rewrite path requested later in this thread is implemented too: the hook now answers with permissionDecision: allow plus modifiedArgs/updatedInput instead of deny-with-suggestion. Please reopen or comment if the hook does not behave that way for you on the latest version.

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:clienhancementhelp wantedpriority:low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions