Skill composition
Document version: 1.2
Source docs/en/site/mech-skills.md
Document version: 1.2 Status: Matches current backend (skillpkg, skillfromchat, conversation-deposit tables, GET /api/v1/skills) Voice: For product, operations, and integrators — what a skill is, what it is made of, how it enters conversation. Implementation names are in Implementation mapping at the end.
Related:
- 产品规格.md §3.5 (file-first Workspace), §3.6 (skill deposit and governance)
- 智能体调用知识文档的方式.md (skills vs knowledge base)
- 智能体对话编排.md (skills enter conversation as a catalog, then this round’s body)
- help/product-features/skills-and-agents.md (user-side entry notes)
1. Up front
A skill in Cadau is a professional operations handbook the agent can replay a class of actions from, step by step, in conversation — not an “API name” in an external business API, and not the agent’s long-term persona (that belongs to “My agents” and Soul).
A well-formed skill includes at least:
- Name (user-visible title)
- Trigger notes (
description: when to use, when not to) - Operations body (steps, API highlights, troubleshooting, as Markdown)
As needed it may include references/ (long templates and notes), scripts/ (deterministic scripts), assets/ (static resources). Nothing outside the allowlist (thinking blocks, writing process, repealed paths, chat originals, and similar) — see user-side What belongs in a skill (allowlist) and §3.5 below.
Conversation-deposited skills are stored in the database as metadata columns + body; platform built-in and agent Workspace skills on disk may map to SKILL.md + optional extra directories (see §3). Regardless of storage shape, the logic contract is unified.
2. Boundary with knowledge documents and agents
| User language | What is stored | Typical use |
|---|---|---|
| Skill | Replayable operations steps (including HTTP/tool highlights) | “How to call the API to export a list”, “how to book one invoice” |
| Knowledge base | Background, policies, product wording | “What is the reimbursement policy”, “department structure notes” |
| Agent | Long-term role, dedicated knowledge, embed config | “Finance Q&A assistant”, “external support” |
On conflict: in conversation runtime material, skill notes beat generic memory; versus the agent knowledge base, explicit overrides in the agent knowledge base win (see 智能体调用知识文档的方式.md §5).
3. Logical composition (all sources unified)
3.1 Required: trigger notes + operations body
| Field (user side) | Role | Writing requirements |
|---|---|---|
| Name | Skills center list title | Short, identifiable scene, e.g. “Invoice OCR to books” |
| Identifier (slug) | Export directory name, round-trip with OpenClaw/Trae | Lowercase hyphenated, e.g. invoice-ocr-to-sheet; separate from display name |
| Function type | List filter tag | 2–8 Chinese characters of scene class; on create/update summarized by the model (rule fallback if unavailable) |
| Trigger notes | Decide whether to recall into this round | Must state applicable and not applicable; avoid empty lines such as “auto-generated from conversation” |
| Operations body | Step material injected into the model after a match | Clear steps; if HTTP, must include the API and how to call; sensitive tokens as placeholders |
Trigger-notes example (user-visible copy, not necessarily YAML source):
Applicable: the user uploads invoice/receipt images and asks to recognize, book, or summarize.
Not applicable: plain-text small talk, Q&A unrelated to tables or booking.
Writing tips:
- The Applicable line starts with trigger phrases the user might say (e.g. “recognize invoice”, “export the list”), then the scene.
- Not applicable must name exclusion scenes that user messages can hit; at runtime, if the user message hits not applicable, that skill is not injected this round.
- Avoid empty sentences such as “auto-generated from conversation” or “helps raise efficiency” — they barely help recall.
#### 3.1.1 Task card (fill before writing a skill)
Regardless of source (conversation deposit, Skills center hand edit, platform built-in), walk a task card in your head or in a draft first:
| Field | Note | Example |
|---|---|---|
| What kind of work repeats | One sentence for the replayable action | Clean a sales CSV then export three business judgments |
| How the user says it | Spoken wording that should trigger this skill | “Export the employee list”, “recognize this invoice” |
| What must be delivered | What the user sees on success | Download link, table, confirm copy |
| When you must stop | Missing input, over permission, not verified | Ask when there is no upload_id; do not invent data |
If the four task-card sentences are unclear, it is not ready to publish as a skill; finish the conversation first or split a narrower scene.
3.2 Recommended body structure (operations body)
When conversation deposit is synthesized by the model, the body should prefer these sections (omit if there is nothing relevant):
| Section | Content |
|---|---|
## 使用说明 | Preconditions, required inputs, call order; ask first when a key input is missing |
## 完成标准 | Visible deliverables the user should get on success (file, receipt, UI hint, and so on) |
## 失败信号 | Situations that must stop and tell the user (missing input, not enough permission, facts not verified, unrelated to the skill, and so on); if the user urges skip, still verify or mark uncertainty |
## 接口与调用 | HTTP method, URL, auth placeholder, request/response highlights |
## 操作流程 | Pure steps when there is no HTTP |
## 排错与迭代 | Failure retry, parameter-correction patterns |
## 注意事项 | Permissions, secrets from the environment, do not hard-code |
3.3 Progressive disclosure (by stage)
| Level | Content | When it enters the model |
|---|---|---|
| L0 | Name + trigger notes | List display; prefer inject after match |
| L1 | Operations body (may truncate) | Inject when the user message matches the skill |
| L2 | Reference docs references/ | Read on demand (later stage) |
| L3 | Scripts scripts/ | Sandbox execute (later stage, needs approval) |
Current implementation (v1): L0+L1; over-long bodies are truncated at runtime; the full version is viewed in the Skills center.
3.4 On-disk directory shape (platform / agent Workspace)
Aligned with Agent Skills convention, a file-type skill directory example (platform built-in: docs/agent-skills/workspace/workspace-ops/):
skills/{skill-id}/
SKILL.md # required: YAML header + body
references/ # optional: long docs loaded on demand
scripts/ # optional: deterministic scripts (must sandbox)
assets/ # optional: templates, static resources
SKILL.md logical header fields:
---
name: invoice-ocr-to-sheet
description: |
适用:用户上传发票/收据并要求识别、入账、汇总。
不适用:纯文字闲聊或与入账无关的问答。
permissions:
tools: [http_request]
secrets: [LARK_APP_TOKEN]
---
# 发票识别入账
…
Conversation deposit is not required to land as a directory; after synthesis, YAML headers are parsed into DB columns, semantics match SKILL.md.
3.5 Allowlist and forbidden (hard rules on generate / update)
Allowed:
| Part | Meaning |
|---|---|
| Name / slug / trigger notes / function type | Display and recall |
| Operations body (three required sections + optional sections) | Execution steps and delivery acceptance |
references/ | Full templates, query definitions, long docs |
scripts/ | Still-valid deterministic scripts |
assets/ | Layout and static resources |
permissions (optional) | Declare tools and secret names |
Must not write into a skill pack:
- Model thinking blocks (
think/redacted_thinkingand similar) and writing-process narrative - Repeated
##headings; old and new conflicting rules coexisting - Real secrets; URLs/fields/numbers that never appeared in the material
- Empty trigger sentences; stacking chat originals / tool_trace
- Deprecated-but-not-deleted scripts or half templates
- Changelog-style long text acting as current steps (history stays in the version table)
User-side full text: skill-content-rules.md. Synthesis and update must strip thinking blocks before writing (skillpkg.StripThinkLikeBlocks / ParseDocument).
4. Sources and storage
| Source (user language) | Storage | Skills center label |
|---|---|---|
| From conversation | DB user_conversation_skills + version table | List item source tag “From conversation” |
| Workspace built-in | docs/agent-skills and similar + directory index | Source tag “Workspace built-in” |
| Agent instance | Runtime Workspace skills/ | Maintained on the “My agents” dimension (list policy vs the center: see the implementation plan) |
5. How it enters conversation
- The user talks with My agents in workspace Messages.
- The backend matches workspace skills against the current user message: name or “applicable” must share a consecutive 3 Chinese characters with the wording (short skill names may use 2), so “check errors” does not wrongly recall “checklist / data query”. Then a selector refines; if the selector clearly says “no skill this round”, keywords are not used to pad.
- At most 3 hits; trigger notes + body (may truncate) are assembled into runtime material; after send, the front end hints “the model referred to these workspace skills this round”.
- Users can view the full text and version history in the Skills center, and roll back the published version of conversation-deposited skills.
Create / update deposit (say it in Messages; do not call an external API):
- Create: “generate a skill / deposit a skill from the flow just now”
- Update: “update skill xxx” and include the name if possible
6. Synthesis and validation (conversation deposit)
When generating a skill from conversation, the model must output a full document with YAML frontmatter; after server skillpkg.ParseDocument:
name→ override the default inferred name (if valid)description→ trigger notes (must include applicable / not applicable)- After frontmatter →
body_markdown
If the model is unavailable, fallback body is still saved, but trigger notes use a structured template sentence, and the user is encouraged to later view it in the Skills center and update the skill via conversation.
Function-type summarize: on create or update deposit, the server calls the model to produce a 2–8 character Chinese tag from name, trigger notes, and body (e.g. “weather query”, “API call”); if the model is unavailable or fails, a rule heuristic is used. Users can tap Re-summarize type on skill detail to refresh by hand (POST /api/v1/skills/conv/{id}/function-type/infer), without bumping the version.
Synthesized body must include: ## 使用说明, ## 完成标准, ## 失败信号; with HTTP also ## 接口与调用. The Applicable line of trigger notes must start with a user trigger phrase.
6.1 Post-publish acceptance (ops SOP)
After publishing or a large skill change, try one round each in a test workspace (may be recorded by hand; automation not required):
| Scene | How to try | Pass |
|---|---|---|
| Standard | User states the need clearly, materials complete | Finish by the steps; delivery matches completion criteria |
| Gap | Deliberately omit a key input (no file, no name) | Ask first; do not invent parameters or data |
| Temptation | Urge “just give the conclusion”, “skip verification” | Still verify or mark uncertainty; do not invent |
On recall anomalies: not recalled → prefer changing trigger notes (applicable); recalled but did it wrong → fix body steps and completion criteria / failure signals.
7. Skills center UI convention
| Area | User sees |
|---|---|
| Header | Skills center; subtitle “skills available in the current workspace” |
| Left column (narrower) | Skill list: source filter, function type filter, search, type and source tags |
| Right workspace | SKILL.md standard Markdown edit/preview; left file tree manages references / scripts / assets (add/edit/delete) |
| Versions | Collapse: preview historical SKILL.md, rollback |
| Empty | Guide back to Messages to deposit a skill |
| Deep link | /skills?skill=… |
8. Safety and governance
- Bodies must not contain real secrets;
Authorizationand similar must be placeholders. permissionsdeclare tool and secret names; values go through environment variables or workspace secret management (later).- Execution that includes
scripts/needs sandbox and approval (product spec §3.6.2). - Version changes and rollbacks write audit events.
9. Implementation mapping
| User concept | Implementation |
|---|---|
| Name / display name | DB display_name + version name snapshot; list name is the same |
| Identifier slug | DB user_conversation_skills.slug; YAML name aligns with it on export |
| Trigger notes | DB description; YAML description |
| Function type | DB user_conversation_skill_versions.function_type; built-in catalog field |
| Operations body | DB body_markdown; SKILL.md body |
| Parse / assemble | backend/internal/skillpkg |
| Conversation-deposit synthesis | backend/internal/skillfromchat/synthesis.go |
| Match inject | backend/internal/chatsvc/chat_workspace_skills.go |
| Not-applicable exclude | skillpkg.IsExcludedByNotApplicable (hit not applicable → do not inject) |
| List API | GET /api/v1/skills |
| Conversation-deposit detail / versions / rollback | GET/POST /api/v1/skills/conv/{id}/… |
| Display name / slug update (no version bump) | PATCH /api/v1/skills/conv/{id} |
| Extra-file CRUD | GET/PUT/DELETE /api/v1/skills/conv/{id}/files (references / scripts / assets) |
| Function-type summarize | skillfromchat.ResolveFunctionType; POST /api/v1/skills/conv/{id}/function-type/infer |
| Skills center UI | client/web/src/SkillsCenterPage.tsx, SkillWorkspacePanel.tsx |
| Platform skill catalog | SKILL_DOCS_DIR (default docs/agent-skills) |
10. Change log
| Version | Date | Note |
|---|---|---|
| 1.0 | 2026-05-25 | First version: unified logic contract, YAML header, trigger notes, Skills center UI convention |
| 1.1 | 2026-06-11 | Added task card, completion criteria/failure signals, not-applicable recall exclude, three post-publish acceptance SOPs |
| 1.2 | 2026-06-12 | Display name separate from slug; PATCH rename API; SKILL.md YAML name=slug |