Back to library
AI
tutorial

Use Autonomous /goal Commands for Multi-File Refactoring

Automate complex coding tasks with autonomous execution and goal detection.

Use the /goal command in Qwen Code to let the agent autonomously handle multi-file coding tasks from start to finish.

Qwen

The Scenario

You need to refactor a legacy project or add unit tests across multiple files but don't want to manually open and edit every single one.

Before & after

The old way

Developers manually read through large codebases and write scripts to modify multiple files. This process typically takes 30–60 minutes depending on project complexity.

With AI

By running 'qwen' in your project folder, the agent autonomously navigates files and executes code. This reduces the time to roughly 1–2 minutes of supervision.

The Prompt

qwen /goal [DESCRIBE_YOUR_CODING_OBJECTIVE_HERE_EG_GENERATE_UNIT_TESTS_FOR_ALL_UTILS]

Qwen Code includes an autonomous agent that follows specific goals to completion. It features impossible-goal detection and independent judging to ensure the code changes are accurate and safe.

Source

Qwen Code Blog: AI Coding Updates and Guides | Qwen Code Docs
"Both Claude Code and Codex shipped /goal. Qwen Code v0.16.0 follows suit—plus an independent judge model and impossible-goal detection."