### Qwen Code - Essential Commands Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart Lists essential commands for daily use of Qwen Code, including starting the application, authentication, help, and exiting. ```bash qwen /auth /help or /? /compress /clear (shortcut: Ctrl+L) /theme /language ui [language] /language output [language] /quit or /exit ``` -------------------------------- ### Example Qwen Code Command: Project Description Source: https://qwenlm.github.io/qwen-code-docs/en/users/overview An example of how to ask Qwen Code about the functionality of your current project. This command is run after starting Qwen Code in your project directory. ```bash what does this project do? ``` -------------------------------- ### Build and Start Qwen Code Project Source: https://qwenlm.github.io/qwen-code-docs/en/users/support/troubleshooting Installs project dependencies, compiles the project, and then starts the application. This is a common troubleshooting step for 'MODULE_NOT_FOUND' or import errors. ```bash npm install npm run build npm run start ``` -------------------------------- ### Qwen Code - Update Documentation Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to update documentation files, such as the README, with new information like installation instructions. Qwen Code can modify documentation content. ```text update the README with installation instructions ``` -------------------------------- ### Set Up Qwen Code Documentation Site Locally Source: https://qwenlm.github.io/qwen-code-docs/en/developers/contributing Steps to set up and run the Qwen Code documentation site locally. This involves navigating to the docs-site directory, installing dependencies, linking documentation content, and starting the development server. ```bash cd docs-site npm install npm run link npm run dev ``` -------------------------------- ### Install Dependencies for Qwen Extension Source: https://qwenlm.github.io/qwen-code-docs/en/developers/extensions/getting-started-extensions This command installs the necessary Node.js dependencies for the Qwen Code extension project. It should be run within the extension's root directory after creation. ```bash cd my-first-extension npm install ``` -------------------------------- ### Example Subagent Configuration (Project Documenter) Source: https://qwenlm.github.io/qwen-code-docs/en/users/features/sub-agents An example demonstrating a Subagent configuration for a project documenter. It includes a name, description, and a system prompt with templated variables for dynamic content like project name and task description. ```yaml --- name: project-documenter description: Creates project documentation and README files --- You are a documentation specialist for the ${project_name} project. Your task: ${task_description} Working directory: ${current_directory} Generated on: ${timestamp} Focus on creating clear, comprehensive documentation that helps both new contributors and end users understand the project. ``` -------------------------------- ### Qwen Code - Inquire About Capabilities Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to ask Qwen Code about its own features and capabilities. The AI can access its documentation to answer questions. ```text what can Qwen Code do? ``` -------------------------------- ### Qwen Code - Add Hello World Function Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to instruct Qwen Code to add a 'hello world' function to the main file. Qwen Code will propose, confirm, and apply the changes. ```text add a hello world function to the main file ``` -------------------------------- ### Install Qwen Code Extension from GitHub Source: https://qwenlm.github.io/qwen-code-docs/en/developers/extensions/extension Installs a Qwen Code extension from a specified GitHub URL. This command copies the extension to the local Qwen Code extensions directory. To get the latest changes, you'll need to run `qwen extensions update`. ```bash qwen extensions install https://github.com/qwen-cli-extensions/security ``` -------------------------------- ### Authenticate Qwen Code Account Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart Command to initiate the authentication process for Qwen Code. Users will be prompted to log in via Qwen OAuth, and credentials will be stored for future use. ```bash /auth ``` -------------------------------- ### Basic exit_plan_mode Usage Example Source: https://qwenlm.github.io/qwen-code-docs/en/developers/tools/exit-plan-mode A simple example demonstrating the basic syntax for calling the `exit_plan_mode` tool with a placeholder for the implementation plan. This serves as a starting point for integrating the tool into Qwen Code workflows. ```python exit_plan_mode(plan="Your detailed implementation plan here...") ``` -------------------------------- ### Qwen Code - Explain Folder Structure Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to ask Qwen Code to explain the current project's folder structure. Qwen Code analyzes the files to provide a summary. ```text explain the folder structure ``` -------------------------------- ### Ask Qwen Code About Its Capabilities Source: https://qwenlm.github.io/qwen-code-docs/en/users/common-workflow Provides examples of questions that can be asked to Qwen Code to inquire about its features, limitations, and integration capabilities. Qwen Code can access its own documentation to provide answers. ```shell can Qwen Code create pull requests? how does Qwen Code handle permissions? what slash commands are available? how do I use MCP with Qwen Code? how do I configure Qwen Code for Amazon Bedrock? what are the limitations of Qwen Code? ``` -------------------------------- ### Navigate Project Directory Source: https://qwenlm.github.io/qwen-code-docs/en/users/common-workflow This command navigates the user to the root directory of a project. It is a prerequisite for starting Qwen Code within a project context. ```bash cd /path/to/project ``` -------------------------------- ### Create New Qwen Extension using Template Source: https://qwenlm.github.io/qwen-code-docs/en/developers/extensions/getting-started-extensions This command initializes a new Qwen Code extension project using a specified template. It requires the extension name and the template name as arguments. The output is a new directory containing the template files. ```bash qwen extensions new my-first-extension mcp-server ``` -------------------------------- ### Get Codebase Overview with Qwen Code Source: https://qwenlm.github.io/qwen-code-docs/en/users/common-workflow These prompts are used to ask Qwen Code for a high-level understanding of a codebase. They help users quickly grasp the project's structure, architecture, data models, and authentication mechanisms. ```bash give me an overview of this codebase ``` ```bash explain the main architecture patterns used here ``` ```bash what are the key data models? ``` ```bash how is authentication handled? ``` -------------------------------- ### Generate Release Notes with Qwen CLI Source: https://qwenlm.github.io/qwen-code-docs/en/users/features/headless This example generates release notes from Git commit history between two tags. It uses `git log` to get the commits, Qwen to generate the notes in JSON format, and then echoes and appends the response to `CHANGELOG.md`. ```bash result=$(git log --oneline v1.0.0..HEAD | qwen -p "Generate release notes from these commits" --output-format json) response=$(echo "$result" | jq -r '.response') echo "$response" echo "$response" >> CHANGELOG.md ``` -------------------------------- ### Add SSE MCP Server using CLI Source: https://qwenlm.github.io/qwen-code-docs/en/developers/tools/mcp-server These bash commands illustrate adding an MCP server configured for Server-Sent Events (SSE) transport. Examples cover the basic syntax and how to add an SSE server with authentication headers. ```bash # Basic syntax qwen mcp add --transport sse # Example: Adding an SSE server qwen mcp add --transport sse sse-server https://api.example.com/sse/ # Example: Adding an SSE server with an authentication header qwen mcp add --transport sse secure-sse https://api.example.com/sse/ --header "Authorization: Bearer abc123" ``` -------------------------------- ### Setup Qwen Code CLI using setup command Source: https://qwenlm.github.io/qwen-code-docs/en/users/integration-github-action This demonstrates the recommended method for setting up the Qwen Code CLI in your repository. It involves running the 'qwen' command in your terminal and then using the '/setup-github' command within the CLI to automate the configuration. ```bash qwen /setup-github ``` -------------------------------- ### Install and Launch Qwen Cowork Project Source: https://qwenlm.github.io/qwen-code-docs/en/blog/how-to-use-qwencode-cowork This snippet demonstrates how to install and launch the Qwen Cowork project using direct installation via Qwen Code. It assumes the user has Qwen Code set up and can interact with it through natural language commands. ```natural language Help me install the cowork project and launch it, the repository address is: https://github.com/QwenLM/qwen-code-examples ``` -------------------------------- ### Create QWEN.md for Persistent Context Source: https://qwenlm.github.io/qwen-code-docs/en/developers/extensions/getting-started-extensions This Markdown file serves as a persistent context for the Qwen Code model. It can contain instructions on how the model should behave or information about the extension's tools. This example sets the model to act as an expert developer assistant and use a specific tool when asked to fetch posts. ```markdown # My First Extension Instructions You are an expert developer assistant. When the user asks you to fetch posts, use the `fetch_posts` tool. Be concise in your responses. ``` -------------------------------- ### Example Qwen Code `settings.json` Configuration Source: https://qwenlm.github.io/qwen-code-docs/en/users/configuration/settings Provides a comprehensive example of the `settings.json` file, demonstrating various configuration options available in Qwen Code v0.3.0 and later. This includes settings for general preferences, UI customization, tool usage, server configurations, telemetry, privacy, model parameters, context management, and advanced environment variable exclusion. ```json { "general": { "vimMode": true, "preferredEditor": "code" }, "ui": { "theme": "GitHub", "hideTips": false, "customWittyPhrases": [ "You forget a thousand things every day. Make sure this is one of 'em", "Connecting to AGI" ] }, "tools": { "approvalMode": "yolo", "sandbox": "docker", "discoveryCommand": "bin/get_tools", "callCommand": "bin/call_tool", "exclude": ["write_file"] }, "mcpServers": { "mainServer": { "command": "bin/mcp_server.py" }, "anotherServer": { "command": "node", "args": ["mcp_server.js", "--verbose"] } }, "telemetry": { "enabled": true, "target": "local", "otlpEndpoint": "http://localhost:4317", "logPrompts": true }, "privacy": { "usageStatisticsEnabled": true }, "model": { "name": "qwen3-coder-plus", "maxSessionTurns": 10, "enableOpenAILogging": false, "openAILoggingDir": "~/qwen-logs", "summarizeToolOutput": { "run_shell_command": { "tokenBudget": 100 } } }, "context": { "fileName": ["CONTEXT.md", "QWEN.md"], "includeDirectories": ["path/to/dir1", "~/path/to/dir2", "../path/to/dir3"], "loadFromIncludeDirectories": true, "fileFiltering": { "respectGitIgnore": false } }, "advanced": { "excludedEnvVars": ["DEBUG", "DEBUG_MODE", "NODE_ENV"] } } ``` -------------------------------- ### Source Code Installation for Qwen Cowork Source: https://qwenlm.github.io/qwen-code-docs/en/blog/how-to-use-qwencode-cowork This snippet details the advanced method of installing the Qwen Cowork project from source. It requires installing Bun, cloning the repository, navigating to the project directory, installing dependencies, and then launching the application. ```bash # Install Bun curl -fsSL https://bun.sh/install | bash exec /bin/zsh # Clone repository git clone https://github.com/QwenLM/qwen-code-examples # Enter directory and install cd qwen-code-examples/apps/qwen-cowork bun install # Launch bun run dev ``` -------------------------------- ### Explicit Subagent Invocation Examples Source: https://qwenlm.github.io/qwen-code-docs/en/users/features/sub-agents Examples demonstrating how to explicitly request specific Subagents to perform tasks, such as creating unit tests or updating documentation. ```text Let the testing-expert Subagents create unit tests for the payment module Have the documentation-writer Subagents update the API reference Get the react-specialist Subagents to optimize this component's performance ``` -------------------------------- ### Start Qwen Code Application from Source Source: https://qwenlm.github.io/qwen-code-docs/en/developers/contributing After building the project from source, this command starts the Qwen Code application. It should be run from the root directory of the project. ```bash npm start ``` -------------------------------- ### Start Background Server with Explicit & using run_shell_command Source: https://qwenlm.github.io/qwen-code-docs/en/developers/tools/shell Starts a development server using `npm run dev &` in the background. While `&` is used, `is_background` is set to false, indicating manual background execution setup. ```python run_shell_command(command="npm run dev &", description="Start development server in background", is_background=false) ``` -------------------------------- ### Install Project Dependencies Source: https://qwenlm.github.io/qwen-code-docs/en/developers/contributing This command installs all project dependencies, including those defined in the `package.json` file and root dependencies. It's a crucial step after cloning the repository. ```bash npm install ``` -------------------------------- ### Example Custom Theme JSON File Source: https://qwenlm.github.io/qwen-code-docs/en/users/configuration/themes An example of a complete custom theme defined in a JSON file. This structure includes all required color properties and optional ones like 'DiffAdded', 'DiffRemoved', 'DiffModified', and 'GradientColors'. This file can be referenced in `settings.json`. ```json { "name": "My File Theme", "type": "custom", "Background": "#282A36", "Foreground": "#F8F8F2", "LightBlue": "#82AAFF", "AccentBlue": "#61AFEF", "AccentPurple": "#BD93F9", "AccentCyan": "#8BE9FD", "AccentGreen": "#50FA7B", "AccentYellow": "#F1FA8C", "AccentRed": "#FF5555", "Comment": "#6272A4", "Gray": "#ABB2BF", "DiffAdded": "#A6E3A1", "DiffRemoved": "#F38BA8", "DiffModified": "#89B4FA", "GradientColors": ["#4796E4", "#847ACE", "#C3677F"] } ``` -------------------------------- ### Example Context File Content for Qwen CLI Source: https://qwenlm.github.io/qwen-code-docs/en/users/configuration/settings A conceptual example of a context file (e.g., QWEN.md) at the root of a TypeScript project. It defines general instructions, coding style guidelines, and specific component details for the AI model. ```markdown # Project: My Awesome TypeScript Library ## General Instructions: - When generating new TypeScript code, please follow the existing coding style. - Ensure all new functions and classes have JSDoc comments. - Prefer functional programming paradigms where appropriate. - All code should be compatible with TypeScript 5.0 and Node.js 20+. ## Coding Style: - Use 2 spaces for indentation. - Interface names should be prefixed with `I` (e.g., `IUserService`). - Private class members should be prefixed with an underscore (`_`). - Always use strict equality (`===` and `!==`). ## Specific Component: `src/api/client.ts` - This file handles all outbound API requests. - When adding new API call functions, ensure they include robust error handling and logging. - Use the existing `fetchWithRetry` utility for all GET requests. ``` -------------------------------- ### Start Qwen Code in a Project Source: https://qwenlm.github.io/qwen-code-docs/en/users/overview Navigates to your project directory and starts the Qwen Code interactive terminal session. You will be prompted to authenticate. ```bash cd your-project qwen ``` -------------------------------- ### Quick Start: Single-turn Query with @qwen-code/sdk Source: https://qwenlm.github.io/qwen-code-docs/en/developers/sdk-typescript Demonstrates how to perform a single-turn query using the query function from the @qwen-code/sdk. It shows how to configure the query with a prompt and options, and how to iterate over the results. ```typescript import { query } from '@qwen-code/sdk'; // Single-turn query const result = query({ prompt: 'What files are in the current directory?', options: { cwd: '/path/to/project', }, }); // Iterate over messages for await (const message of result) { if (message.type === 'assistant') { console.log('Assistant:', message.message.content); } else if (message.type === 'result') { console.log('Result:', message.result); } } ``` -------------------------------- ### Qwen Code - Code Review Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to request a code review of recent changes. Qwen Code analyzes the code and suggests improvements. ```text review my changes and suggest improvements ``` -------------------------------- ### Qwen Extension Manifest Configuration (qwen-extension.json) Source: https://qwenlm.github.io/qwen-code-docs/en/developers/extensions/getting-started-extensions The `qwen-extension.json` file serves as the manifest for a Qwen Code extension. It defines the extension's name, version, and configuration for MCP servers, including the command, arguments, and working directory to start the server. The `${extensionPath}` variable is dynamically replaced by Qwen Code. ```json { "name": "my-first-extension", "version": "1.0.0", "mcpServers": { "nodeServer": { "command": "node", "args": ["${extensionPath}${/}dist${/}example.js"], "cwd": "${extensionPath}" } } } ``` -------------------------------- ### Install Qwen Code IDE Companion Source: https://qwenlm.github.io/qwen-code-docs/en/users/support/troubleshooting Installs the Qwen Code IDE companion extension. This command should be run within the IDE's integrated terminal. ```bash /ide install ``` -------------------------------- ### Automated Refactoring Workflow Example with Qwen Code Source: https://qwenlm.github.io/qwen-code-docs/en/users/features/approval-mode This example demonstrates a fully automated refactoring task using Qwen Code in YOLO Mode. The command instructs the AI to run tests, fix failures, and commit changes without human intervention, showcasing the power of full automation. ```bash # Fully automated refactoring task qwen --prompt "Run the test suite, fix all failing tests, then commit changes" # Without human intervention, AI will: # 1. Run test commands (auto-approved) # 2. Fix failed test cases (auto-edit files) # 3. Execute git commit (auto-approved) ``` -------------------------------- ### Qwen Code - Git: Commit Changes Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to commit current changes with a descriptive message. Qwen Code will handle the Git commit operation. ```text commit my changes with a descriptive message ``` -------------------------------- ### Simple Query Example using Qwen Code Java SDK Source: https://qwenlm.github.io/qwen-code-docs/en/developers/sdk-java This Java code demonstrates the simplest way to use the Qwen Code Java SDK by performing a basic query. It utilizes the `QwenCodeCli.simpleQuery()` method with a string input and logs the results. ```java public static void runSimpleExample() { List result = QwenCodeCli.simpleQuery("hello world"); result.forEach(logger::info); } ``` -------------------------------- ### Real-world Web Search Examples Source: https://qwenlm.github.io/qwen-code-docs/en/developers/tools/web-search Demonstrates practical use cases for the web_search tool, including searching for current weather, specific software versions, and best practices. ```python web_search(query="weather in San Francisco today") web_search(query="latest Node.js LTS version", provider="google") web_search(query="best practices for React 19", provider="dashscope") ``` -------------------------------- ### Qwen Code - Refactor Code: Async/Await Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to refactor code, specifically converting callbacks to async/await in the authentication module. Qwen Code analyzes and restructures the code. ```text refactor the authentication module to use async/await instead of callbacks ``` -------------------------------- ### Create Custom Command File Source: https://qwenlm.github.io/qwen-code-docs/en/users/features/commands Demonstrates the creation of a command file for a custom command, specifically for a 'pure function refactoring' command. ```shell touch ~/.qwen/commands/refactor/pure.md ``` -------------------------------- ### Qwen Code - Git: Show Last Commits Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to display the last N commits in the Git history. Qwen Code can retrieve and present commit information. ```text show me the last 5 commits ``` -------------------------------- ### Configure Custom Sandbox Flags (Podman Example) Source: https://qwenlm.github.io/qwen-code-docs/en/users/features/sandbox Example of how to set custom flags for container-based sandboxing, specifically disabling SELinux labeling for volume mounts when using Podman. This allows for advanced configurations. ```bash export SANDBOX_FLAGS="--security-opt label=disable" ``` ```bash export SANDBOX_FLAGS="--flag1 --flag2=value" ``` -------------------------------- ### Qwen Code - Git: Create New Branch Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to create a new Git branch with a specified name. Qwen Code facilitates conversational Git operations. ```text create a new branch called feature/quickstart ``` -------------------------------- ### Qwen Code - Git: Check Changed Files Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to ask Qwen Code to list all files that have been changed. This leverages Qwen Code's integration with Git. ```text what files have I changed? ``` -------------------------------- ### Qwen Code - Add Feature: Input Validation Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to add input validation to a user registration form. Qwen Code understands the context and implements the requested feature. ```text add input validation to the user registration form ``` -------------------------------- ### Qwen Code - Git: Resolve Merge Conflicts Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to request assistance with resolving Git merge conflicts. Qwen Code can help identify and suggest solutions for conflicts. ```text help me resolve merge conflicts ``` -------------------------------- ### Building Custom Sandbox Image with Environment Variable Source: https://qwenlm.github.io/qwen-code-docs/en/users/configuration/settings Demonstrates how to build a custom sandbox Docker image for Qwen Code using the `BUILD_SANDBOX` environment variable. This command automatically builds the image based on a custom Dockerfile present in the project's root directory. ```bash BUILD_SANDBOX=1 qwen -s ``` -------------------------------- ### Qwen Code - Write Unit Tests Source: https://qwenlm.github.io/qwen-code-docs/en/users/quickstart A natural language prompt to generate unit tests for specific functions, such as calculator functions. Qwen Code can write test cases based on the provided code. ```text write unit tests for the calculator functions ``` -------------------------------- ### Build the Entire Project Source: https://qwenlm.github.io/qwen-code-docs/en/developers/contributing This command builds the entire Qwen Code project, typically involving compiling TypeScript to JavaScript, bundling assets, and preparing packages for execution. Refer to `scripts/build.js` and `package.json` for detailed build steps. ```bash npm run build ```