Skip to content
$ shellfirm

Qwen Code

A PreToolUse hook that checks Qwen Code shell commands, writes, edits and reads; risky ones ask, dangerous ones are denied.

Connect

shellfirm connect qwen
Output
shellfirm — connecting Qwen Code integration

  /home/dev/.qwen/settings.json:
    - add hooks.PreToolUse entry (matcher "run_shell_command|write_file|edit|read_file|read_many_files") running `shellfirm check --hook qwen --config-dir /home/dev/.config/shellfirm`
    ✓ written

Qwen Code shell commands, file writes and reads are now checked by shellfirm (PreToolUse hook: risky -> ask, dangerous -> deny; headless runs deny what would be asked). Restart running Qwen Code sessions.

What it installs

~/.qwen/settings.json
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "run_shell_command|write_file|edit|read_file|read_many_files",
        "hooks": [
          {
            "type": "command",
            "command": "shellfirm check --hook qwen --config-dir /home/dev/.config/shellfirm",
            "timeout": 30
          }
        ]
      }
    ]
  }
}

The matcher is a list of exact tool names. run_shell_command is checked as a shell command (with its directory), write_file and edit as edits, read_file like cat <path>, and read_many_files (a tool only in Qwen Code versions that still expose it) like a read of every path in paths; a directory is read as everything in it (~/.ssh like ~/.ssh/*), and a directory or glob that reaches a key or credential file (~/.kube, ~/.ss?, **/* from the home directory) like a read of that file. Your other settings and hooks are kept. hooksConfig.disabled is a Gemini CLI setting: Qwen Code does not read it, so connect leaves it alone.

What Qwen Code sees

The answer has Claude Code's shape: hookSpecificOutput.permissionDecision with permissionDecisionReason.

CommandAnswerEffect
No check matches (ls)nothingQwen Code's own approvals apply
Risky, below the auto-deny threshold (cat ~/.ssh/id_rsa, Medium)askYou confirm in Qwen Code's prompt
At or above the threshold, or deny-listed (git push -f origin main, High)denyBlocked, with the reason and a safer alternative

Real ask answer:

{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"ask","permissionDecisionReason":"shellfirm flagged this command as risky; confirm before running.\n[exfil:read_secret_file] [MEDIUM] This reads a private key or a credentials file. ...\nReason: Matched risky pattern(s) (severity MEDIUM, below the auto-deny threshold HIGH); confirm before running\nSafe alternative: read only what you need, not the secret itself (...)"}}

Headless and IDE sessions

Headless runs and IDE (ACP) sessions of Qwen Code turn an ask into a deny: nobody is there to confirm, so risky commands are blocked there. If shellfirm cannot run, Qwen Code runs the tool call.

Options

OptionEffect
--scope user (default)~/.qwen/settings.json
--scope project./.qwen/settings.json; Qwen Code asks you to approve project hooks
--dry-runShow what would change, write nothing
--uninstallRemove shellfirm's entries only

qwen --safe-mode, qwen -y / --approval-mode yolo and a fresh QWEN_HOME started by an agent ask first, like the other hook bypasses (see self-protection).

Check the integration

Output
  Agent integrations:
    qwen (user): hook yes, file tools yes, fail-closed no, MCP n/a