微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🔍

代码库模式智能提取与技能化沉淀

Skill Extraction · v1.0.0
开发 安全 A 级 作者 wpank 公开目录收录
1.4k 下载 0 安装 6.4k 收藏 17 浏览

简介

从代码库自动提取设计系统、架构模式和工作流方法论,转化为可复用的结构化技能与文档,支持设计令牌捕获、技术债务分析和跨项目模式沉淀

原始描述

Extract design systems, architecture patterns, and methodology from codebases into reusable skills and documentation. Use when analyzing a project to capture patterns, creating skills from existing code, extracting design tokens, or documenting how a project was built. Triggers on "extract patterns", "extract from this repo", "analyze this codebase", "create skills from this project", "extract design system".

通过你的 Agent 添加

安装目录:pattern-extraction/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/skill-extraction/
Codex CLI~/.codex/skills/skill-extraction/
DeepSeek Harness~/.agents/skills/skill-extraction/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

核心用法

Pattern Extraction 是一套面向代码库的结构化分析方法论,旨在从现有项目中捕获可复用的设计系统、架构模式与工作流实践。其核心流程分为五个阶段:

  1. Discovery(发现):扫描项目根目录结构、关键配置文件(package.json、tailwind.config.* 等)、技术栈标识(React、Go、Kubernetes 等)以及设计系统信号(CSS 变量、主题文件、设计文档)。
  2. Categorization(分类):按优先级映射发现内容——设计系统(最高优先)、UI 模式、架构、工作流、领域特定模式,并筛选出具有跨组件复用价值、有文档记录的设计决策。
  3. Extraction(提取):针对高价值模式生成输出:设计系统提取为文档+技能,架构沉淀为方法论文档,具体模式转化为独立技能(需满足 <300 行、包含 WHAT/WHEN/KEYWORDS 描述、NEVER 反模式清单等质量门槛)。
  4. Validation(验证):执行质量检查,包括专家知识占比(>70% 非 Claude 基础模型已知内容)、冲突检测(避免重复技能)、模板完整性验证。
  5. Output(输出):将内容写入标准化目录结构——docs/extracted/ 存放方法论文档,ai/skills/ 存放可复用技能。

显著优点

  • 系统性优先级:明确将设计系统(颜色、排版、动效、美学方向)置于最高提取优先级,避免技术实现细节淹没设计意图。
  • 强制质量门槛:内置 skill-quality-criteria.md 检查清单,要求技能描述包含触发关键词、反模式清单、代码示例,且行数严格控制在 300 行以内(上限 500)。
  • 项目无关化:强制去除硬编码项目名称,确保提取的模式具备跨项目迁移能力。
  • 渐进式精炼:支持将提取结果暂存至 staging 区域,通过后续 refinement 流程跨项目整合,形成通用技能库。

潜在缺点与局限性

  • 依赖源项目质量:若原项目缺乏文档化设计决策、使用默认配置或充斥一次性 hack,提取价值大幅降低。
  • 半自动化瓶颈:虽然流程结构化,但"是否值得提取"的判断仍需人工/AI 主观评估,存在误筛或过度提取风险。
  • 技术栈覆盖盲区:当前指标文件显式针对 JavaScript/React/Tailwind/shadcn/ui 生态,对 Rust、Python、原生移动开发等栈的检测指标不足。
  • 美学捕获的主观性:"设计哲学"和"vibe"的文档化依赖提取者的设计敏感度,可能产生不一致的输出质量。

适合人群

  • 设计系统工程师:需要从遗留项目中抢救设计令牌和美学方向
  • 平台/中台团队:负责沉淀跨项目的可复用技术资产
  • 技术负责人:进行代码库健康度审计、技术债务识别与模式标准化
  • AI 辅助开发工具链构建者:需要将组织内部最佳实践转化为结构化技能供 AI 代理调用

常规风险

  • 过度工程化风险:可能将本应简单的项目特定方案强行泛化为"可复用模式",增加不必要的抽象成本。
  • 技能膨胀:缺乏严格的冲突检测时,易产生功能重叠的碎片化技能,维护成本上升。
  • 知识产权敏感:提取过程中可能捕获包含业务逻辑的项目特定代码,需确保输出前完成项目无关化清洗。
  • 版本漂移:提取的技能与原项目演进脱节,若缺乏持续同步机制,技能可能迅速过时。

技能正文


name: pattern-extraction model: reasoning description: Extract design systems, architecture patterns, and methodology from codebases into reusable skills and documentation. Use when analyzing a project to capture patterns, creating skills from existing code, extracting design tokens, or documenting how a project was built. Triggers on "extract patterns", "extract from this repo", "analyze this codebase", "create skills from this project", "extract design system".

Pattern Extraction

Extract reusable patterns, skills, and methodology documentation from existing codebases.

Installation

OpenClaw / Moltbot / Clawbot

npx clawhub@latest install extraction

Before Starting

MANDATORY: Read these reference files based on what you're extracting:

Extracting Read First
Any extraction methodology-values.md — priority order and what to look for
Specific categories extraction-categories.md — detailed patterns per category
Generating skills skill-quality-criteria.md — quality checklist

Extraction Process

Phase 1: Discovery

Analyze the project to understand what exists.

Scan for project structure:

- Root directory layout
- Key config files (package.json, tailwind.config.*, etc.)
- Documentation (README, docs/, etc.)
- Source organization (src/, app/, components/, etc.)

Identify tech stack:

Indicator Technology
package.json with react React
tailwind.config.* Tailwind CSS
components.json shadcn/ui
go.mod Go
Dockerfile Docker
k8s/ or .yaml manifests Kubernetes
turbo.json Turborepo
Makefile Make automation

Look for design system signals:

  • Custom Tailwind config (not defaults)
  • CSS variables / custom properties
  • Theme files
  • Design documentation
  • Mood boards or reference lists

Capture key findings:

  • What's the tech stack?
  • What's the folder structure?
  • Is there a documented design direction?
  • What workflows exist (Makefile, scripts)?

Phase 2: Categorization

Map discoveries to extraction categories, prioritized:

Priority order:

  1. Design Systems — Color tokens, typography, spacing, motion, aesthetic documentation
  2. UI Patterns — Component organization, layouts, interactions
  3. Architecture — Folder structure, data flow, API patterns
  4. Workflows — Build, dev, deploy, CI/CD
  5. Domain-Specific — Patterns unique to this application type

For each category found, note:

  • What specific patterns exist?
  • Where are they defined? (file paths)
  • Are they documented? (comments, docs)
  • Are they worth extracting? (used in multiple places, well-designed)

Filter by value:

Extract Skip
Patterns used across multiple components One-off solutions
Customized configs with intention Default configurations
Documented design decisions Arbitrary choices
Reusable infrastructure Project-specific hacks

Phase 3: Extraction

For each valuable pattern, generate outputs.

Design Systems → Design System Doc + Skill

  1. Read the Tailwind config, CSS files, theme files
  2. Extract actual token values (colors, typography, spacing)
  3. Document the aesthetic direction
  4. Create:
    • docs/extracted/[project]-design-system.md using design-system.md template
    • ai/skills/[project]-design-system/SKILL.md if patterns are reusable

Architecture → Methodology Doc

  1. Document folder structure with reasoning
  2. Capture data flow patterns
  3. Note key technical decisions
  4. Create docs/extracted/[project]-summary.md using project-summary.md template

Patterns → Skills

For each pattern worth a skill:

  1. Load skill-quality-criteria.md
  2. Use skill-template.md template
  3. Verify the quality checklist:
    • Description has WHAT, WHEN, KEYWORDS
    • No explanations of basics Claude knows
    • Has specific NEVER list
    • < 300 lines ideal
  4. Create ai/skills/[project]-[pattern]/SKILL.md

Phase 4: Validation

Before writing output, validate extracted content.

For each skill, verify:

  • Description has WHAT, WHEN, and trigger KEYWORDS
  • >70% expert knowledge (not in base Claude model)
  • <300 lines (max 500)
  • Has "When to Use" section with clear triggers
  • Has code examples (if applicable)
  • Has NEVER Do section with anti-patterns
  • Project-agnostic (no hardcoded project names)

For documentation, verify:

  • Actual values extracted (not placeholders)
  • Templates fully filled out
  • Aesthetic direction documented (for design systems)
  • File paths are correct

Conflict detection: Before creating a new skill, check if similar skills exist:

# Check existing skills in the target repo
ls ai/skills/*/
Situation Action
Similar skill exists Enhance existing skill instead
Overlapping patterns Note overlap, may merge in refinement
Unique pattern Proceed with new skill

Phase 5: Output

Write extracted content to target locations.

Methodology Documentation:

docs/extracted/
├── [project]-summary.md       # Overall methodology
├── [project]-design-system.md # Design tokens and aesthetic
└── [project]-architecture.md  # Code patterns (if complex)

Skills:

ai/skills/
└── [project]-[category]/
    ├── SKILL.md
    └── references/  # (if needed for detailed content)

Create docs/extracted/ directory if it doesn't exist.


Extraction Focus Areas

Design System Extraction (Highest Priority)

When a project has intentional design work, extract thoroughly:

Must capture:

  • Color palette (primary, secondary, accent, semantic)
  • Typography (fonts, scale, weights)
  • Spacing scale
  • Motion/animation patterns
  • The "vibe" or aesthetic direction

Look in:

  • tailwind.config.js / tailwind.config.ts
  • globals.css / app.css / root CSS files
  • theme.ts / theme.js
  • Any design documentation

Generate:

  1. Design system documentation with actual values
  2. Skill capturing the aesthetic philosophy (if distinctive)

Workflow Extraction

Look for:

  • Makefile targets
  • package.json scripts
  • Docker configurations
  • CI/CD workflows

Extract:

  • Dev setup commands
  • Build processes
  • Deployment patterns

Error Handling

Situation Resolution
No patterns found Create project summary only; document why extraction failed
Pattern too project-specific Skip or generalize by removing project names
Incomplete pattern Extract what exists, note gaps in skill
Quality criteria not met Revise skill or skip pattern
Similar skill already exists Update existing skill instead of creating new
Can't find source files Note in extraction log, skip that category

When extraction fails partially:

  1. Complete what can be extracted
  2. Document gaps in the project summary
  3. Note "Incomplete extraction" in output
  4. Suggest what additional information would be needed

NEVER Do

  • NEVER extract default configurations — Only extract customized, intentional patterns
  • NEVER create skills for basic concepts — Claude already knows React, Tailwind basics
  • NEVER skip the aesthetic — Design philosophy is highest priority
  • NEVER generate skills > 500 lines — Use references/ for detailed content
  • NEVER create skills without good descriptions — Description determines if skill activates
  • NEVER extract one-off solutions — Focus on patterns used in multiple places
  • NEVER skip validation phase — Quality check before writing output
  • NEVER leave project names in skills — Make patterns project-agnostic
  • NEVER create duplicate skills — Check for existing similar skills first

Quality Check Before Finishing

  • Design system captured (if one exists)?
  • Methodology summary created?
  • Skills have proper descriptions (WHAT, WHEN, KEYWORDS)?
  • Skills pass the expert knowledge test?
  • Anti-patterns documented in skills?
  • Output files created in correct locations?

After Extraction: Staging for Refinement

If you're extracting to later consolidate patterns across multiple projects:

Copy results to the skills toolkit repo for staging:

# From this project, copy to the skills repo staging area
cp -r ai/skills/[project]-* /path/to/skills-repo/ai/staging/skills/
cp -r docs/extracted/* /path/to/skills-repo/ai/staging/docs/

Staging folder structure:

ai/staging/
├── skills/           # Extracted skills from multiple projects
│   ├── project-a-design-system/
│   ├── project-b-ui-patterns/
│   └── ...
└── docs/             # Extracted methodology docs
    ├── project-a-summary.md
    ├── project-b-design-system.md
    └── ...

After staging content from multiple projects:

  • Say "refine staged content" or "consolidate staged skills"
  • The refinement process will:
    • Identify patterns across projects
    • Consolidate into project-agnostic skills
    • Update methodology docs with insights
    • Promote refined skills to active locations

Related Skills

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

code-analysisdesign-systemspattern-extractionskill-generationdocumentationarchitecture-patternsworkflow-automation

同类 Skill