After using Qwen Code for a while, you might notice unfamiliar skills appearing in .qwen/skills/skill-review, skill-testing — each tagged with source: auto-skill in their frontmatter. You didn’t create them. Nobody did manually.

This is Qwen Code’s AutoSkill mechanism: an automatic distillation system for procedural knowledge. This article reverse-engineers the mechanism from source code and design documents, covering its architecture, security model, and academic origins.

What is AutoSkill

In one sentence: after a session ends, Qwen Code automatically evaluates whether your workflow is worth reusing, and if so, saves it as a project-level skill.

It differs from Auto Memory in focus:

DimensionAuto MemoryAutoSkill
Knowledge typeDeclarative (who you are, project context)Procedural (how you do things)
TriggerEvery session endSessions with ≥ 20 tool calls
Write target.qwen/memory/.qwen/skills/
ContentUser preferences, project contextReusable workflows, best practices

Memory remembers who you are. AutoSkill remembers how you work.

Trigger Conditions

Session ends
  ├─ toolCallCount ≥ 20 ?        // Too few calls → skip
  ├─ skillsModifiedInSession ?   // User edited skills this round → skip
  └─ Both pass → scheduleSkillReview()
               └─ Fork standalone agent (8-turn limit, 2-min timeout)

The threshold ensures only sessions with substantial tool usage trigger review — avoiding low-quality skills from simple Q&A sessions. The review runs in an independent agent (not a continuation of your conversation), capped at 8 turns and 2 minutes.

Permission Sandbox: The Core Security Design

The most elegant part of AutoSkill is its security model. The review agent is locked in a strict sandbox:

ToolPermissionSecurity Mechanism
read_file✅ Within project rootPrevents reading ~/.aws/credentials and injecting into SKILL.md
ls✅ Within project rootSame as above
write_file⚠️ Only .qwen/skills/<name>/SKILL.mdCan only create non-existent files (prevents overwriting)
edit⚠️ Only .qwen/skills/ + target must contain source: auto-skillCannot modify user-authored skills

Core principle: auto-skill can only touch what it created — never user-authored skills.

The source: auto-skill Protection

Two layers of defense:

  1. Hard constraint (permission manager): edit reads frontmatter first; no source: auto-skill → rejected
  2. Soft constraint (system prompt): “You may ONLY modify skill files that contain ‘source: auto-skill’”

If you add source: auto-skill to your own skill, you’re opting in to automatic updates by the review agent.

Preventing Name Collision Overwrites

// write_file only allows creating new files
try {
  await fs.stat(ctx.filePath);
  return 'deny';  // File exists → reject
} catch (err) {
  if (err.code === 'ENOENT') return 'allow';  // Doesn't exist → allow creation
  return 'deny';
}
  • Creating a new skill → write_file
  • Updating an existing auto-skill → must use edit
  • Overwriting any existing file → rejected ❌

assertRealProjectSkillPath() uses fs.realpath() to resolve the actual path, confirming it stays within .qwen/skills/ — preventing writes to arbitrary locations via symlinks.

Academic Origins

Trace2Skill paper (arXiv: 2603.25158)
Hermes Agent (Nous Research, open-source) — original prompt source
    ↓ Qwen Code design doc: "ported from Hermes _SKILL_REVIEW_PROMPT, minimal adaptation"
Qwen Code AutoSkill

The Qwen Code design document explicitly states:

The review agent’s prompt is directly ported from Hermes _SKILL_REVIEW_PROMPT with minimal adaptation.

Hermes’s original prompt is far more detailed — including CLASS-LEVEL skill organization, preference embedding, protected skills, and Do NOT capture lists. Qwen’s version is significantly streamlined, focusing on “non-trivial approaches” and “trial-and-error processes.”

Hermes vs Qwen Code

HermesQwen Code
TriggerIn-session agent call + post-session reviewPost-session background fork only
ProtectionContextVar tracking + tool whitelist + protected skillssource: auto-skill frontmatter + file-level permission manager
Write scope~/.hermes/skills/ (global).qwen/skills/ (project-level)
Prompt complexityDetailed (skill organization, preference embedding, etc.)Streamlined (focused on reusable workflows)

Comparison with Other Agents

AgentAuto-distills procedural skillsNotes
Hermes Agent✅ Yes (in-session + post-session)First open-source implementation, with tool whitelist + protected skills
Qwen Code✅ Yes (post-session)Ported Hermes prompt + file-level permission sandbox
Claude Code❌ NoAuto Memory records declarative knowledge only
Cursor❌ NoSkills are entirely manual
Pi❌ NoSkills entirely manual, Memory managed manually
Codex CLI❌ NoBuilt-in skills + AGENTS.md extension, no auto-distillation
Gemini CLI❌ NoManual SKILL.md creation, Memory reads GEMINI.md

Currently only Hermes and Qwen Code implement automatic procedural skill distillation. All other major AI coding agents remain in manual-management territory.

References

  • Design doc
  • Source: packages/core/src/memory/skillReviewAgentPlanner.ts
  • First commit: 2026-05-09 (#3673), enabled by default: 2026-05-27 (#4547)
  • Trace2Skill paper