Support Qwen Code CLI hooks (same as Gemini CLI integration)
#1222 opened on Apr 11, 2026
Description
Summary
Qwen Code is an LLM-powered coding assistant with a CLI interface and BeforeTool hook system architecturally very similar to Gemini CLI. This feature request is to add first-class RTK support for Qwen Code.
Current Status
RTK currently supports 10+ AI coding tools:
- ✅ Claude Code
- ✅ GitHub Copilot (VS Code + CLI)
- ✅ Cursor
- ✅ Gemini CLI
- ✅ Cline / Roo Code
- ✅ Windsurf
- ✅ Codex
- ✅ OpenCode
- ✅ OpenClaw
- ⏳ Mistral Vibe (planned)
Qwen Code is missing from this list.
Why Qwen Code?
Qwen Code is gaining adoption as a powerful open-source alternative to Claude Code and Copilot. Users would benefit from RTK's 60-90% token savings just like other supported agents.
Technical Feasibility
JSON Format Similarity to Gemini CLI
Qwen Code BeforeTool Input:
{
"tool_name": "run_shell_command",
"tool_input": { "command": "git status" }
}
Expected RTK Output:
{
"decision": "allow",
"hookSpecificOutput": {
"tool_input": { "command": "rtk git status" }
}
}
This is virtually identical to Gemini CLI's hook format (see hooks/README.md#Gemini-CLI).
Implementation Effort
Minimal — RTK already has:
- ✅ Command rewrite logic (
src/discover/registry.rs) — reusable - ✅ Gemini CLI handler (
src/hooks/hook_cmd.rs::run_gemini()) — can be reused or slightly adapted - ✅ Settings.json patching (
src/hooks/init.rs::patch_gemini_settings()) — template exists - ✅ Installation CLI (
rtk init -g --gemini) — pattern established
Proposal: Add rtk init -g --qwen command that:
- Creates
~/.qwen/hooks/rtk-rewrite.sh(or similar) - Patches
~/.qwen/settings.jsonwith BeforeTool hook entry - Installs
QWEN.md(RTK awareness doc)
This is a straightforward extension of the existing Gemini CLI support.
Expected Outcome
After implementation, users can:
# 1. Install RTK for Qwen Code
rtk init -g --qwen
# 2. Restart Qwen Code
# 3. Commands auto-rewrite transparently
git status # → internally: rtk git status
cargo test # → internally: rtk cargo test
npm list # → internally: rtk npm list
# etc. (all 100+ supported commands)
# 4. Check savings
rtk gain
Resources
- RTK README: https://github.com/rtk-ai/rtk#supported-ai-tools
- Gemini CLI Implementation: https://github.com/rtk-ai/rtk/blob/master/src/hooks/hook_cmd.rs#L163-L200
- Hook Registry: https://github.com/rtk-ai/rtk/blob/master/hooks/README.md
- Installation Code: https://github.com/rtk-ai/rtk/blob/master/src/hooks/init.rs#L2132-L2175
Qwen Code Documentation
(If you have Qwen Code's official hook API docs, link them here. E.g., official Qwen Code repository or docs URL.)
I'm happy to:
- ✅ Test early builds on Qwen Code
- ✅ Provide hook API documentation if available
- ✅ Contribute a PR if you want community implementation
Thanks for the amazing RTK project! 🚀