5 min read
ai developer-tools

Qwen Code Setup: Free AI Coding with Extensions, PDCA Workflows, and Context Engineering

TL;DR: Here’s my Qwen Code stack:

LayerToolProblem It Solves
1 — RAGContext7 + Tavily (7 skills)Outdated docs → hallucinated code
2 — Context Engineeringcontext-modeTool output bloat → burned context window
3 — Workflow Enginebkit (21 agents, 35 skills, 10 hooks)Chaotic workflows → structured PDCA pipeline
4 — Shared Skills26 skills (~/.agents/skills/)No domain knowledge → generic output
5 — Modelcoder-model (Qwen3-Coder)Cost → free (2,000 req/day)

Start with whatever solves your biggest pain point:

  • Want structured dev workflow → bkit
  • Outdated docs → Context7
  • Context bloat → context-mode
  • Domain-specific quality → shared skills

Why Qwen Code?

I already have an opencode setup that works well. But opencode requires a paid model provider. Qwen Code gives me a fully open-source (Apache 2.0) AI coding agent with 2,000 free requests per day via Qwen OAuth — no credit card, no subscription.

The selling points:

AspectQwen CodeMy opencode Setup
CostFree (2,000 req/day)Paid (Z.AI Coding Plan)
LicenseApache 2.0Open source
Extension sourcesQwen + Gemini + Claude marketplacesSkills-based only
IDE supportVS Code, Zed, JetBrainsTerminal
SDKTypeScript + JavaNone
SubagentsConfigurable concurrency/nestingTask-based
SWE-bench~69.6%N/A (provider-dependent)

The 0.8% gap behind Claude on SWE-bench at $0 vs $240/year makes it a no-brainer for everyday tasks.


The Architecture

My Qwen Code setup follows the same three principles as my opencode config:

  1. Prompt Engineering — bkit’s 21 agents and 35 skills enforce structured workflows
  2. RAG — Context7 + Tavily provide current information
  3. Context Engineering — context-mode protects the context window
flowchart TB subgraph Core["Core Workflow — bkit PDCA"] P["Plan
pm-discovery, pm-lead"] D["Design
phase-1 to phase-9"] C["Check
code-review, qa-monitor"] A["Act
pdca-iterator, deploy"] end subgraph L1["Layer 1: RAG"] R1["Context7
Live library docs"] R2["Tavily (7 skills)
Search, extract, research"] end subgraph L2["Layer 2: Context Protection"] CM["context-mode
Sandbox execution
FTS5 knowledge base"] end subgraph L3["Layer 3: Domain Skills"] S1["Vue/Go/Tailwind/Astro
framework skills"] S2["Testing/Security
vitest, accessibility"] S3["Research
tavily-*, find-docs"] end P --> D --> C --> A Core --> L1 Core --> L2 Core --> L3 style Core fill:#fff3e0,stroke:#f57c00,stroke-width:3px style L1 fill:#e3f2fd,stroke:#1976d2,stroke-width:2px style L2 fill:#e8f5e9,stroke:#388e3c,stroke-width:2px style L3 fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px

The Core — bkit PDCA Workflow Engine

Without structure, AI assistants freestyle. bkit solves this by enforcing the PDCA (Plan-Do-Check-Act) methodology — a 10-event hook system that intercepts the full Qwen Code lifecycle.

What Is bkit?

bkit is an extension originally built for Gemini CLI that auto-converts to Qwen Code format. It provides three layers of Context Engineering:

LayerComponentsCountPurpose
Domain KnowledgeSkills35Expert knowledge activated on-demand
Behavioral RulesAgents21Role-based constraints with model/tool config
State ManagementHook Scripts + Lib Modules17 + 13PDCA tracking, intent detection, permission control

The 10-Event Hook System

bkit intercepts Qwen Code’s full lifecycle:

flowchart LR A["SessionStart
Init + level detect"] --> B["BeforeAgent
Intent detection"] B --> C["BeforeModel
Prompt augmentation"] C --> D["AfterModel
Response tracking"] D --> E["BeforeToolSelection
Phase-based filtering"] E --> F["BeforeTool
Permission blocking"] F --> G["AfterTool
Phase auto-transition"] G --> H["AfterAgent
Cleanup"] H --> I["PreCompress
Context snapshot"] I --> J["SessionEnd
Memory persistence"] style A fill:#e3f2fd,stroke:#1976d2,stroke-width:1px style B fill:#e3f2fd,stroke:#1976d2,stroke-width:1px style C fill:#fff3e0,stroke:#f57c00,stroke-width:2px style F fill:#ffcdd2,stroke:#d32f2f,stroke-width:2px style I fill:#e8f5e9,stroke:#388e3c,stroke-width:1px

The key insight: phase-based tool filtering. During the Plan phase, bkit restricts tools to read-only. During Do, all tools unlock. This prevents the AI from making changes before it understands the codebase.

The 21 Agents

bkit provides specialized agents that auto-activate based on task type and project level:

CategoryAgentsWhat They Do
Orchestrationcto-lead, pipeline-guideHigh-level task delegation and workflow management
Productpm-discovery, pm-lead, pm-prd, pm-research, pm-strategy, product-managerRequirements, research, PRD generation
Codebkend-expert, frontend-architect, code-analyzer, design-validatorArchitecture, analysis, validation
Qualityqa-monitor, qa-strategist, security-architectTesting, QA, security review
Infrainfra-architectInfrastructure and deployment
Dynamicpdca-iterator, starter-guide, enterprise-expertLevel-specific guidance
Reportingreport-generator, gap-detectorAnalysis and gap identification

Project level auto-detection:

LevelTriggerDefault Agent
StarterDefault (no k8s/terraform/backend)starter-guide
Dynamicdocker-compose.yml, .mcp.json, backend dirsbkend-expert
Enterprisekubernetes/, terraform/ dirsenterprise-expert

The 35 Skills

The skills cover the full development lifecycle:

PhaseSkillsPurpose
Discoverypm-discovery, simplifyUnderstand what to build
Planningplan-plus, pdca, bkit-rulesStructured planning
Designphase-1-schema through phase-9-deployment9-phase design pipeline
Backendbkend-auth, bkend-data, bkend-security, bkend-storage, bkend-api, bkend-mcpBackend-specific guidance
Frontendphase-3-mockup, phase-5-design-system, phase-6-ui-integrationFrontend pipeline
Qualitycode-review, zero-script-qa, phase-8-reviewReview and testing
Metabkit-templates, bkit-rules, output-style-setup, loopConfiguration and iteration

Configuration

bkit installs as a Qwen Code extension with these settings:

{
"contextFileName": ["GEMINI.md"],
"settings": [
{
"name": "Output Style",
"description": "Response formatting style (bkit-learning, bkit-pdca-guide, bkit-enterprise, bkit-pdca-enterprise)",
"envVar": "BKIT_OUTPUT_STYLE"
},
{
"name": "Project Level",
"description": "Override auto-detected project level (Starter, Dynamic, Enterprise)",
"envVar": "BKIT_PROJECT_LEVEL"
}
]
}

Key bkit config highlights:

  • PDCA status file: .pdca-status.json — tracks phase transitions automatically
  • Auto-iterate: Enabled by default, up to 5 iterations per task
  • Model routing: Pro models for plan/design/do, flash models for check/act/report
  • Team orchestration: Supports up to 10 agents with 5 patterns (leader, council, swarm, pipeline, watchdog)
  • Agent memory: Persistent across sessions, scoped per-project or per-user

Installation:

Terminal window
qwen extensions install <bkit-repo-url>
qwen extensions settings bkit

Layer 1 — Current Information (Context7)

The Problem

Models trained months ago hallucinate confidently about APIs that have since changed.

The Solution — Context7 Extension

Context7 provides an MCP server that queries live library documentation on demand.

Installation:

Terminal window
qwen extensions install context7
qwen extensions settings context7 # Set CONTEXT7_API_KEY

Extension manifest:

{
"name": "context7",
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "${CONTEXT7_API_KEY}"]
}
}
}

Included skills (3):

SkillPurpose
context7-cliUse ctx7 CLI to resolve and fetch docs
context7-mcpUse Context7 MCP tools directly
find-docsUnified skill for finding library documentation

Workflow: Resolve library ID first (ctx7 library), then query docs (ctx7 docs). If you already know the ID, skip straight to querying. Supports version-specific docs.


Layer 2 — Context Protection (context-mode)

The Problem

Raw tool outputs flood the context window. A single Playwright snapshot is 56 KB. The session dies before any real work happens.

The Solution — context-mode

context-mode intercepts tool outputs and routes them through an isolated subprocess. Only condensed summaries enter context. Full data stays in a searchable FTS5 database.

AGENTS.md Enforcement

This is identical to my opencode setup — the same rules file works across both tools:

RuleWhat’s BlockedWhat You Use Instead
curl/wgetShell HTTP callsctx_fetch_and_index or ctx_execute
Inline HTTPfetch(), requests.get() in shellctx_execute sandbox
Shell >20 linesRaw command outputctx_batch_execute or ctx_execute

Tool hierarchy (same as opencode):

  1. GATHER: ctx_batch_execute — primary tool, one call replaces 30+ individual calls
  2. FOLLOW-UP: ctx_search — query indexed content with natural language
  3. PROCESSING: ctx_execute / ctx_execute_file — sandboxed subprocess execution
  4. WEB: ctx_fetch_and_index — fetch, chunk, index, query without touching context
  5. INDEX: ctx_index — store content in FTS5 for later retrieval

Output constraints:

  • Keep responses under 500 words
  • Write artifacts to files, not inline text
  • Use descriptive source labels for indexed content

Layer 3 — Domain Skills (26 Shared Skills)

These live in ~/.agents/skills/ and are shared between Qwen Code and opencode:

Framework Skills (10)

SkillDomainKey Capabilities
vueVue 3Composition API, <script setup>, reactivity
vue-best-practicesVueEnforces Composition API + TypeScript standard
vue-router-best-practicesVue Router 4Navigation guards, route params
vue-testing-best-practicesVue testingVitest, Vue Test Utils, Playwright
vueuse-functionsVueUseComposables for concise Vue features
piniaState managementType-safe stores, actions, getters
astroAstroSSG, islands, content collections
daisyui-5Tailwind CSS 4DaisyUI components and patterns
tailwind-design-systemDesign systemsTokens, component libraries
tailwindcss-advanced-layoutsTailwindCSS Grid and Flexbox patterns

Go Skills (2)

SkillDomain
golang-patternsIdiomatic Go, best practices
golang-documentationgodoc, README, examples

Research Skills (8)

SkillPurpose
find-docsFetch current library documentation
tavily-searchWeb search for current information
tavily-extractExtract content from known URLs
tavily-mapDiscover URLs on a website
tavily-crawlBulk extract from site sections
tavily-researchDeep multi-source analysis with citations
tavily-cliGeneral Tavily CLI reference
tavily-best-practicesProduction Tavily integration patterns

Quality & Other Skills (6)

SkillPurpose
vitestFast unit testing with Vite
accessibility-a11yWCAG compliance
web-design-guidelinesUI review and audit
slidevTechnical presentations
turborepoMonorepo build system
agent-browserBrowser automation

Why shared? Both Qwen Code and opencode support the ~/.agents/skills/ directory. One skill file, two AI assistants, zero duplication.


Global Configuration

settings.json

{
"security": {
"auth": {
"selectedType": "qwen-oauth"
}
},
"model": {
"name": "coder-model"
},
"permissions": {
"allow": [
"Bash(npm init *)",
"Bash(git add *)",
"Bash(git commit *)",
"Bash(git push)"
]
}
}

Output Language

Enforced via ~/.qwen/output-language.md:

  • Default: English (mandatory, not preference)
  • Exception: Explicit language request switches for remainder of conversation
  • Technical artifacts (code, CLI commands, file paths) preserved verbatim

File Structure

~/.qwen/
├── AGENTS.md # Context-mode routing rules
├── settings.json # Auth, model, permissions
├── output-language.md # Language enforcement
├── extensions/
│ ├── bkit/ # PDCA workflow engine
│ │ ├── qwen-extension.json
│ │ ├── bkit.config.json # 248-line centralized config
│ │ ├── agents/ # 21 specialized agents
│ │ ├── skills/ # 35 PDCA/phase skills
│ │ ├── hooks/ # 10-event hook system
│ │ ├── mcp/ # Spawn-agent MCP server
│ │ └── policies/ # Level-based policies
│ └── context7/ # Live documentation
│ ├── qwen-extension.json
│ └── skills/ # 3 doc-fetching skills
├── projects/ # Per-project chat history
└── todos/ # Persistent task tracking

What Makes Qwen Code Different

Beyond what I’ve configured, Qwen Code has features I haven’t fully explored yet:

Approval Modes

Four modes, cycled with Shift+Tab:

ModeFile EditsShellMCPBest For
planRead-onlyRead-onlyRead-onlyCode review, exploration
defaultPromptPromptPromptDaily development
auto-editAutoPromptPromptBulk refactoring
yoloAutoAutoAutoCI/CD, containers

Sandbox Execution

  • macOS: Seatbelt profiles (6 built-in: permissive/restrictive x open/closed/proxied)
  • Linux: Docker/Podman with custom Dockerfiles
  • Custom profiles: .qwen/sandbox-macos-*.sb or .qwen/sandbox.Dockerfile

LSP Integration

Experimental (--experimental-lsp): go-to-definition, find references, call hierarchy, hover, diagnostics, code actions.

Headless Mode

Terminal window
# Non-interactive for scripts/CI
qwen -p "Run tests and fix failures" --approval-mode yolo
# Pipe input
cat requirements.txt | qwen -p "Create a project from these requirements"
# Stream JSON for tool integration
qwen -p "Analyze" --output stream-json > session.jsonl

Multi-Provider Support

Use any model from one CLI:

{
"modelProviders": {
"openai": [
{ "id": "qwen3.5-plus", "baseUrl": "https://...", "envKey": "BAILIAN_CODING_PLAN_API_KEY" },
{ "id": "gpt-4o", "envKey": "OPENAI_API_KEY" }
],
"anthropic": [
{ "id": "claude-sonnet-4-20250514", "envKey": "ANTHROPIC_API_KEY" }
],
"gemini": [
{ "id": "gemini-2.5-pro" }
]
}
}

Switch models mid-session with /model.

Subagents

Configurable parallel task delegation:

{
"subagents": {
"maxConcurrent": 4,
"maxNestingDepth": 2,
"defaultModel": "gemini-2.5-flash",
"inheritApprovalMode": true
}
}

Session Checkpointing

Enable via general.checkpointing.enabled — restores token counts, request counts, and model usage on resume.


What I Could Install Next

Extension/ToolWhyInstall Command
qwen-cli-extensions/security/security:analyze security scanningqwen extensions install qwen-cli-extensions/security
qwen-cli-extensions/code-reviewAutomated code reviewqwen extensions install qwen-cli-extensions/code-review
server-github MCPNative GitHub Issues/PRs/Actionsqwen mcp add github npx -y @modelcontextprotocol/server-github
server-filesystem MCPFilesystem operations with searchqwen mcp add filesystem npx -y @modelcontextprotocol/server-filesystem ~
Claude Marketplace pluginsThousands of extensions/extensions explore ClaudeCode
Gemini Gallery extensionsMore options/extensions explore Gemini
qwen-code-actionCI/CD automated reviewGitHub Actions: uses: QwenLM/qwen-code-action@v1
LSPGo-to-definition, references--experimental-lsp

How It Compares to My Opencode Setup

Both setups share the same principles. The difference is execution:

AspectQwen CodeOpencode
CostFreePaid
Workflow enginebkit (PDCA, 21 agents, 10 hooks)Superpowers (brainstorming → TDD → verification)
Code intelligenceNot configuredGitNexus (knowledge graph, blast radius)
VisionNot configuredzai-mcp-server + agent-browser
Context protectioncontext-mode (shared AGENTS.md)context-mode (shared AGENTS.md)
RAGContext7 + Tavily (shared skills)Context7 + Tavily (shared skills)
Skills26 shared + 35 bkit = 61 total26 shared + Superpowers = ~30 total
ApproachHeavy process (PDCA)Light process (skill-driven)

When I use which: Qwen Code for structured feature work where PDCA adds value. Opencode for quick tasks, refactoring with GitNexus safety, and vision-dependent debugging.


Closing

The beauty of this setup is that most of it is portable. The 26 shared skills in ~/.agents/skills/ work in both Qwen Code and opencode. The context-mode AGENTS.md is identical. Only the workflow engine differs — bkit for Qwen Code, Superpowers for opencode.

If you’re looking for a free, powerful AI coding setup, start with Qwen Code + Context7 + context-mode. Add bkit when you need structured workflows. Add domain skills as you encounter specific frameworks.

The three principles hold regardless of tool choice: prompt engineering, RAG, and context engineering. Everything else is implementation detail.


References

ToolAuthorWhat It Does
Qwen CodeQwen (Alibaba)Open-source AI coding agent for the terminal
bkitPOPUP STUDIOPDCA workflow engine with Context Engineering
Context7Context7Live library documentation retrieval
context-modemksgluMCP plugin for context window protection
TavilyTavilyWeb search, extraction, crawling, and research
agent-browserVercelBrowser automation for AI agents
Qwen Code DocsQwenOfficial documentation

This article was written by opencode (GLM-5-Turbo | Z.AI Coding Plan).