mcpField
S
skill

skill

github.com/yeachan-heoAgent 工作流40.4k850 次安装1 天前更新
代码仓库

关于 skill

skill 是 oh-my-claudecode 的元技能,通过类命令行指令管理本地技能。它支持发现、创建、编辑、移除、搜索、导入,以及在用户和项目范围间同步。

主要功能

  1. 01列出并查看技能详情
  2. 02创建、编辑和移除技能
  3. 03按名称与内容搜索
  4. 04同步用户和项目技能
  5. 05设置并导入本地技能

适用场景

  1. 01盘点不同范围的技能
  2. 02创建项目专属技能
  3. 03按触发词或内容查找技能
  4. 04比较或复制不同范围的技能

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/yeachan-heo/oh-my-claudecode --skill skill

安装后在 Claude Code 中输入/skill确认已加载。

详细介绍

Skill 管理命令行

通过类命令行命令管理 oh-my-claudecode skill 的元 skill。

子命令

/skill list

按作用域显示所有可用的 skill。

行为:

  1. 扫描插件 skills/ 目录中内置的捆绑 skill(只读)
  2. 扫描用户 skill,位于 ${CLAUDE_CONFIG_DIR:-~/.claude}/skills/omc-learned/
  3. 扫描项目 skill,位于 .omc/skills/
  4. 解析 YAML frontmatter 以获取元数据
  5. 以整齐的表格格式显示:
BUILT-IN SKILLS (bundled with oh-my-claudecode):
| Name              | Description                    | Scope    |
|-------------------|--------------------------------|----------|
| visual-verdict    | Structured visual QA verdicts  | built-in |
| ralph             | Persistence loop               | built-in |

USER SKILLS (~/.claude/skills/omc-learned/):
| Name              | Triggers           | Quality | Usage | Scope |
|-------------------|--------------------|---------|-------|-------|
| error-handler     | fix, error         | 95%     | 42    | user  |
| api-builder       | api, endpoint      | 88%     | 23    | user  |

PROJECT SKILLS (.omc/skills/):
| Name              | Triggers           | Quality | Usage | Scope   |
|-------------------|--------------------|---------|-------|---------|
| test-runner       | test, run          | 92%     | 15    | project |

回退: 如果质量/使用统计不可用,显示 "N/A"

内置 skill 说明: 内置 skill 与 oh-my-claudecode 捆绑在一起,可被发现/读取,但无法通过 /skill remove 或 /skill edit 移除或编辑。


/skill add [name]

用于创建新 skill 的交互式向导。

行为:

  1. 询问 skill 名称(如果命令中未提供)
    • 校验:仅小写字母、连字符,不允许空格
  2. 询问描述
    • 清晰、简洁的一句话说明
  3. 询问触发词(逗号分隔的关键词)
    • 示例:"error, fix, debug"
  4. 询问参数提示(可选)
    • 示例:" [options]"
  5. 询问作用域:
    • user → ${CLAUDE_CONFIG_DIR:-~/.claude}/skills/omc-learned/<name>/SKILL.md
    • project → .omc/skills/<name>/SKILL.md
  6. 使用模板创建 skill 文件:
---
name: <name>
description: <description>
triggers:
  - <trigger1>
  - <trigger2>
argument-hint: "<args>"
---

# <Name> Skill

## Purpose

[Describe what this skill does]

## When to Activate

[Describe triggers and conditions]

## Workflow

1. [Step 1]
2. [Step 2]
3. [Step 3]

## Examples

/oh-my-claudecode: example-arg


## Notes

[Additional context, edge cases, gotchas]
  1. 报告成功并附上文件路径
  2. 建议: "编辑 /skill edit <name> 以自定义内容"

示例:

User: /skill add custom-logger
Assistant: Creating new skill 'custom-logger'...

Description: Enhanced logging with structured output
Triggers (comma-separated): log, logger, logging
Argument hint (optional): <level> [message]
Scope (user/project): user

✓ Created skill at ~/.claude/skills/omc-learned/custom-logger/SKILL.md
→ Edit with: /skill edit custom-logger

/skill remove

按名称移除 skill。

行为:

  1. 在两个作用域中搜索 skill:
    • ${CLAUDE_CONFIG_DIR:-~/.claude}/skills/omc-learned/<name>/SKILL.md
    • .omc/skills/<name>/SKILL.md
  2. 如果找到:
    • 显示 skill 信息(名称、描述、作用域)
    • 请求确认: "从 删除 '' skill?(yes/no)"
  3. 如果确认:
    • 删除整个 skill 目录(例如 ${CLAUDE_CONFIG_DIR:-~/.claude}/skills/omc-learned/<name>/)
    • 报告:"✓ 已从 移除 skill ''"
  4. 如果未找到:
    • 报告:"✗ 在用户或项目作用域中未找到 skill ''"

安全提示: 绝不在未经用户明确确认的情况下删除。

示例:

User: /skill remove old-logger
Assistant: Found skill 'old-logger' in user scope:
  Description: Legacy logging utility
  Scope: user (~/.claude/skills/omc-learned/)

Delete 'old-logger' skill? (yes/no)

User: yes
Assistant: ✓ Removed skill 'old-logger' from user scope

/skill edit

以交互方式编辑现有 skill。

行为:

  1. 按名称查找 skill(搜索两个作用域)
  2. 通过 Read 工具读取当前内容
  3. 显示当前值:
    Current skill 'custom-logger':
    - Description: Enhanced logging with structured output
    - Triggers: log, logger, logging
    - Argument hint: <level> [message]
    - Scope: user
    
  4. 询问要更改什么:
    • description - 更新描述
    • triggers - 更新触发关键词
    • argument-hint - 更新参数提示
    • content - 编辑完整 markdown 内容
    • rename - 重命名 skill(移动文件)
    • cancel - 退出且不做更改
  5. 对于所选字段:
    • 显示当前值
    • 询问新值
    • 更新 YAML frontmatter 或内容
    • 写回文件
  6. 报告成功并附上更改摘要

示例:

User: /skill edit custom-logger
Assistant: Current skill 'custom-logger':
  - Description: Enhanced logging with structured output
  - Triggers: log, logger, logging
  - Argument hint: <level> [message]

What would you like to edit? (description/triggers/argument-hint/content/rename/cancel)

User: triggers
Assistant: Current triggers: log, logger, logging
New triggers (comma-separated): log, logger, logging, trace

✓ Updated triggers for 'custom-logger'

/skill search

按内容、触发词、名称或描述搜索 skill。

行为:

  1. 扫描两个作用域中的所有 skill
  2. 匹配查询(不区分大小写)针对:
    • Skill 名称
    • 描述
    • 触发词
    • 完整 markdown 内容
  3. 显示匹配结果并附上上下文:
Found 3 skills matching "typescript error":

1. typescript-fixer (user)
   Description: Fix common TypeScript errors
   Match: "typescript error handling patterns"

2. error-handler (user)
   Description: Generic error handling utilities
   Match: "Supports TypeScript and JavaScript errors"

3. lint-fix (project)
   Description: Auto-fix linting errors
   Match: "TypeScript ESLint error resolution"

排序: 优先匹配名称/触发词,其次匹配内容

示例:

User: /skill search api endpoint
Assistant: Found 2 skills matching "api endpoint":

1. api-builder (user)
   Description: Generate REST API endpoints
   Triggers: api, endpoint, rest

2. backend-scaffold (project)
   Description: Scaffold backend services
   Match: "Creates API endpoint boilerplate"

/skill info

显示某个 skill 的详细信息。

行为:

  1. 按名称查找 skill(搜索两个作用域)
  2. 解析 YAML frontmatter 和内容
  3. 显示完整详情:
Skill: custom-logger
Scope: user (~/.claude/skills/omc-learned/custom-logger/)
Description: Enhanced logging with structured output
Triggers: log, logger, logging
Argument Hint: <level> [message]
Quality: 95% (if available)
Usage Count: 42 times (if available)
File Path: /home/user/.claude/skills/omc-learned/custom-logger/SKILL.md

--- FULL CONTENT ---
[entire markdown content]

如果未找到: 报告错误并建议使用 /skill search

示例:

User: /skill info custom-logger
Assistant: Skill: custom-logger
Scope: user
Description: Enhanced logging with structured output
Triggers: log, logger, logging
File: ~/.claude/skills/omc-learned/custom-logger/SKILL.md

--- CONTENT ---
# Custom Logger Skill

## Purpose
Enhanced logging with structured JSON output...
[rest of content]

/skill sync

在用户范围与项目范围之间同步技能。

行为:

  1. 扫描两个范围:
    • 用户技能:${CLAUDE_CONFIG_DIR:-~/.claude}/skills/omc-learned/
    • 项目技能:.omc/skills/
  2. 比较并分类:
    • 仅用户侧技能(不在项目中)
    • 仅项目侧技能(不在用户侧)
    • 共同技能(两侧都有)
  3. 显示同步机会:
SYNC REPORT:

User-only skills (5):
  - error-handler
  - api-builder
  - custom-logger
  - test-generator
  - deploy-helper

Project-only skills (2):
  - test-runner
  - backend-scaffold

Common skills (3):
  - frontend-ui-ux
  - git-master
  - planner

Options:
  [1] Copy user skill to project
  [2] Copy project skill to user
  [3] View differences
  [4] Cancel
  1. 处理用户选择:
    • 选项 1:选择要复制到项目的技能
    • 选项 2:选择要复制到用户侧的技能
    • 选项 3:显示共同技能的并排差异
    • 选项 4:退出

安全: 未经确认绝不覆盖

示例:

User: /skill sync
Assistant: Found 5 user-only skills and 2 project-only skills.

Copy 'error-handler' from user to project? (yes/no/skip)
User: yes
Assistant: ✓ Copied 'error-handler' to .omc/skills/

Copy 'api-builder' from user to project? (yes/no/skip)
User: skip
...

/skill setup

用于设置和管理本地技能(原为 local-skills-setup)的交互式向导。

行为:

第 1 步:目录检查与设置

首先,检查技能目录是否存在,如不存在则创建:

# Check and create user-level skills directory
USER_SKILLS_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/skills/omc-learned"
if [ -d "$USER_SKILLS_DIR" ]; then
  echo "User skills directory exists: $USER_SKILLS_DIR"
else
  mkdir -p "$USER_SKILLS_DIR"
  echo "Created user skills directory: $USER_SKILLS_DIR"
fi

# Check and create project-level skills directory
PROJECT_SKILLS_DIR=".omc/skills"
if [ -d "$PROJECT_SKILLS_DIR" ]; then
  echo "Project skills directory exists: $PROJECT_SKILLS_DIR"
else
  mkdir -p "$PROJECT_SKILLS_DIR"
  echo "Created project skills directory: $PROJECT_SKILLS_DIR"
fi
第 2 步:技能扫描与清单

扫描两个目录并显示完整的清单:

# Scan user-level skills
echo "=== USER-LEVEL SKILLS (~/.claude/skills/omc-learned/) ==="
if [ -d "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/skills/omc-learned" ]; then
  USER_COUNT=$(find "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/skills/omc-learned" -name "*.md" 2>/dev/null | wc -l)
  echo "Total skills: $USER_COUNT"

  if [ $USER_COUNT -gt 0 ]; then
    echo ""
    echo "Skills found:"
    find "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/skills/omc-learned" -name "*.md" -type f -exec sh -c '
      FILE="$1"
      NAME=$(grep -m1 "^name:" "$FILE" 2>/dev/null | sed "s/name: //")
      DESC=$(grep -m1 "^description:" "$FILE" 2>/dev/null | sed "s/description: //")
      MODIFIED=$(stat -c "%y" "$FILE" 2>/dev/null || stat -f "%Sm" "$FILE" 2>/dev/null)
      echo "  - $NAME"
      [ -n "$DESC" ] && echo "    Description: $DESC"
      echo "    Modified: $MODIFIED"
      echo ""
    ' sh {} \;
  fi
else
  echo "Directory not found"
fi

echo ""
echo "=== PROJECT-LEVEL SKILLS (.omc/skills/) ==="
if [ -d ".omc/skills" ]; then
  PROJECT_COUNT=$(find ".omc/skills" -name "*.md" 2>/dev/null | wc -l)
  echo "Total skills: $PROJECT_COUNT"

  if [ $PROJECT_COUNT -gt 0 ]; then
    echo ""
    echo "Skills found:"
    find ".omc/skills" -name "*.md" -type f -exec sh -c '
      FILE="$1"
      NAME=$(grep -m1 "^name:" "$FILE" 2>/dev/null | sed "s/name: //")
      DESC=$(grep -m1 "^description:" "$FILE" 2>/dev/null | sed "s/description: //")
      MODIFIED=$(stat -c "%y" "$FILE" 2>/dev/null || stat -f "%Sm" "$FILE" 2>/dev/null)
      echo "  - $NAME"
      [ -n "$DESC" ] && echo "    Description: $DESC"
      echo "    Modified: $MODIFIED"
      echo ""
    ' sh {} \;
  fi
else
  echo "Directory not found"
fi

# Summary
TOTAL=$((USER_COUNT + PROJECT_COUNT))
echo "=== SUMMARY ==="
echo "Total skills across all directories: $TOTAL"
第 3 步:快捷操作菜单

扫描后,使用 AskUserQuestion 工具提供以下选项:

问题:“你想对本地技能做什么?”

选项:

  1. 添加新技能 - 启动技能创建向导(调用 /skill add)
  2. 列出所有技能及详情 - 显示完整的技能清单(调用 /skill list)
  3. 扫描对话以查找模式 - 分析当前对话,寻找值得做成技能的模式
  4. 导入技能 - 从 URL 导入技能或粘贴内容
  5. 完成 - 退出向导

选项 3:扫描对话以查找模式

分析当前对话上下文,识别可能值得做成技能的模式。查找:

  • 近期带有非显而易见解决方案的调试过程
  • 需要调查的棘手 bug
  • 发现的代码库特定变通方法
  • 耗费时间才解决的错误模式

报告发现结果,并询问用户是否想将其中任何内容提取为技能(调用 /skillify;/learner 为已废弃的兼容项)。

选项 4:导入技能

要求用户提供以下任一内容:

  • URL:从 URL 下载技能(例如 GitHub gist)
  • 粘贴内容:直接粘贴技能 markdown 内容

然后询问范围:

  • 用户级(~/.claude/skills/omc-learned/)- 在所有项目中可用
  • 项目级(.omc/skills/)- 仅适用于此项目

验证技能格式并保存到所选位置。


/skill scan

用于扫描两个技能目录的快捷命令(/skill setup 的子集)。

行为: 运行 /skill setup 第 2 步中的扫描,但不包含交互式向导。


技能模板

通过 /skill add 或 /skill setup 创建技能时,提供常见技能类型的快捷模板:

错误解决方案模板
---
id: error-[unique-id]
name: [Error Name]
description: Solution for [specific error in specific context]
source: conversation
triggers: ["error message fragment", "file path", "symptom"]
quality: high
---

# [Error Name]

## The Insight
What is the underlying cause of this error? What principle did you discover?

## Why This Matters
What goes wrong if you don't know this? What symptom led here?

## Recognition Pattern
How do you know when this applies? What are the signs?
- Error message: "[exact error]"
- File: [specific file path]
- Context: [when does this occur]

## The Approach
Step-by-step solution:
1. [Specific action with file/line reference]
2. [Specific action with file/line reference]
3. [Verification step]

## Example
\`\`\`typescript
// Before (broken)
[problematic code]

// After (fixed)
[corrected code]
\`\`\`
工作流技能模板
---
id: workflow-[unique-id]
name: [Workflow Name]
description: Process for [specific task in this codebase]
source: conversation
triggers: ["task description", "file pattern", "goal keyword"]
quality: high
---

# [Workflow Name]

## The Insight
What makes this workflow different from the obvious approach?

## Why This Matters
What fails if you don't follow this process?

## Recognition Pattern
When should you use this workflow?
- Task type: [specific task]
- Files involved: [specific patterns]
- Indicators: [how to recognize]

## The Approach
1. [Step with specific commands/files]
2. [Step with specific commands/files]
3. [Verification]

## Gotchas
- [Common mistake and how to avoid it]
- [Edge case and how to handle it]
代码模式模板
---
id: pattern-[unique-id]
name: [Pattern Name]
description: Pattern for [specific use case in this codebase]
source: conversation
triggers: ["code pattern", "file type", "problem domain"]
quality: high
---

# [Pattern Name]

## The Insight
What's the key principle behind this pattern?

## Why This Matters
What problems does this pattern solve in THIS codebase?

## Recognition Pattern
When do you apply this pattern?
- File types: [specific files]
- Problem: [specific problem]
- Context: [codebase-specific context]

## The Approach
Decision-making heuristic, not just code:
1. [Principle-based step]
2. [Principle-based step]

## Example
\`\`\`typescript
[Illustrative example showing the principle]
\`\`\`

## Anti-Pattern
What NOT to do and why:
\`\`\`typescript
[Common mistake to avoid]
\`\`\`
集成技能模板
---
id: integration-[unique-id]
name: [Integration Name]
description: How [system A] integrates with [system B] in this codebase
source: conversation
triggers: ["system name", "integration point", "config file"]
quality: high
---

# [Integration Name]

## The Insight
What's non-obvious about how these systems connect?

## Why This Matters
What breaks if you don't understand this integration?

## Recognition Pattern
When are you working with this integration?
- Files: [specific integration files]
- Config: [specific config locations]
- Symptoms: [what indicates integration issues]

## The Approach
How to work with this integration correctly:
1. [Configuration step with file paths]
2. [Setup step with specific details]
3. [Verification step]

## Gotchas
- [Integration-specific pitfall #1]
- [Integration-specific pitfall #2]

错误处理

所有命令都必须处理:

  • 文件/目录不存在
  • 权限错误
  • 无效的 YAML frontmatter
  • 重复的技能名称
  • 无效的技能名称(空格、特殊字符)

错误格式:

✗ Error: <clear message>
→ Suggestion: <helpful next step>

用法示例

# List all skills
/skill list

# Create a new skill
/skill add my-custom-skill

# Remove a skill
/skill remove old-skill

# Edit existing skill
/skill edit error-handler

# Search for skills
/skill search typescript error

# Get detailed info
/skill info my-custom-skill

# Sync between scopes
/skill sync

# Run setup wizard
/skill setup

# Quick scan
/skill scan

用法模式

直接命令模式

带参数调用时,跳过交互式向导:

  • /oh-my-claudecode:skill list - 显示详细的技能清单
  • /oh-my-claudecode:skill add - 开始技能创建(调用 skillify)
  • /oh-my-claudecode:skill scan - 扫描两个技能目录
交互模式

不带参数调用时,运行完整的引导式向导。


本地技能的优势

自动应用:Claude 会检测触发条件并自动应用技能——无需记住或搜索解决方案。

版本控制:项目级技能(.omc/skills/)应当与你的代码一起提交,让整个团队受益。在关联的 worktree 中,未提交的技能仅保留在该 worktree 本地,如果该 worktree 被删除,这些技能也会消失。

不断演进的知识:随着你发现更好的方法并优化触发条件,技能会不断完善。

减少 Token 消耗:Claude 无需重复解决相同的问题,而是高效地应用已知模式。

代码库记忆:保留那些否则会丢失在对话历史中的团队知识。


技能质量指南

好的技能应具备:

  1. 无法通过搜索获得——无法轻易通过搜索找到

    • 差:“如何在 TypeScript 中读取文件”
    • 好:“此代码库使用自定义路径解析,需要 fileURLToPath”
  2. 特定于上下文——引用来自此代码库的实际文件/错误

    • 差:“使用 try/catch 进行错误处理”
    • 好:“server.py:42 中的 aiohttp 代理在遇到 ClientDisconnectedError 时崩溃”
  3. 可精确执行——明确指出做什么以及在哪里做

    • 差:“处理边界情况”
    • 好:“在 dist/ 中看到‘Cannot find module’时,检查 tsconfig.json 的 moduleResolution”
  4. 来之不易——需要大量调试工作才能获得

    • 差:通用编程模式
    • 好:“worker.ts 中的竞态条件——第 89 行的 Promise.all 需要 await”

相关技能

  • /oh-my-claudecode:skillify - 从当前对话中提取技能(/oh-my-claudecode:learner 是已弃用的别名)
  • /oh-my-claudecode:note - 保存快速笔记(不如技能正式)
  • /oh-my-claudecode:deepinit - 生成 AGENTS.md 代码库层级结构

示例会话

> /oh-my-claudecode:skill list

Checking skill directories...
✓ User skills directory exists: ~/.claude/skills/omc-learned/
✓ Project skills directory exists: .omc/skills/

Scanning for skills...

=== USER-LEVEL SKILLS ===
Total skills: 3
  - async-network-error-handling
    Description: Pattern for handling independent I/O failures in async network code
    Modified: 2026-01-20 14:32:15

  - esm-path-resolution
    Description: Custom path resolution in ESM requiring fileURLToPath
    Modified: 2026-01-19 09:15:42

=== PROJECT-LEVEL SKILLS ===
Total skills: 5
  - session-timeout-fix
    Description: Fix for sessionId undefined after restart in session.ts
    Modified: 2026-01-22 16:45:23

  - build-cache-invalidation
    Description: When to clear TypeScript build cache to fix phantom errors
    Modified: 2026-01-21 11:28:37

=== SUMMARY ===
Total skills: 8

What would you like to do?
1. Add new skill
2. List all skills with details
3. Scan conversation for patterns
4. Import skill
5. Done

用户提示

  • 定期运行 /oh-my-claudecode:skill list 来查看你的技能库
  • 解决棘手 bug 后,立即运行 skillify 将其捕获
  • 使用项目级技能存储特定于代码库的知识
  • 使用用户级技能存储适用于所有地方的通用模式
  • 随着时间推移审查并优化触发条件,以提高匹配准确性

实现说明

  1. YAML 解析: 使用 frontmatter 提取元数据
  2. 文件操作: 使用 Read/Write 工具,创建新文件时切勿使用 Edit
  3. 用户确认: 始终对破坏性操作进行确认
  4. 清晰反馈: 使用对勾(✓)、叉号(✗)、箭头(→)以提高清晰度
  5. 作用域解析: 始终同时检查用户和项目作用域
  6. 验证: 强制执行命名规范(仅限小写、连字符)

相关技能

  • /oh-my-claudecode:skillify - 从当前对话中提取技能(/oh-my-claudecode:learner 是已弃用的别名)
  • /oh-my-claudecode:note - 保存快速笔记(不如技能正式)
  • /oh-my-claudecode:deepinit - 生成 AGENTS.md 代码库层级结构

未来增强

  • /skill export <name> - 将技能导出为可分享的文件
  • /skill import <file> - 从文件导入技能
  • /skill stats - 显示所有技能的使用统计
  • /skill validate - 检查所有技能的格式错误
  • /skill template <type> - 从预定义模板创建

评论

支持 Markdown