|
| 1 | +# Setup QWEN Coder CLI in VS Code |
| 2 | + |
| 3 | +**QWEN Coder CLI is completely FREE to use!** 🎉 This powerful AI coding assistant can help you write, debug, and understand code directly from your terminal. Follow this step-by-step guide to get it set up in VS Code. |
| 4 | + |
| 5 | +## What is QWEN Coder CLI? |
| 6 | + |
| 7 | +QWEN Coder CLI is an AI-powered coding agent that lives in your terminal. It can: |
| 8 | +- 🔍 **Analyze codebases** and explain architecture |
| 9 | +- 💻 **Generate code** for any programming language |
| 10 | +- 🐛 **Debug issues** and suggest fixes |
| 11 | +- 📚 **Understand new codebases** quickly |
| 12 | +- 🔄 **Refactor code** and improve performance |
| 13 | +- 📝 **Generate documentation** and tests |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +Before we start, make sure you have: |
| 18 | +- **VS Code** installed (download from [code.visualstudio.com](https://code.visualstudio.com)) |
| 19 | +- **Node.js** (version 18 or higher) - [Download here](https://nodejs.org) |
| 20 | +- **Git** installed - [Download here](https://git-scm.com) |
| 21 | + |
| 22 | +## Step 1: Download and Install VS Code |
| 23 | + |
| 24 | +1. **Download VS Code** |
| 25 | + - Go to [code.visualstudio.com](https://code.visualstudio.com) |
| 26 | + - Click "Download for Windows" (or your operating system) |
| 27 | + - Run the installer and follow the setup wizard |
| 28 | + |
| 29 | +2. **Open VS Code** |
| 30 | + - Launch VS Code from your desktop or start menu |
| 31 | + - You'll see the welcome screen |
| 32 | + |
| 33 | +## Step 2: Open Terminal in VS Code |
| 34 | + |
| 35 | +1. **Open the Terminal** |
| 36 | + - Press `Ctrl + `` (backtick) or go to `View > Terminal` |
| 37 | + - The terminal will appear at the bottom of VS Code |
| 38 | + - Make sure you're in your project directory |
| 39 | + |
| 40 | +2. **Verify Node.js Installation** |
| 41 | + ```bash |
| 42 | + node --version |
| 43 | + npm --version |
| 44 | + ``` |
| 45 | + You should see version numbers (Node.js 18+ and npm 8+) |
| 46 | + |
| 47 | +## Step 3: Install QWEN Coder CLI |
| 48 | + |
| 49 | +1. **Install QWEN Coder CLI globally** |
| 50 | + ```bash |
| 51 | + npm install -g @qwen-code/qwen-code@latest |
| 52 | + ``` |
| 53 | + |
| 54 | +2. **Verify Installation** |
| 55 | + ```bash |
| 56 | + qwen --version |
| 57 | + ``` |
| 58 | + You should see the version number (e.g., v0.0.15) |
| 59 | + |
| 60 | +## Step 4: Authentication Setup |
| 61 | + |
| 62 | +QWEN Coder CLI offers **FREE authentication** with generous quotas! Choose your preferred method: |
| 63 | + |
| 64 | +### Option 1: QWEN OAuth (🚀 Recommended - Completely FREE!) |
| 65 | + |
| 66 | +This is the easiest way to get started: |
| 67 | + |
| 68 | +1. **Run the authentication command** |
| 69 | + ```bash |
| 70 | + qwen |
| 71 | + ``` |
| 72 | + |
| 73 | +2. **Follow the browser authentication** |
| 74 | + - CLI will automatically open your browser |
| 75 | + - Sign in with your qwen.ai account (create one if needed) |
| 76 | + - Grant permissions when prompted |
| 77 | + - You'll be redirected back to the terminal |
| 78 | + |
| 79 | +**Free Tier Benefits:** |
| 80 | +- ✅ **2,000 requests/day** (no token counting needed) |
| 81 | +- ✅ **60 requests/minute** rate limit |
| 82 | +- ✅ **Automatic credential refresh** |
| 83 | +- ✅ **Zero cost** for individual users |
| 84 | + |
| 85 | +### Option 2: API Key Authentication (Alternative) |
| 86 | + |
| 87 | +If you prefer using API keys: |
| 88 | + |
| 89 | +1. **Set up environment variables** |
| 90 | + ```bash |
| 91 | + # Create a .env file in your project |
| 92 | + echo "OPENAI_API_KEY=your_api_key_here" > .env |
| 93 | + echo "OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1" >> .env |
| 94 | + echo "OPENAI_MODEL=qwen3-coder-plus" >> .env |
| 95 | + ``` |
| 96 | + |
| 97 | +2. **Or set system environment variables** |
| 98 | + - Windows: Set in System Properties > Environment Variables |
| 99 | + - Mac/Linux: Add to your `~/.bashrc` or `~/.zshrc` |
| 100 | + |
| 101 | +## Step 5: Test Your Setup |
| 102 | + |
| 103 | +1. **Start QWEN Coder CLI** |
| 104 | + ```bash |
| 105 | + qwen |
| 106 | + ``` |
| 107 | + |
| 108 | +2. **Try a simple command** |
| 109 | + ``` |
| 110 | + > Hello! Can you help me understand this codebase? |
| 111 | + ``` |
| 112 | + |
| 113 | +3. **Test code analysis** |
| 114 | + ``` |
| 115 | + > What are the main components of this project? |
| 116 | + ``` |
| 117 | + |
| 118 | +## Step 6: VS Code Integration Tips |
| 119 | + |
| 120 | +### Terminal Configuration |
| 121 | + |
| 122 | +1. **Set up your preferred terminal** |
| 123 | + - Go to `File > Preferences > Settings` |
| 124 | + - Search for "terminal.integrated.defaultProfile.windows" |
| 125 | + - Choose your preferred shell (PowerShell, Command Prompt, or Git Bash) |
| 126 | + |
| 127 | +2. **Enable terminal shortcuts** |
| 128 | + - `Ctrl + `` - Toggle terminal |
| 129 | + - `Ctrl + Shift + `` - New terminal |
| 130 | + - `Ctrl + C` - Cancel current operation |
| 131 | + |
| 132 | +### Useful VS Code Extensions |
| 133 | + |
| 134 | +Install these extensions for better integration: |
| 135 | + |
| 136 | +1. **Terminal Extensions** |
| 137 | + - **Terminal** - Built-in terminal support |
| 138 | + - **PowerShell** - Enhanced PowerShell support |
| 139 | + |
| 140 | +2. **Code Quality Extensions** |
| 141 | + - **ESLint** - JavaScript/TypeScript linting |
| 142 | + - **Prettier** - Code formatting |
| 143 | + - **GitLens** - Enhanced Git capabilities |
| 144 | + |
| 145 | +## Step 7: Basic Usage Examples |
| 146 | + |
| 147 | +### 🔍 Explore Your Codebase |
| 148 | + |
| 149 | +```bash |
| 150 | +# Navigate to your project |
| 151 | +cd your-project-directory |
| 152 | + |
| 153 | +# Start QWEN Coder CLI |
| 154 | +qwen |
| 155 | + |
| 156 | +# Ask questions about your code |
| 157 | +> Describe the main architecture of this project |
| 158 | +> What are the key dependencies? |
| 159 | +> Find all API endpoints and their authentication methods |
| 160 | +``` |
| 161 | + |
| 162 | +### 💻 Code Development |
| 163 | + |
| 164 | +```bash |
| 165 | +# Code generation |
| 166 | +> Create a REST API endpoint for user management |
| 167 | +> Generate unit tests for the authentication module |
| 168 | +> Add error handling to all database operations |
| 169 | + |
| 170 | +# Code refactoring |
| 171 | +> Refactor this function to improve readability |
| 172 | +> Convert this class to use dependency injection |
| 173 | +> Split this large module into smaller components |
| 174 | +``` |
| 175 | + |
| 176 | +### 🐛 Debugging & Analysis |
| 177 | + |
| 178 | +```bash |
| 179 | +# Performance analysis |
| 180 | +> Identify performance bottlenecks in this React component |
| 181 | +> Find all N+1 query problems in the codebase |
| 182 | + |
| 183 | +# Security audit |
| 184 | +> Check for potential SQL injection vulnerabilities |
| 185 | +> Find all hardcoded credentials or API keys |
| 186 | +``` |
| 187 | + |
| 188 | +## Step 8: Advanced Configuration |
| 189 | + |
| 190 | +### Custom Settings |
| 191 | + |
| 192 | +Create a `.qwen/settings.json` file in your home directory: |
| 193 | + |
| 194 | +```json |
| 195 | +{ |
| 196 | + "experimental": { |
| 197 | + "vlmSwitchMode": "once", |
| 198 | + "visionModelPreview": true |
| 199 | + } |
| 200 | +} |
| 201 | +``` |
| 202 | + |
| 203 | +### Session Commands |
| 204 | + |
| 205 | +While using QWEN Coder CLI, you can use these commands: |
| 206 | + |
| 207 | +- `/help` - Display available commands |
| 208 | +- `/clear` - Clear conversation history |
| 209 | +- `/compress` - Compress history to save tokens |
| 210 | +- `/stats` - Show current session information |
| 211 | +- `/exit` or `/quit` - Exit QWEN Coder CLI |
| 212 | + |
| 213 | +## Troubleshooting |
| 214 | + |
| 215 | +### Common Issues |
| 216 | + |
| 217 | +1. **"qwen: command not found"** |
| 218 | + ```bash |
| 219 | + # Reinstall globally |
| 220 | + npm uninstall -g @qwenlm/qwen-code |
| 221 | + npm install -g @qwenlm/qwen-code |
| 222 | + ``` |
| 223 | + |
| 224 | +2. **Authentication errors** |
| 225 | + ```bash |
| 226 | + # Clear cached credentials |
| 227 | + qwen --logout |
| 228 | + qwen # Re-authenticate |
| 229 | + ``` |
| 230 | + |
| 231 | +3. **Permission errors on Windows** |
| 232 | + ```bash |
| 233 | + # Run VS Code as Administrator |
| 234 | + # Or use PowerShell as Administrator |
| 235 | + ``` |
| 236 | + |
| 237 | +4. **Node.js version issues** |
| 238 | + ```bash |
| 239 | + # Update Node.js to version 18+ |
| 240 | + # Or use nvm to manage versions |
| 241 | + nvm install 18 |
| 242 | + nvm use 18 |
| 243 | + ``` |
| 244 | + |
| 245 | +### Getting Help |
| 246 | + |
| 247 | +- **Documentation**: [qwenlm.github.io/qwen-code-docs](https://qwenlm.github.io/qwen-code-docs) |
| 248 | +- **GitHub Repository**: [github.com/QwenLM/qwen-code](https://github.com/QwenLM/qwen-code) |
| 249 | +- **Issues**: Report bugs on GitHub Issues |
| 250 | + |
| 251 | +## Best Practices |
| 252 | + |
| 253 | +### 1. Project Organization |
| 254 | +- Always run `qwen` from your project root directory |
| 255 | +- Keep your codebase organized with clear folder structure |
| 256 | +- Use meaningful commit messages for better analysis |
| 257 | + |
| 258 | +### 2. Effective Prompts |
| 259 | +- Be specific about what you want to achieve |
| 260 | +- Provide context about your project |
| 261 | +- Ask follow-up questions for clarification |
| 262 | + |
| 263 | +### 3. Security |
| 264 | +- Never share your API keys |
| 265 | +- Use environment variables for sensitive data |
| 266 | +- Review generated code before using in production |
| 267 | + |
| 268 | +### 4. Performance |
| 269 | +- Use `/compress` to save tokens in long sessions |
| 270 | +- Break down complex tasks into smaller steps |
| 271 | +- Use `/clear` to start fresh when needed |
| 272 | + |
| 273 | +## Next Steps |
| 274 | + |
| 275 | +Now that you have QWEN Coder CLI set up, try these activities: |
| 276 | + |
| 277 | +1. **Explore a new codebase** |
| 278 | + ```bash |
| 279 | + > What are the core business logic components? |
| 280 | + > How does the data flow through the system? |
| 281 | + > What security mechanisms are in place? |
| 282 | + ``` |
| 283 | + |
| 284 | +2. **Refactor existing code** |
| 285 | + ```bash |
| 286 | + > Help me refactor this class to follow SOLID principles |
| 287 | + > Add proper error handling and logging |
| 288 | + > Convert callbacks to async/await pattern |
| 289 | + ``` |
| 290 | + |
| 291 | +3. **Generate documentation** |
| 292 | + ```bash |
| 293 | + > Generate comprehensive JSDoc comments for all public APIs |
| 294 | + > Create API documentation in OpenAPI format |
| 295 | + > Generate a README for this module |
| 296 | + ``` |
| 297 | + |
| 298 | +4. **Set up new projects** |
| 299 | + ```bash |
| 300 | + > Set up a new Express server with authentication |
| 301 | + > Create a React component with TypeScript and tests |
| 302 | + > Implement a rate limiter middleware |
| 303 | + ``` |
| 304 | + |
| 305 | +## Conclusion |
| 306 | + |
| 307 | +Congratulations! 🎉 You now have QWEN Coder CLI set up and ready to use. This powerful AI coding assistant will help you: |
| 308 | + |
| 309 | +- **Understand codebases** faster |
| 310 | +- **Generate code** more efficiently |
| 311 | +- **Debug issues** more effectively |
| 312 | +- **Learn new technologies** through hands-on assistance |
| 313 | + |
| 314 | +Remember: QWEN Coder CLI is completely **FREE** to use with generous quotas, so don't hesitate to experiment and explore its capabilities! |
| 315 | + |
| 316 | +--- |
| 317 | + |
| 318 | +**Happy Coding!** 🚀 |
| 319 | + |
| 320 | +*Need help? Check out the [official documentation](https://qwenlm.github.io/qwen-code-docs) or join the [GitHub discussions](https://github.com/QwenLM/qwen-code/discussions).* |
0 commit comments