Lesson 03 — Custom Skills: Give Your AI a New Trick
Goal: Write a custom Skill so that AI automatically applies your preset behavior in specific scenarios.
What Is a Skill?
A Skill is a Markdown file (SKILL.md) that gets injected into the AI's context when you invoke a slash command, telling the AI "what to do and how to do it right now."
/code-review → Inject SKILL.md → AI reviews code according to preset rules
Skills are stored at:
~/.openclaw/workspace/skills/<skill-name>/SKILL.md
Step 1: Create the Skill Directory
mkdir -p ~/.openclaw/workspace/skills/code-reviewStep 2: Write SKILL.md
Create ~/.openclaw/workspace/skills/code-review/SKILL.md:
# Senior Code Reviewer
You are now a senior code reviewer. The user will paste code, and you need to:
## Review Dimensions
1. **Correctness** — Are there any logic bugs? Are edge cases handled?
2. **Security** — Are there risks like SQL injection, XSS, or unsafe deserialization?
3. **Performance** — Are there obvious bottlenecks or unnecessary complexity?
4. **Readability** — Are names clear? Are comments adequate?
5. **Best Practices** — Does it follow idiomatic conventions for this language/framework?
## Output Format
List issues in a Markdown table:
| Line | Severity | Issue Description | Suggested Fix |
|------|----------|-------------------|---------------|
| ... | 🔴High/🟡Medium/🟢Low | ... | ... |
Finish with an overall score (1–10) and a one-sentence summary.
## Tone
Professional but friendly — when pointing out issues, always provide a fix example.Step 3: Use the Skill
In WebChat or Telegram, type:
/code-review
def login(username, password):
query = f"SELECT * FROM users WHERE name='{username}' AND pwd='{password}'"
return db.execute(query)
AI will automatically adopt the reviewer role and output a structured code review report.
More Skill Examples
Daily Briefing (/briefing)
# Daily Briefing Assistant
Organize the information the user provides into a concise daily briefing in this format:
## 📅 [Date]
### Key Items
- ...
### To-Do
- [ ] ...
### Notes
...
Keep language concise, prioritize key points, stay under 300 words.Translation & Polish (/polish)
# Professional Translation & Polish
You are a bilingual Chinese-English writing expert. The user will provide Chinese or English text, and you need to:
1. Detect the language
2. Translate it into the other language
3. Polish the translation to make it more natural and idiomatic
4. Present three versions for comparison: original, literal translation, and polished version
Maintain accuracy of technical terms; avoid machine-translation tone.Diagram Generator (/diagram)
# Mermaid Diagram Generator
Convert the user's text description into Mermaid diagram code.
Supported types:
- flowchart
- sequenceDiagram
- classDiagram
- gantt
Output format:
\```mermaid
...diagram code...
\```
Then explain the diagram structure in plain text.Skill Directory Structure
~/.openclaw/workspace/skills/
├── code-review/
│ └── SKILL.md
├── briefing/
│ └── SKILL.md
├── polish/
│ └── SKILL.md
└── diagram/
└── SKILL.md
View Installed Skills
pnpm openclaw skills listAdvanced: Calling Tools Inside Skills
In SKILL.md you can instruct AI to use specific tools:
# Web Page Summarizer
The user provides a URL. You need to:
1. Use browser_navigate to open the page
2. Use browser_snapshot to get the content
3. Distill the core points and output a 3–5 bullet summaryFAQ
How do I troubleshoot a slash command that isn't working?
First run pnpm openclaw skills list to confirm the skill is recognized. Common causes: ① The directory name doesn't match the slash command (case-sensitive); ② The SKILL.md filename has a case error; ③ The skill directory hierarchy is wrong — it must be ~/.openclaw/workspace/skills/<skill-name>/SKILL.md. No gateway restart needed after changes; just resend the command.
What built-in tools can a Skill use?
SKILL.md can instruct AI to use any of OpenClaw's built-in tools, including browser tools (browser_navigate, browser_snapshot, browser_action), file read/write tools, and other tools enabled via configuration. Describe the behavior you want in natural language inside SKILL.md, and AI will automatically select the right tools.
Are there length or format requirements for SKILL.md?
No hard limits, but we recommend keeping it under 500 words. A very long SKILL.md consumes more context tokens, increases costs, and can reduce AI instruction-following accuracy. Using clear Markdown headings (# main heading, ## sections) helps AI understand the structure better.
Do I need to restart the gateway after editing a Skill?
No. OpenClaw re-reads the SKILL.md file every time a slash command is invoked, so changes take effect immediately. However, if you modify settings in openclaw.json, a gateway restart is required.
Can multiple Skills be combined?
Yes. Within a single message, call /skillA and AI will maintain that skill's behavior until you send /new to start a new session. You can also integrate multiple capabilities into one SKILL.md to create an "all-in-one" skill.