These are 28 coding prompts worth saving for Qwen3.7-Max, the agent flagship released in May 2026 with a 1M-token context window — big enough to paste an entire repo, a long log, and several files at once. They are grouped by job: debugging, building features, refactor and review, tests and docs, data and query work, and repo-scale changes. Run them free at chat.qwen.ai, in the iOS and Android apps, or against the open-weight Qwen3 models you self-host under Apache 2.0.

Every prompt is written out in full and ready to copy. They follow the Role + Task + Context + Constraints + Output format shape, but the golden rule for coding is simple: paste real code, state your language and versions, give the exact error, and turn on Thinking for the hard ones so you can watch Qwen reason before it commits. For the full set across every job, start with 40 Best Qwen Prompts; the reasoning guide covers when Thinking pays off, and the Qwen prompt cheat sheet is a one-page reference. Swap anything in [BRACKETS] for your own details.

Advertisement

Debugging & fixing

This is where Thinking mode earns its keep. Turn it on, paste the exact error next to the relevant code, and ask Qwen to reason from symptom to root cause and verify the fix before it answers. A visible trace is easy to spot-check when a bug is subtle.

1. Debug with a Thinking-mode root-cause trace

Turn on Thinking. I'm hitting this error in [LANGUAGE / FRAMEWORK version]: [PASTE ERROR]. Here's the relevant code: [PASTE CODE]. Reason step by step from the error to the most likely root cause. If more than one cause is plausible, rank them by likelihood and explain the evidence for each. Give me the corrected code and a two-sentence explanation of what was actually wrong. Before you finish, check the fix against the original error.

Why it works: Thinking mode spends real compute on the trace, which pays off on subtle bugs, and the verify step catches confident-but-wrong fixes.

2. Fix a bug and verify the fix

This code produces the wrong result. Expected: [EXPECTED OUTPUT]. Actual: [ACTUAL OUTPUT]. Input: [SAMPLE INPUT]. Code: [PASTE CODE]. Find the smallest change that fixes it without altering anything else. Return the corrected code, then walk through the sample input line by line to show it now produces the expected output. If the fix has any side effect on other inputs, say so.

Best for: Logic bugs where the code runs fine but returns the wrong answer, and a trace-through proves the fix.

3. Reproduce an intermittent bug

Turn on Thinking. I have a bug that only happens sometimes: [DESCRIBE SYMPTOMS, WHEN IT APPEARS, WHAT YOU'VE RULED OUT]. Relevant code and config: [PASTE]. Reason about what could make this non-deterministic — race conditions, uninitialized state, ordering, caching, time or timezone, or environment differences. Rank the suspects, and for the top one give me a minimal way to reliably reproduce it plus the fix.

Why it works: Naming the classic sources of non-determinism up front steers Qwen toward the causes that flaky bugs actually come from.

4. Read a stack trace and locate the fault

Here's a full stack trace: [PASTE TRACE]. And here's the code at the frames that matter: [PASTE CODE]. Walk the trace from the top, tell me which frame is the real origin of the failure versus where it merely surfaced, and explain what state must have been true to reach it. Then give the fix and one guard that would have failed louder and earlier.

Best for: Long traces where the error is thrown far from where the real mistake was made.

5. Debug across multiple files

Turn on Thinking. A request flows through these files and breaks somewhere: [PASTE FILE 1], [PASTE FILE 2], [PASTE FILE 3]. Symptom: [DESCRIBE]. Trace the data as it moves from entry point to the failure, name the exact file and function where the invariant breaks, and explain how the earlier code let bad state through. Give the fix at the true source, not a patch at the symptom.

Why it works: The 1M-token context holds several files at once, so Qwen can follow the data across module boundaries instead of guessing about code it can't see.

Writing & building features

Give Qwen a real spec — requirements, constraints, and stack — and it writes runnable code. For full sites and apps, use Web Dev, which generates the project from a natural-language prompt and previews it live. Turn on Thinking when the design has real trade-offs to reason through first.

6. Build a feature from a spec

Turn on Thinking. Build [FEATURE] in [LANGUAGE / STACK]. Requirements: [LIST REQUIREMENTS]. Constraints: [PERFORMANCE, DEPENDENCIES, STYLE CONVENTIONS]. First outline your approach and the two or three key decisions with their trade-offs, then write the full runnable code with comments only on the non-obvious parts. List the assumptions you made and how I'd test each requirement. Confirm the code meets every requirement before finishing.

Why it works: Outlining the approach before coding surfaces design mistakes while they're still cheap to change.

7. Generate a full app with Web Dev

Use Web Dev. Build a [TYPE OF APP — e.g. task tracker] as a single-page app. Core screens: [LIST SCREENS]. Features: [LIST FEATURES]. Use [STACK / FRAMEWORK] and store data in [localStorage / the given API]. Make it responsive and clean with [STYLE — e.g. a minimal light theme]. Show me the working preview, then explain the file structure so I know where to extend it.

Best for: Standing up a working front end or prototype you can preview and iterate on without wiring up a project by hand.

8. Design an API endpoint

Design and implement a [METHOD] [ROUTE] endpoint in [FRAMEWORK]. It should [WHAT IT DOES]. Inputs: [PARAMS / BODY]. Define the request and response schemas, validate inputs and return proper status codes and error bodies, handle the obvious failure cases, and keep it idiomatic for [FRAMEWORK]. Return the handler code plus a short list of the edge cases you covered and any you'd want product to decide on.

Why it works: Asking for the edge cases and open decisions separately turns a quick handler into something you can actually ship and hand off.

9. Scaffold a component from a mockup

Build a [FRAMEWORK] component called [NAME] that renders [DESCRIBE THE UI, OR ATTACH A SCREENSHOT]. Props: [LIST PROPS AND TYPES]. Handle these states: loading, empty, error, and populated. Keep styling in [CSS APPROACH], make it accessible (labels, keyboard focus, ARIA where needed), and don't pull in new dependencies. Return the component and a small usage example.

Best for: Turning a design or screenshot into a real, accessible component instead of a happy-path stub.

10. Wire up a third-party integration

Turn on Thinking. I need to integrate [SERVICE / API] into my [STACK] app to [GOAL]. Here are the relevant docs and my current setup: [PASTE]. Write the integration code, handle auth, retries, rate limits, and errors, and keep secrets out of the source. Explain the request flow, call out anything in the docs that's ambiguous or a common gotcha, and tell me exactly what config or keys I need to supply.

Why it works: Pasting the real docs into the context lets Qwen code against the actual API surface rather than a plausible-looking guess.

Refactor & review

Qwen can clean up code, review it for security, and profile it for speed. Be explicit about what must not change, and turn on Thinking for security and performance work where the reasoning matters more than the edit. For the broader collection, see 40 Best Qwen Prompts.

11. Refactor without changing behavior

Refactor this code for readability and maintainability without changing its behavior: [PASTE CODE]. Improve naming, reduce nesting, extract logic where it earns its place, and remove dead code. Keep it idiomatic for [LANGUAGE] and add no new dependencies. Return the refactored version first, then a short bullet list of what you changed and why, and confirm the public interface is unchanged.

Best for: Cleaning up code you have to keep working in, safely enough to merge without a behavior diff.

12. Security review of a code path

Turn on Thinking. Review this code for security issues: [PASTE CODE]. Check for injection (SQL, command, template), missing input validation, auth and access-control gaps, unsafe deserialization, secrets in code, and unsafe handling of user data. For each finding, rate the severity, explain how it could be exploited in one or two sentences, and give the concrete fix. If something looks safe, don't invent a problem.

Why it works: A named checklist plus a severity rating produces a review you can triage, and "don't invent a problem" keeps it honest.

13. Performance profile and optimize

Turn on Thinking. This code is slower than I need: [PASTE CODE]. Context: [DATA SIZE, HOT PATH, WHAT'S ACCEPTABLE]. Identify the real bottlenecks — algorithmic complexity, unnecessary work in loops, N+1 queries, allocations — and rank them by expected impact. Give the optimized version, state the before-and-after complexity, and note any readability or correctness trade-off each change makes. Don't micro-optimize what won't matter.

Best for: Speeding up a hot path without blindly rewriting code that was never the bottleneck.

14. Review a pull request diff

Act as a careful reviewer. Here's a diff: [PASTE DIFF]. Here's the surrounding code for context: [PASTE]. Review it for correctness, edge cases, error handling, naming, and anything that would surprise a future reader. Group comments as blocking, worth-fixing, and nit, quote the exact line for each, and suggest the change. End with a one-line verdict: approve, approve with changes, or request changes.

Why it works: Grouping comments by severity and quoting exact lines makes the review usable instead of a vague list of opinions.

15. Untangle a tightly coupled module

Turn on Thinking. This module does too much and is hard to change: [PASTE CODE]. Propose a cleaner design: identify the distinct responsibilities, suggest how to split them, and draw the new boundaries and dependencies in plain text. Then show the refactored code for the first, highest-value split. Keep behavior identical, and flag any hidden coupling that makes a clean separation risky.

Best for: A god-object or tangled file you want to break apart step by step without a big-bang rewrite.

Advertisement

Tests & documentation

Qwen writes coverage, docstrings, and READMEs from the code itself. Give it the framework and conventions you use, and ask it to flag anything ambiguous while it works so gaps surface early. For a quick reference on modes and modifiers, see the Qwen prompt cheat sheet.

16. Write thorough unit tests

Write thorough unit tests for this function using [TEST FRAMEWORK]: [PASTE FUNCTION]. Cover the happy path, edge cases, invalid inputs, and boundary conditions. Name each test for the behavior it checks, keep them independent and readable, and mock [EXTERNAL DEPENDENCIES] where needed. Flag any behavior in the function that looks like a bug or is ambiguous enough to need a spec decision rather than silently testing it as-is.

Why it works: Asking Qwen to flag ambiguous behavior surfaces spec gaps while it's writing coverage.

17. Add edge-case and property tests

Here's a function and its existing tests: [PASTE CODE AND TESTS]. Find the cases the current tests miss — empty and huge inputs, unicode, nulls, off-by-one boundaries, concurrent access, and malformed data. Add tests for the gaps in [TEST FRAMEWORK]. Where a property holds for all valid inputs (e.g. round-trips, invariants), write a property-based test for it and explain the property in one line.

Best for: Hardening code that already has happy-path tests but breaks on the inputs nobody thought about.

18. Write docstrings and inline comments

Add documentation to this code: [PASTE CODE]. Write a docstring for each public function in [STYLE — e.g. Google / NumPy / JSDoc] covering purpose, parameters, return value, and any raised errors or side effects. Add inline comments only where the intent isn't obvious from the code — explain the why, not the what. Don't change any logic. Return the fully documented code.

Why it works: "Explain the why, not the what" keeps the comments useful and stops Qwen from narrating obvious lines.

19. Generate a README from the code

Here's my project's code and structure: [PASTE KEY FILES / TREE]. Write a clear README in Markdown: a one-line description, what it does, install and setup steps, a minimal usage example that actually runs, the main configuration options, and how to run the tests. Keep it accurate to the code — don't document features that aren't there. Note anything a new contributor would trip over.

Best for: A first README that matches the real code, generated from the project instead of a generic template.

20. Explain unfamiliar code

Explain what this code does to a developer new to [LANGUAGE / LIBRARY]: [PASTE CODE]. Start with a one-paragraph overview of its job, then walk through the tricky parts block by block, and call out any bugs, edge cases, or performance concerns you notice along the way. Skip the obvious lines and keep it concrete. End with the two or three things I'd need to know before changing it.

Why it works: Ending with "what to know before changing it" turns an explanation into onboarding you can act on.

SQL, regex & data

Give Qwen your schema or a data sample and it writes queries, regexes, and wrangling scripts. Use Code Interpreter when you want the code to actually run — it executes Python in a sandbox for analysis, math, charts, and file processing, and returns real results, not just source.

21. Write a SQL query from a schema

Here's my schema: [PASTE TABLES AND COLUMNS]. I'm on [DATABASE — e.g. PostgreSQL]. Write a query that [WHAT YOU NEED]. Use clear aliases, only the joins you need, and handle nulls and duplicates correctly. Return the query, a one-line explanation of what each join and filter does, and note any assumption about the data (e.g. that a column is unique). Suggest an index if the query would be slow at scale.

Best for: Getting a correct, readable query from a real schema instead of a guess about your column names.

22. Build and test a regex

Write a regex for [FLAVOR — e.g. JavaScript / PCRE] that matches [WHAT TO MATCH] and does not match [WHAT TO EXCLUDE]. Here are real examples of both: should match [LIST], should not match [LIST]. Return the pattern, explain each part in plain English, and show it correctly classifying every example above. Warn me about any catastrophic-backtracking or edge-case risk in the pattern.

Why it works: Giving positive and negative examples lets Qwen test the pattern against your real cases and catch a regex that's too greedy or too strict.

23. Wrangle data with Code Interpreter

Use Code Interpreter. I've attached [CSV / spreadsheet]. Load it, then: clean [DESCRIBE THE MESS — missing values, inconsistent formats, duplicates], compute [WHAT YOU NEED — e.g. totals by category], and show me the result as a table and a quick chart. Print the row counts before and after cleaning so I can see what was dropped, and give me the cleaned file to download plus the Python you ran.

Best for: Actually running the cleanup on your file and getting results back, not just a script you have to set up and run yourself.

24. Optimize a slow SQL query

Turn on Thinking. This query is slow: [PASTE QUERY]. Schema and rough table sizes: [PASTE]. Here's the query plan if it helps: [PASTE EXPLAIN OUTPUT]. Explain why it's slow, then rewrite it to be faster while returning the same rows. Recommend specific indexes, note whether they help writes or storage, and show the before-and-after approach. Keep it valid for [DATABASE].

Why it works: Feeding in the plan and table sizes lets Qwen reason about the actual cost drivers instead of guessing at what's expensive.

Repo-scale & Qwen Code

The 1M-token context is the headline feature for coding: paste a whole repo and ask Qwen to reason across it. For changes that need to touch many files on disk, use Qwen Code, the open-source command-line agent that reads, edits, and runs commands across your project. The reasoning guide covers how to prompt it for multi-step work.

25. Map a whole repo in the 1M context

Turn on Thinking. I'm pasting my whole repo below. Read it, then give me: a one-paragraph summary of what the project does, the main modules and how they depend on each other, the entry points and data flow, and the three areas that look riskiest or most tangled. Point to exact files and functions. Don't summarize file by file — explain the system. Repo: [PASTE REPO].

Why it works: The 1M-token window holds a real codebase, so Qwen can describe the architecture from the actual source instead of from filenames alone.

26. Plan a framework migration

Turn on Thinking. Here's my codebase: [PASTE REPO OR KEY FILES]. I want to migrate from [OLD — e.g. framework/version] to [NEW]. Produce a migration plan: what changes and why, the order to do it in so the app stays working, the risky spots that need manual review, and an estimate of effort per stage. Then show the migrated code for the first, self-contained step so I can validate the approach before committing to it.

Best for: A staged, low-risk migration plan grounded in your actual code rather than a generic upgrade guide.

27. Drive a multi-file change with Qwen Code

You are working in my project with Qwen Code. Goal: [DESCRIBE THE CHANGE — e.g. rename a concept across the codebase, or add a field end to end]. First scan the project and list every file that needs to change and why, then propose the plan and wait for my go-ahead. Once I approve, make the edits, run [TEST / LINT COMMAND], and report what passed, what failed, and any file you weren't sure about.

Why it works: Asking Qwen Code to plan and get approval before editing keeps an agentic multi-file change under control instead of letting it rewrite half the repo unsupervised.

28. Audit dependencies and upgrade paths

Turn on Thinking. Here are my dependency manifest and lockfile: [PASTE]. Identify which packages are outdated, which have known-breaking major upgrades, and which look unmaintained or redundant. For each recommended upgrade, note whether it's a safe patch or a breaking change, what in my code would need to adapt, and the order I should tackle them in. Flag any dependency I could drop entirely and what I'd replace it with.

Best for: Turning a stale dependency list into a prioritized, low-surprise upgrade plan.

That's the full set. Bookmark this collection at /qwen-prompts-coding, keep the Qwen prompt cheat sheet open for the modes and modifiers, and browse 40 Best Qwen Prompts for writing, research, and everyday work.

Frequently Asked Questions

Which Qwen model and context window are these coding prompts for?

They target Qwen3.7-Max, the agent flagship released in May 2026, with a 1M-token context window — big enough to paste whole repos, long logs, and multiple files at once. They also work on Qwen-Plus and Qwen-Flash for lighter or higher-volume tasks. Run them free at chat.qwen.ai or in the iOS and Android apps.

Should I turn on Thinking mode for debugging?

Yes. Turn on Thinking for any bug that isn't obvious. Qwen shows its full chain-of-thought before the fix, so you can watch it reason from the error to the root cause and catch a confident-but-wrong answer. For quick edits or boilerplate, leave it on Fast or Auto.

When should I use Web Dev versus Code Interpreter?

Web Dev generates full websites and apps from a natural-language prompt and previews them live — use it to build UIs and front ends. Code Interpreter runs Python in a sandbox for data analysis, math, charts, and file processing — use it when you need code to actually execute and return results, not just source you copy out.

What is Qwen Code?

Qwen Code is an open-source command-line coding agent, comparable to Claude Code. It runs in your terminal, reads and edits files across your project scaffold, runs commands, and works agentically on multi-file changes. Use it for repo-scale refactors and migrations that need to touch many files.

Is Qwen free and open-source?

Qwen Chat is free at chat.qwen.ai and in the mobile apps. The open-weight Qwen3 models are on Hugging Face and GitHub under the Apache 2.0 license, so you can self-host them, and Qwen Code is open source too. The proprietary Qwen3.7-Max is available through Qwen Chat and the API.

How do the [BRACKET] placeholders work?

Anything in square brackets is a swap-in. Replace [PASTE ERROR], [LANGUAGE], or [SPEC] with your own details before sending. The rest of each prompt is written to be copy-paste ready.

Advertisement