Skip to content

Instantly share code, notes, and snippets.

@yangl
Created January 22, 2026 10:52
Show Gist options
  • Select an option

  • Save yangl/524a59257bdc52913aae187e561f0d07 to your computer and use it in GitHub Desktop.

Select an option

Save yangl/524a59257bdc52913aae187e561f0d07 to your computer and use it in GitHub Desktop.

Qoder CLI Skills 功能详解与实战

让 AI 从"通才"变"专家"的秘密武器


问题本质

我们使用AI工具,每次都需要通过prompt描述如何去执行任务,以求让AI理解我们的意图,更好的完成我们的任务。

但是对于一些重复性、特定领域的任务,我们每次执行任务时都需要对AI进行重复的调教。

┌─────────────────────────────────────────────────────────────┐
│                                                             │
│    AI 是一个"超级通才"                                       │
│                                                             │
│    它什么都会,但什么都不精                                   │
│                                                             │
│    它不记得你上次是怎么要求的                                 │
│                                                             │
│    它不知道你们团队的规范和偏好                               │
│                                                             │
└─────────────────────────────────────────────────────────────┘

我们需要的是

一种方式,让 AI 记住"怎么做某件事",下次只需说一句话,它就能按照我们定义的方式执行。

这就是 Skill。


Skill 是什么

1.1 官方定义

Skill = 可复用的专家知识包

它是一组打包好的指令、知识和工具,让 AI 在特定领域从"通才"变成"专家"

Skill可以教会Qoder如何以特定的SOP完成特定任务

1.2 让人眼前一亮的优势

1.3 一个 Skill 长什么样

# ~/.qoder/skills/api-mocker/SKILL.md

---
name: api-mocker
description: |
  根据 API 定义生成 Mock 测试数据。
  当用户说"生成mock数据"、"造测试数据"时使用。
---

# API Mock 数据生成器

## 规则
1. 分析用户提供的接口定义
2. 根据字段名推断数据语义(name→姓名,email→邮箱)
3. 生成 5 条真实感数据

## 字段映射
- name/姓名 → 中文姓名(王晓明、刘思远)
- email → user_xxx@example.com
- phone → 138-XXXX-XXXX
- avatar → https://api.dicebear.com/7.x/avataaars/svg?seed=随机

## 输出
JSON 数组,用代码块包裹

就这么简单:一个目录 + 一个 SKILL.md 文件。

1.4 Prompt vs. Skills

“Skill不就是一个保存Prompt的地方吗?”

没错,但是并没有体现Skill厉害之处。

Prompt告诉AI来做什么,而Skills则告诉AI如何判断以及整个流程如何进行。

Skills让我们能把自己的判断逻辑、处理流程写成一个Qoder可以反复执行的模块

1.5 Skill 的三层结构

┌─────────────────────────────────────────────────────────────┐
│  Layer 1: 元数据
│  ├── name: skill 的名字                                      │
│  └── description: 什么时候该用这个 skill(触发条件)             │
├─────────────────────────────────────────────────────────────┤
│  Layer 2: 核心指令(触发时才加载)                              │
│  └── SKILL.md 正文:具体怎么做                                │
├─────────────────────────────────────────────────────────────┤
│  Layer 3: 附加资源(按需加载)                                 │
│  ├── scripts/    → 可执行脚本(Python/Bash)                  │
│  ├── references/ → 参考文档(API 文档、规范说明)               │
│  └── assets/     → 资源文件(模板、图片)                      │
└─────────────────────────────────────────────────────────────┘

为什么要分层?

  • AI 的上下文窗口是有限的"公共资源"
  • 如果所有 Skill 的内容都一直在上下文里,会浪费大量 Token
  • 分层设计:只有 name 和 description 始终存在,正文和资源按需加载

这就是 渐进式加载(Progressive Disclosure) 设计。


怎么使用 Skill

2.1 Skill 的存储位置

全局 Skill(所有项目可用)
~/.qoder/skills/
├── pdf-processing/
│   └── SKILL.md
├── code-reviewer/
│   └── SKILL.md
└── ...

项目 Skill(仅当前项目可用)
your-project/
└── .qoder/
    └── skills/
        └── project-specific-skill/
            └── SKILL.md

2.2 查看已安装的 Skill

在 Qoder CLI 中输入:

/skills

你会看到类似这样的界面:

> /skills                                                                                                   
------------------------------------------------------------------------------------------------------------
Skill Commands:  [User]  Project                                                                            

Skill list:
→ code-reviewer      : [user] 审查代码并提供改进建议。当需要代码审查、查找潜...
- pdf-processing     : [user] -Extract text, fill forms, merge PDFs. Use when working with PDF files,...

Press Enter to select · Esc to exit · Tab to cycle tabs · ↑↓ to navigate

三个级别

  • User:存储在 ~/.qoder/skills/,所有项目可用
  • Project:存储在 项目/.qoder/skills/,仅当前项目可用

2.3 使用 Skill 的两种方式

方式一:自动触发

你只需正常描述你的需求,AI 会根据 Skill 的 description 自动判断是否使用,例如,pdf-processing技能。

帮我查看这个xxx.pdf的内容

这就是为什么 description 很重要 —— 它是 AI 判断"何时使用这个 Skill"的依据。

方式二:手动调用

如果你想强制使用某个 Skill,可以用命令:

/pdf-processing

或者在对话中明确指定:

使用 pdf-processing skill 帮我查看这个xxx.pdf的内容

Skill实战

3.1 微服务应用问题排查

场景

在 K8s 集群中部署了一套微服务应用,某天突然发现接口报错 500。需要快速定位是哪个服务出了问题。

传统方式:登录各个 Pod → 翻日志 → 分析调用链 → 定位问题

使用 Skill:进入 Pod → 跟 Qoder CLI 说一句"帮我排查问题" → 自动完成排查

核心思路

这个 Skill 的价值在于:把项目架构知识固化下来

  • 服务有哪些?调用关系是什么?
  • 出问题时该调用哪些接口验证?
  • 日志里哪些关键字代表什么含义?

这些"确定性知识"写进 Skill,让 AI 按照 SOP 自主排查。

Skill 内容

存储到/.qoder/skills/microservice-troubleshooter/SKILL.md

---
name: microservice-troubleshooter
description: |
  微服务问题排查专家。自动诊断 A、B、C 三个服务组成的微服务架构中的问题,生成排查报告和修复建议。
  触发场景:用户请求 "排查微服务问题"、"诊断错误"、"分析日志"、"查找异常"等直接触发这个SKILL进行排查
---

# 微服务问题排查

## 项目架构

本项目由 3 个 Spring Boot 微服务组成,通过 HTTP (RestTemplate) 进行链式调用:

用户请求 → A服务(/a) → B服务(/b) → C服务(/c) → 返回结果


### 服务说明

| 服务 | 端口    | 职责 | 下游依赖 |
|------|-------|------|----------|
| A | 20001 | 入口服务,接收用户请求 | 调用 B 服务 |
| B | 20002 | 中间层服务 | 调用 C 服务 |
| C | 20003 | 末端服务,返回最终结果 | 无 |

### 注册中心说明

/root/nacos/naming/目录是微服务注册中心的缓存,当前已用【直接】依赖的服务,订阅的微服务实例的地址会缓存到这个目录下,其中包含所有订阅服务的实例列表

因此可以在/root/nacos/naming/目录下查找阅读依赖服务的相关信息

### 调用链路

HTTP 链路: A(/a) --RestTemplate--> B(/b) --RestTemplate--> C(/c)


## 排查流程

### Step 1: 在当前 Pod 测试本地接口

通过 curl 调用本地接口,观察返回结果或错误信息:

**A 服务接口** (在 A Pod 中执行)
```bash
curl localhost:20001/a          # HTTP 全链路调用 A→B→C
curl localhost:20001/a-zone     # 同城多活链路
curl localhost:20001/actuator/health  # 健康检查

B 服务接口 (在 B Pod 中执行)

curl localhost:20002/b          # 调用 C 服务
curl localhost:20002/b-zone     # 同城多活
curl localhost:20002/actuator/health  # 健康检查

C 服务接口 (在 C Pod 中执行)

curl localhost:20003/c          # 返回 C 服务信息 (末端,不依赖其他服务)
curl localhost:20003/c-zone     # 同城多活
curl localhost:20003/actuator/health  # 健康检查

Step 2: 查看当前服务日志中的错误

# 搜索日志中的异常信息
grep -i "exception\|error\|失败" *.log | tail -50

Step 3: 分析调用链

  • 如果看到 [A] 调用服务B失败 → 问题在 B 或 C
  • 如果看到 [B] 调用服务C失败 → 问题在 C
  • 如果看到 C service error → C 服务内部错误

注意

如果上述方式都无法找到具体问题,可以在A入口应用Pod中通过

curl localhost:20001/dubbo      # Dubbo 全链路调用

通过Dubbo全链路调用排查调用链路问题




**Skill 扩展脚本**

```markdown
### 优先批量检查B服务实例

通过 `/b` 接口批量检测多个B服务实例的状态:

```bash
# 用法: ./check_b_instances.sh <ip1> <ip2> ...
.qoder/skills/microservice-troubleshooter/scripts/check_b_instances.sh 10.192.168.34 10.192.168.35

# 实例IP可从 /root/nacos/naming/ 目录获取

状态说明:

  • [存活-正常] - 服务正常响应
  • [存活-有错误] - 服务存活但返回5xx错误(业务异常)
  • [不可达] - 服务无法连接

> 存储到<project-path>/.qoder/skills/microservice-troubleshooter/scripts/check_b_instances.sh
>

```markdown
#!/bin/bash
#
# B服务多实例健康检查脚本
# 通过 /b 接口判断服务状态
# 用法: ./check_b_instances.sh <ip1> <ip2> <ip3> ...
# 示例: ./check_b_instances.sh 10.192.168.34 10.192.168.35 10.192.168.36
#

PORT=20002
TIMEOUT=3

# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

if [ $# -eq 0 ]; then
    echo "用法: $0 <ip1> <ip2> <ip3> ..."
    echo "示例: $0 10.192.168.34 10.192.168.35"
    exit 1
fi

echo "========================================"
echo "  B服务多实例健康检查 (/b接口)"
echo "========================================"
echo ""

total=0
alive=0
dead=0
has_error=0

for ip in "$@"; do
    total=$((total + 1))
    echo -n "检查 B实例 [$ip:$PORT] ... "
    
    # 通过 /b 接口检查
    response=$(curl -s -w "\n%{http_code}" --connect-timeout $TIMEOUT "http://$ip:$PORT/b" 2>/dev/null)
    curl_status=$?
    
    if [ $curl_status -ne 0 ]; then
        # curl失败,服务不可达
        echo -e "${RED}[不可达]${NC}"
        echo "  └─ 原因: 连接超时或拒绝"
        dead=$((dead + 1))
    else
        # 解析响应体和状态码
        http_code=$(echo "$response" | tail -1)
        body=$(echo "$response" | sed '$d')
        
        if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then
            # 2xx 正常
            echo -e "${GREEN}[存活-正常]${NC}"
            alive=$((alive + 1))
        elif [ "$http_code" -ge 500 ]; then
            # 5xx 服务存活但有错误
            echo -e "${YELLOW}[存活-有错误]${NC}"
            echo "  └─ HTTP $http_code: $body"
            alive=$((alive + 1))
            has_error=$((has_error + 1))
        else
            # 其他状态码
            echo -e "${YELLOW}[存活-HTTP $http_code]${NC}"
            alive=$((alive + 1))
        fi
    fi
    echo ""
done

echo "========================================"
echo "  检查结果汇总"
echo "========================================"
echo "总实例数:   $total"
echo -e "存活实例:   ${GREEN}$alive${NC}"
echo -e "不可达:     ${RED}$dead${NC}"
echo -e "业务错误:   ${YELLOW}$has_error${NC}"
echo ""

if [ $dead -gt 0 ]; then
    echo -e "${RED}警告: 存在 $dead 个不可达的实例${NC}"
    exit 2
elif [ $has_error -gt 0 ]; then
    echo -e "${YELLOW}警告: 存在 $has_error 个有业务错误的实例${NC}"
    exit 1
else
    echo -e "${GREEN}所有实例正常${NC}"
    exit 0
fi


3.2 常用Skill分享

Web应用页面优化

场景

1、使用AI帮助生成一个SaaS的落地页面

做一个 SaaS 产品落地页,暗色科技风。需要元素丰富(导航、卡片、按钮)

2、使用Anthropic提供的frontend-design skill来优化页面

使用frontend-design skill优化这个页面

Skill 内容

存储到/.qoder/skills/microservice-troubleshooter/SKILL.md

---
name: frontend-design
description: Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
license: Complete terms in LICENSE.txt
---

This skill guides creation of distinctive, production-grade frontend interfaces that avoid generic "AI slop" aesthetics. Implement real working code with exceptional attention to aesthetic details and creative choices.

The user provides frontend requirements: a component, page, application, or interface to build. They may include context about the purpose, audience, or technical constraints.

## Design Thinking

Before coding, understand the context and commit to a BOLD aesthetic direction:
- **Purpose**: What problem does this interface solve? Who uses it?
- **Tone**: Pick an extreme: brutally minimal, maximalist chaos, retro-futuristic, organic/natural, luxury/refined, playful/toy-like, editorial/magazine, brutalist/raw, art deco/geometric, soft/pastel, industrial/utilitarian, etc. There are so many flavors to choose from. Use these for inspiration but design one that is true to the aesthetic direction.
- **Constraints**: Technical requirements (framework, performance, accessibility).
- **Differentiation**: What makes this UNFORGETTABLE? What's the one thing someone will remember?

**CRITICAL**: Choose a clear conceptual direction and execute it with precision. Bold maximalism and refined minimalism both work - the key is intentionality, not intensity.

Then implement working code (HTML/CSS/JS, React, Vue, etc.) that is:
- Production-grade and functional
- Visually striking and memorable
- Cohesive with a clear aesthetic point-of-view
- Meticulously refined in every detail

## Frontend Aesthetics Guidelines

Focus on:
- **Typography**: Choose fonts that are beautiful, unique, and interesting. Avoid generic fonts like Arial and Inter; opt instead for distinctive choices that elevate the frontend's aesthetics; unexpected, characterful font choices. Pair a distinctive display font with a refined body font.
- **Color & Theme**: Commit to a cohesive aesthetic. Use CSS variables for consistency. Dominant colors with sharp accents outperform timid, evenly-distributed palettes.
- **Motion**: Use animations for effects and micro-interactions. Prioritize CSS-only solutions for HTML. Use Motion library for React when available. Focus on high-impact moments: one well-orchestrated page load with staggered reveals (animation-delay) creates more delight than scattered micro-interactions. Use scroll-triggering and hover states that surprise.
- **Spatial Composition**: Unexpected layouts. Asymmetry. Overlap. Diagonal flow. Grid-breaking elements. Generous negative space OR controlled density.
- **Backgrounds & Visual Details**: Create atmosphere and depth rather than defaulting to solid colors. Add contextual effects and textures that match the overall aesthetic. Apply creative forms like gradient meshes, noise textures, geometric patterns, layered transparencies, dramatic shadows, decorative borders, custom cursors, and grain overlays.

NEVER use generic AI-generated aesthetics like overused font families (Inter, Roboto, Arial, system fonts), cliched color schemes (particularly purple gradients on white backgrounds), predictable layouts and component patterns, and cookie-cutter design that lacks context-specific character.

Interpret creatively and make unexpected choices that feel genuinely designed for the context. No design should be the same. Vary between light and dark themes, different fonts, different aesthetics. NEVER converge on common choices (Space Grotesk, for example) across generations.

**IMPORTANT**: Match implementation complexity to the aesthetic vision. Maximalist designs need elaborate code with extensive animations and effects. Minimalist or refined designs need restraint, precision, and careful attention to spacing, typography, and subtle details. Elegance comes from executing the vision well.

Remember: Claude is capable of extraordinary creative work. Don't hold back, show what can truly be created when thinking outside the box and committing fully to a distinctive vision.

用 Skill 创建 Skill

Anthropic 官方提供了一个 skill-creator Skill,用于帮助你创建新的 Skill。

4.1 skill-creator 的核心原则

官方 skill-creator 遵循这些原则:

1. 简洁至上

"AI 已经很聪明,只补充它不知道的。"

每一段内容都要问:这个信息 AI 真的不知道吗?值得占用 Token 吗?

2. 明确触发条件

description 是最重要的部分,决定了 Skill 何时被使用。

3. 渐进式加载

Layer 1: name + description     → 始终存在(~100词)
Layer 2: SKILL.md 正文          → 触发时加载(<5000词)
Layer 3: scripts/references/    → 按需加载(无限制)

4.2 skill-creator 用法演示

  • 将skill-creator这个skill包copy到工程目录对应的skills存放目录
  • 让AI帮我们研究、梳理下目标Skill的能力,将研究到的内容落到文档中
帮我调研和梳理一套现在通用、完整且详细的微服务问题排查流程,将这个调研内容落到markdown文件中
  • 使用skill-creator这个skill,让它根据我们刚调研到的内容生成一个Skill
skill-creator 根据调研文档帮我生成对应的微服务排查SKILL

Skill 推荐

Anthropic 官方提供了多个高质量 Skill:

Skill 功能 适用场景
pdf PDF 文本提取、合并、拆分、表单填写 处理 PDF 文档
xlsx Excel 创建、编辑、公式、数据分析 处理电子表格
docx Word 文档创建、编辑、格式保持 处理 Word 文档
pptx PPT 创建、编辑、布局 处理演示文稿
mcp-builder MCP 服务器开发指南 开发 MCP 集成
frontend-design 前端视觉设计优化 提升 UI 质量
skill-creator 创建新 Skill 的向导 开发新 Skill

获取方式https://github.com/anthropics/skills


资源


"Skills 的核心简洁性是我如此兴奋的原因...这可能引发比 MCP 更大的寒武纪大爆发。"

— Simon Willison

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment