Back to home page

EIC code displayed by LXR

 
 

    


Warning, /swf-testbed/docs/skills-for-testbed.md is written in an unsupported language. File is not indexed.

0001 # Creating Custom Skills for Qwen Code and Claude Code
0002 
0003 This guide shows you how to create custom skills for AI coding assistants (Qwen Code, Claude Code) to automate repetitive tasks with structured workflows.
0004 
0005 ---
0006 
0007 ## Table of Contents
0008 
0009 - [What is a Skill?](#what-is-a-skill)
0010 - [Directory Structure](#directory-structure)
0011 - [Creating a Skill](#creating-a-skill)
0012 - [Example: testbed-audit](#example-testbed-audit)
0013 - [Best Practices](#best-practices)
0014 - [Troubleshooting](#troubleshooting)
0015 
0016 ---
0017 
0018 ## What is a Skill?
0019 
0020 A **Skill** is a reusable instruction template that tells an AI assistant how to perform a specific task consistently. Skills are useful for:
0021 
0022 - **Standardizing workflows** (e.g., testbed audits, health checks)
0023 - **Enforcing constraints** (e.g., "use only this tool", "hardcode this parameter")
0024 - **Providing templates** for consistent output formatting
0025 - **Reducing prompt repetition** (trigger with keywords like "testbed audit")
0026 
0027 ---
0028 
0029 ## Directory Structure
0030 
0031 ### Qwen Code
0032 
0033 ```
0034 ~/.qwen/skills/
0035 ├── your-skill-name/
0036 │   └── SKILL.md          # Skill definition (required)
0037 └── another-skill/
0038     └── SKILL.md
0039 ```
0040 
0041 ### Claude Code
0042 
0043 ```
0044 .your-project/.claude/skills/
0045 ├── your-skill-name/
0046 │   └── SKILL.md          # Skill definition (required)
0047 └── another-skill/
0048     └── SKILL.md
0049 ```
0050 
0051 > **Note**: Qwen Code uses a global skills directory (`~/.qwen/skills/`), while Claude Code uses project-local skills (`.claude/skills/`).
0052 
0053 ---
0054 
0055 ## Creating a Skill
0056 
0057 ### Step 1: Create the Directory
0058 
0059 ```bash
0060 # For Qwen Code (global)
0061 mkdir -p ~/.qwen/skills/testbed-audit
0062 
0063 # For Claude Code (project-local)
0064 mkdir -p .claude/skills/testbed-audit
0065 ```
0066 
0067 ### Step 2: Create SKILL.md
0068 
0069 Create a file named `SKILL.md` inside your skill directory. This file contains:
0070 
0071 1. **Frontmatter** (YAML metadata between `---` delimiters)
0072 2. **Instruction Body** (Markdown instructions for the AI)
0073 
0074 ### Step 3: Define Frontmatter
0075 
0076 ```yaml
0077 ---
0078 name: testbed-audit
0079 description: >
0080   MANDATORY: Use this skill for a detailed diagnostic audit of the 'test-zy'
0081   environment. Trigger this when the user asks for a "testbed audit",
0082   "agent report", "testbed health summary", or "is my testbed okay?".
0083 
0084   This skill provides structured heartbeat analysis for zyang2 that
0085   the default swf_get_testbed_status tool does not provide.
0086 ---
0087 ```
0088 
0089 **Frontmatter Fields:**
0090 
0091 | Field | Required | Description |
0092 |-------|----------|-------------|
0093 | `name` | ✅ | Unique skill identifier (use hyphens, lowercase) |
0094 | `description` | ✅ | When to use this skill; trigger keywords |
0095 
0096 ### Step 4: Write Instructions
0097 
0098 The instruction body should include:
0099 
0100 - **Role**: What role the AI should adopt
0101 - **Rules**: Strict constraints the AI must follow
0102 - **Steps**: Sequential actions to perform
0103 - **Template**: Output format to use
0104 - **Error Handling**: What to do on failure
0105 
0106 ---
0107 
0108 ## Example: testbed-audit
0109 
0110 Here's the complete `testbed-audit` skill as a reference:
0111 
0112 ```markdown
0113 ---
0114 name: testbed-audit
0115 description: >
0116   MANDATORY: Use this skill for a detailed diagnostic audit of the 'test-zy'
0117   environment. Trigger this when the user asks for a "testbed audit",
0118   "agent report", "testbed health summary", or "is my testbed okay?".
0119 
0120   This skill provides structured heartbeat analysis for zyang2 that
0121   the default swf_get_testbed_status tool does not provide.
0122 ---
0123 
0124 # zyang2 Testbed Health Audit
0125 
0126 ## Role
0127 You are a Diagnostic Auditor. Your goal is to fetch raw agent data,
0128 analyze it for 'zyang2' in the 'test-zy' namespace, and present a
0129 finalized health report.
0130 
0131 ## Strict Rules
0132 1. **Primary Tool**: Use `swf_list_agents` ONLY.
0133 2. **Namespace**: Hardcode `namespace: "test-zy"`.
0134 3. **Exclusion**: Do NOT call `swf_get_testbed_status`.
0135 4. **Iteration**: Exactly ONE tool call total.
0136 5. **Finality**: Stop immediately after printing the report.
0137 
0138 ## Steps
0139 1. **Data Acquisition**: Call `swf_list_agents` with parameters:
0140    - `status`: "OK"
0141    - `namespace`: "test-zy"
0142 2. **Analysis**: Check the `last_heartbeat` for every agent found.
0143 3. **Reporting**: Render the findings using the Audit Template below.
0144 
0145 ## Audit Template
0146 **Namespace**: test-zy | **User**: zyang2
0147 
0148 **Agent Status Matrix**:
0149 1. [agent-name] — [__state__] ([role])
0150 2. ...
0151 
0152 **Heartbeat Analysis**: [fresh / stale]
0153 
0154 > **Auditor Note**: [Only add "Action Required" if an agent is NOT in 'READY' state]
0155 
0156 ## Error Handling
0157 - If `swf_list_agents` fails: Print `⚠ Audit Failed: [error]` and stop.
0158 
0159 [DONE — no further tool calls]
0160 ```
0161 
0162 ### How to Use
0163 
0164 Once installed, trigger the skill by saying:
0165 
0166 - "Run a testbed audit"
0167 - "Check testbed health"
0168 - "Is my testbed okay?"
0169 - "Show me agent status"
0170 
0171 The AI will automatically use the skill and produce a standardized report.
0172 
0173 ### Example Output
0174 
0175 Here's a real example of what the `testbed-audit` skill produces:
0176 
0177 ```
0178 # Testbed Health Audit
0179 
0180 **Namespace**: test-zy | **User**: zyang2
0181 
0182 ## Agent Status Matrix
0183 
0184 ### Active Agents (OK status, READY state):
0185 1. **data-agent-zyang2-1202** — READY (DATA) — Heartbeat: 2026-03-20 18:47:57 UTC
0186 2. **agent-manager-zyang2** — READY (agent_manager) — Heartbeat: 2026-03-20 18:47:38 UTC
0187 3. **processing-agent-zyang2-1201** — READY (PROCESSING) — Heartbeat: 2026-03-20 18:47:04 UTC
0188 4. **daq_simulator-agent-zyang2-1199** — READY (DAQ_Simulator) — Heartbeat: 2026-03-20 18:47:04 UTC
0189 
0190 ### Inactive Agents (EXITED or WARNING):
0191 - **382 additional agents** in EXITED status (dating from Feb 22 to Mar 17, 2026)
0192 - **6 agents** with WARNING status (all EXITED operational state)
0193 
0194 ## Heartbeat Analysis
0195 
0196 **Active Agents**: ✅ **FRESH** — All 4 active agents have heartbeats within the last ~45 seconds (as of 18:47:57 UTC)
0197 
0198 **Inactive Agents**: ⚠️ **STALE** — Heartbeats range from 3 days to 26 days old
0199 
0200 ## Summary
0201 
0202 |   Status  | Count |
0203 |-----------|-------|
0204 |  OK/READY |  4    |
0205 |  EXITED   |  376+ |
0206 |  WARNING  |  6+   |
0207 
0208 **System Health**: ✅ **HEALTHY** — Core workflow agents (DAQ Simulator, Data Agent, Processing Agent, and Agent Manager) are all running and responsive.
0209 
0210 ---
0211 
0212 *Note: The large number of EXITED agents is normal — these are historical agent instances from previous testbed runs. They don't impact current operations.*
0213 ```
0214 
0215 This shows how the skill's template produces consistent, well-formatted output every time.
0216 
0217 ---
0218 
0219 ## Best Practices
0220 
0221 ### 1. Clear Trigger Keywords
0222 
0223 In the `description`, list all the phrases that should trigger this skill:
0224 
0225 ```yaml
0226 description: >
0227   Use this when the user asks for "X", "Y", or "Z".
0228 ```
0229 
0230 ### 2. Explicit Constraints
0231 
0232 Use numbered rules with bold labels:
0233 
0234 ```markdown
0235 ## Strict Rules
0236 1. **Primary Tool**: Use `tool_name` ONLY.
0237 2. **Parameter**: Hardcode `param: "value"`.
0238 3. **Exclusion**: Do NOT call `other_tool`.
0239 ```
0240 
0241 ### 3. Structured Output Templates
0242 
0243 Provide a template for consistent output:
0244 
0245 ```markdown
0246 ## Output Template
0247 **Field 1**: [value]
0248 **Field 2**: [value]
0249 
0250 **Summary**: [analysis]
0251 ```
0252 
0253 ### 4. Error Handling
0254 
0255 Tell the AI what to do on failure:
0256 
0257 ```markdown
0258 ## Error Handling
0259 - If `tool_call` fails: Print `⚠ Error: [message]` and stop.
0260 ```
0261 
0262 ### 5. Termination Marker
0263 
0264 Indicate when the skill is complete:
0265 
0266 ```markdown
0267 [DONE — no further tool calls]
0268 ```
0269 
0270 This prevents the AI from continuing unnecessarily.
0271 
0272 ---
0273 
0274 ## Skill Templates
0275 
0276 ### Template 1: Diagnostic Skill
0277 
0278 ```markdown
0279 ---
0280 name: diagnostic-name
0281 description: >
0282   Use this when the user asks for [trigger phrases].
0283   This skill provides [unique value] that default tools don't offer.
0284 ---
0285 
0286 # [Diagnostic Name]
0287 
0288 ## Role
0289 You are a [Role Name]. Your goal is to [objective].
0290 
0291 ## Strict Rules
0292 1. **Primary Tool**: Use `tool_name` ONLY.
0293 2. **Parameters**: Hardcode `param: "value"`.
0294 3. **Exclusion**: Do NOT call `other_tool`.
0295 4. **Iteration**: Exactly N tool call(s) total.
0296 5. **Finality**: Stop immediately after [action].
0297 
0298 ## Steps
0299 1. **Step Name**: Call `tool` with parameters:
0300    - `param1`: "value1"
0301    - `param2`: "value2"
0302 2. **Analysis**: [What to analyze]
0303 3. **Reporting**: Render findings using the template below.
0304 
0305 ## Output Template
0306 **Header**: [format]
0307 
0308 **Details**:
0309 1. [item format]
0310 2. ...
0311 
0312 **Summary**: [analysis guidance]
0313 
0314 ## Error Handling
0315 - If `tool` fails: Print `⚠ Error: [message]` and stop.
0316 
0317 [DONE — no further tool calls]
0318 ```
0319 
0320 ### Template 2: Tool Invocation Skill
0321 
0322 ```markdown
0323 # /tool-name
0324 
0325 Brief description of what this skill does.
0326 
0327 ## MCP Call
0328 
0329 ```
0330 {{MCP|provider|tool_function|param1=value1}}
0331 ```
0332 
0333 ## Parameters
0334 
0335 - `param1`: description (fixed/default value)
0336 ```
0337 
0338 ---
0339 
0340 ## Troubleshooting
0341 
0342 ### Skill Not Triggering
0343 
0344 **Problem**: The AI doesn't use your skill when expected.
0345 
0346 **Solutions**:
0347 1. Check that trigger keywords are in the `description` field
0348 2. Ensure the skill name is descriptive and unique
0349 3. Restart the AI session to reload skills
0350 
0351 ### Skill Produces Wrong Output
0352 
0353 **Problem**: The AI doesn't follow the template.
0354 
0355 **Solutions**:
0356 1. Make the template more explicit with placeholders like `[value]`
0357 2. Add "Strict Rules" section with numbered constraints
0358 3. Include an example output in the skill
0359 
0360 ### Tool Call Fails
0361 
0362 **Problem**: The MCP tool call fails.
0363 
0364 **Solutions**:
0365 1. Verify the tool name is correct (check `swf_list_available_tools`)
0366 2. Ensure all required parameters are provided
0367 3. Add error handling instructions to the skill
0368 
0369 ---
0370 
0371 ## Additional Resources
0372 
0373 - **Qwen Code Skills**: `~/.qwen/skills/` directory
0374 - **Claude Code Skills**: `.claude/skills/` in your project
0375 - **Available MCP Tools**: Use `swf_list_available_tools` to discover tools
0376 - **MCP Server**: https://pandaserver02.sdcc.bnl.gov/swf-monitor/mcp/
0377 
0378 ---
0379 
0380 ## Quick Reference
0381 
0382 | Component | Purpose |
0383 |-----------|---------|
0384 | `SKILL.md` | Skill definition file (required) |
0385 | Frontmatter (`---`) | Metadata: name, description |
0386 | Role Section | Defines AI's persona/objective |
0387 | Strict Rules | Hard constraints the AI must follow |
0388 | Steps | Sequential actions to perform |
0389 | Template | Output format for consistency |
0390 | Error Handling | Failure recovery instructions |
0391 | `[DONE]` | Termination marker |
0392 
0393 ---