Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问许可证需确认审计异常

refactor-skill-structure重构技能结构

Agent Skill

refactor-skill-structure 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

449

周安装

18

GitHub Stars

12

下载量

145
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:refactor-skill-structure(重构技能结构)
来源仓库:https://github.com/pjt222/development-guides
仓库路径:skills/refactor-skill-structure
安装命令:
npx skills add https://github.com/pjt222/development-guides --skill refactor-skill-structure
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/pjt222/development-guides --skill refactor-skill-structure

简介

refactor-skill-structure 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。

  • 适用于技能系统重构时的结构优化、接口规范制定或模块化拆分参考。
  • 提供技能间调用关系、输入输出格式及错误处理模式的检索支持。
  • 安装命令:npx skills add https://github.com/pjt222/development-guides --skill refactor-skill-structure。
  • 注意检查技能定义文件是否完整,部分字段可能缺失导致检索结果不准确。

SKILL.md

Refactor Skill Structure

Refactor a SKILL.md that has exceeded the 500-line limit or developed structural problems. This skill extracts extended code examples to references/EXAMPLES.md, splits compound procedures into focused sub-procedures, adds cross-references for progressive disclosure, and verifies the skill remains complete and valid after restructuring.

When to Use

  • A skill exceeds the 500-line limit enforced by CI
  • A single procedure step contains multiple unrelated operations that should be separate steps
  • Code blocks longer than 15 lines dominate the SKILL.md and could be extracted
  • The skill has accumulated ad-hoc sections that break the standard six-section structure
  • After a content update pushed the skill over the line limit
  • A skill review flagged structural issues that go beyond content quality

Inputs

  • Required: Path to the SKILL.md file to refactor
  • Optional: Target line count (default: aim for 80% of the 500-line limit, i.e., ~400 lines)
  • Optional: Whether to create references/EXAMPLES.md (default: yes, if extractable content exists)
  • Optional: Whether to split into multiple skills (default: no, prefer extraction first)

Procedure

Step 1: Measure Current Line Count and Identify Bloat Sources

Read the skill and create a section-by-section line budget to identify where the bloat is.

# Total line count
wc -l < skills/<skill-name>/SKILL.md

# Line count per section (approximate)
grep -n "^## \|^### " skills/<skill-name>/SKILL.md

Classify bloat sources:

  • Extractable: Code blocks >15 lines, full configuration examples, multi-variant examples
  • Splittable: Compound procedure steps doing 2+ unrelated operations
  • Trimable: Redundant explanations, overly verbose context sentences
  • Structural: Ad-hoc sections not in the standard six-section structure

Expected: A line budget showing which sections are over-sized and which bloat category applies to each. The largest sections are the primary refactoring targets.

On failure: If the skill is under 500 lines and no structural issues are apparent, this skill may not be needed. Verify the refactoring request is justified before proceeding.

Step 2: Extract Code Blocks to references/EXAMPLES.md

Move code blocks longer than 15 lines to a references/EXAMPLES.md file, leaving brief inline snippets (3-10 lines) in the main SKILL.md.

  1. Create the references directory: mkdir -p skills/<skill-name>/references/
  2. For each extractable code block:

- Copy the full code block to references/EXAMPLES.md under a descriptive heading - Replace the code block in SKILL.md with a brief 3-5 line snippet - Add a cross-reference: See [EXAMPLES.md](references/EXAMPLES.md#heading) for the complete configuration.

  1. Structure references/EXAMPLES.md with clear headings: ``` # Examples ## Example 1: Full Configuration Complete configuration file for [context]: \`yaml #... full config here... \` ## Example 2: Multi-Variant Setup ### Variant A: Development \`yaml #... dev config... \` ### Variant B: Production \`yaml #... prod config... \` ```

Expected: All code blocks >15 lines are extracted. The main SKILL.md retains brief inline snippets for readability. Cross-references link to the extracted content. references/EXAMPLES.md is well-organized with descriptive headings.

On failure: If extracting code blocks does not reduce the line count sufficiently (still over 500), proceed to Step 3 for procedure splitting. If the skill has very few code blocks (e.g., a natural-language skill), focus on Steps 3 and 4 instead.

Step 3: Split Compound Procedures into Focused Steps

Identify procedure steps that perform multiple unrelated operations and split them.

Signs of a compound step:

  • The step title contains "and" (e.g., "Configure Database and Set Up Caching")
  • The step has multiple Expected/On failure blocks (or should have)
  • The step is longer than 30 lines
  • The step could be skipped or done in a different order from its sub-parts

For each compound step:

  1. Identify the distinct operations within the step
  2. Create a new ### Step N: for each operation
  3. Renumber subsequent steps
  4. Ensure each new step has its own Expected and On failure blocks
  5. Add transition context between new steps

Expected: Each procedure step does one thing. No step exceeds 30 lines. Step count may increase but each step is independently verifiable.

On failure: If splitting a step creates steps that are too granular (e.g., 20+ total steps), consider grouping related micro-steps under a single step with numbered sub-steps instead. The sweet spot is 5-12 procedure steps.

Step 4: Add Cross-References from SKILL.md to Extracted Content

Ensure the main SKILL.md maintains readability and discoverability after extraction.

For each extraction:

  1. The inline snippet in SKILL.md should be self-sufficient for the common case
  2. The cross-reference should explain what additional content is available
  3. Use relative paths: [EXAMPLES.md](references/EXAMPLES.md#section-anchor)

Cross-reference patterns:

  • After a brief code snippet: See [EXAMPLES.md](references/EXAMPLES.md#full-configuration) for the complete configuration with all options.
  • For multi-variant examples: See [EXAMPLES.md](references/EXAMPLES.md#variants) for development, staging, and production variants.
  • For extended troubleshooting: See [EXAMPLES.md](references/EXAMPLES.md#troubleshooting) for additional error scenarios.

Expected: Every extraction has a corresponding cross-reference. A reader can follow the main SKILL.md for the common case and drill into references for details.

On failure: If cross-references make the text flow awkward, consolidate multiple references into a single note at the end of the procedure step: For extended examples including [X], [Y], and [Z], see [EXAMPLES.md](references/EXAMPLES.md).

Step 5: Verify Line Count After Refactoring

Re-measure the SKILL.md line count after all changes.

# Check main SKILL.md
lines=$(wc -l < skills/<skill-name>/SKILL.md)
[ "$lines" -le 500 ] && echo "SKILL.md: OK ($lines lines)" || echo "SKILL.md: STILL OVER ($lines lines)"

# Check references file if created
if [ -f skills/<skill-name>/references/EXAMPLES.md ]; then
  ref_lines=$(wc -l < skills/<skill-name>/references/EXAMPLES.md)
  echo "EXAMPLES.md: $ref_lines lines"
fi

# Total content
echo "Total content: $((lines + ${ref_lines:-0})) lines"

Expected: SKILL.md is under 500 lines. Ideally under 400 lines to leave room for future growth. The references/EXAMPLES.md has no line limit.

On failure: If still over 500 lines after extraction and splitting, consider whether the skill should be decomposed into two separate skills. A skill covering too much ground is a sign of scope creep. Use create-skill to author the second skill and update Related Skills cross-references in both.

Step 6: Validate All Sections Still Present

After refactoring, verify the skill still has all required sections and the frontmatter is intact.

Run the review-skill-format checklist:

  1. YAML frontmatter parses correctly
  2. All six required sections present (When to Use, Inputs, Procedure, Validation, Common Pitfalls, Related Skills)
  3. Every procedure step has Expected and On failure blocks
  4. No orphaned cross-references (all links resolve)
# Quick section check
for section in "## When to Use" "## Inputs" "## Procedure" "## Common Pitfalls" "## Related Skills"; do
  grep -q "$section" skills/<skill-name>/SKILL.md && echo "$section: OK" || echo "$section: MISSING"
done
grep -qE "## Validation( Checklist)?" skills/<skill-name>/SKILL.md && echo "Validation: OK" || echo "Validation: MISSING"

Expected: All sections present. No content was accidentally deleted during extraction. Cross-references in SKILL.md resolve to actual headings in EXAMPLES.md.

On failure: If a section was accidentally removed, restore it from git history: git diff skills/<skill-name>/SKILL.md to see what changed. If cross-references are broken, verify the heading anchors in EXAMPLES.md match the links in SKILL.md (GitHub-flavored markdown anchor rules: lowercase, hyphens for spaces, strip punctuation).

Validation

  • SKILL.md line count is 500 or fewer
  • All code blocks in SKILL.md are 15 lines or fewer
  • Extracted content is in references/EXAMPLES.md with descriptive headings
  • Every extraction has a cross-reference in the main SKILL.md
  • No compound procedure steps remain (each step does one thing)
  • All six required sections are present after refactoring
  • Every procedure step has Expected: and On failure: blocks
  • YAML frontmatter is intact and parseable
  • Cross-reference links resolve to actual headings in EXAMPLES.md
  • review-skill-format validation passes on the refactored skill

Common Pitfalls

  • Extracting too aggressively: Moving all code to references makes the main SKILL.md unreadable. Keep 3-10 line snippets inline for the common case. Only extract blocks that are >15 lines or show multiple variants.
  • Broken anchor links: GitHub-flavored markdown anchors are case-sensitive in some renderers. Use lowercase headings in EXAMPLES.md and match exactly in cross-references. Test with grep -c "heading-text" references/EXAMPLES.md.
  • Losing Expected/On failure during splits: When splitting compound steps, ensure each new step gets its own Expected and On failure blocks. It is easy to leave one step without these blocks after a split.
  • Creating too many tiny steps: Splitting should produce 5-12 procedure steps. If you end up with 15+, you have split too aggressively. Merge related micro-steps back into logical groups.
  • Forgetting to update references/EXAMPLES.md headings: If you rename a section in EXAMPLES.md, all cross-reference anchors in SKILL.md must be updated. Grep for the old anchor name to catch all references.

Related Skills

  • review-skill-format — Run format validation after refactoring to confirm the skill is still compliant
  • update-skill-content — Content updates are often the trigger for structural refactoring when they push a skill over the line limit
  • create-skill — Reference the canonical structure when deciding how to organize extracted content
  • evolve-skill — When a skill needs to be split into two separate skills, use evolution to create the derivative

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.28%
按下载量换算54

Claude

30.65%
按下载量换算44

Cursor

18.38%
按下载量换算27

Gemini CLI

8.7%
按下载量换算13

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

未通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills