Analyze existing source code to identify key patterns and generate comprehensive educational skill documentation with proper YAML frontmatter, architectural ana
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-create-skill-from-source-code-afb8dd44405a ,按照其中的说明把「create-skill-from-source-code」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
This skill guides you through the process of analyzing an existing source code implementation and transforming it into comprehensive educational documentation in the form of a skill file.
When you have a reference implementation and need to create teaching materials or reusable documentation from it, follow this systematic workflow to extract patterns, analyze architecture, and generate well-structured educational content.
First, read the complete source file to understand its full scope:
# Read the source file
cat /path/to/source/file.ext
Or use file reading tools to access the content programmatically.
Analyze the code to identify:
Take notes on 3-5 major patterns that define the implementation.
# Create skill directory
mkdir -p skills/skill-name
# If you need auxiliary files (examples, scripts, etc.)
mkdir -p skills/skill-name/examples
mkdir -p skills/skill-name/templates
Create a SKILL.md file with the following structure:
---
name: descriptive-skill-name
description: Brief one-sentence description of what the skill teaches
---
Frontmatter rules:
--- fencesname: lowercase, use hyphens for spacesdescription: concise but informative (1-2 sentences max)Organize the content into clear sections:
# [Skill Title]
## Overview
Brief introduction to what pattern/technique is being taught.
## Key Patterns Identified
### Pattern 1: [Name]
**Purpose**: What problem does it solve?
**Implementation**: How is it implemented in the reference code?
**Key Code Elements**:
- Relevant classes/functions
- Important variables/structures
### Pattern 2: [Name]
[Same structure as Pattern 1]
[Continue for 3-5 main patterns]
## Complete Code Template
Provide a minimal but complete implementation:
\`\`\`[language]
// Simplified, well-commented version of the key code
// Include only essential elements
// Add explanatory comments
\`\`\`
## Usage Examples
### Example 1: Basic Usage
\`\`\`[language]
// Practical example showing how to use the pattern
\`\`\`
### Example 2: Advanced Usage
\`\`\`[language]
// More complex scenario
\`\`\`
## Best Practices
- List key recommendations
- Common pitfalls to avoid
- Performance considerations
- Testing strategies
## When to Use This Pattern
Explain scenarios where this pattern is appropriate and where it might not be the best choice.
## Related Patterns
Reference related techniques or alternative approaches.
## References
- Link to original source (if applicable)
- Related documentation
- Further reading
After creating the skill file, verify:
# Check file exists
ls -la skills/skill-name/SKILL.md
# Verify frontmatter format
head -n 5 skills/skill-name/SKILL.md
# Should show:
# ---
# name: skill-name
# description: Description here
# ---
Ensure:
--- on line 1name and description fields---If the pattern benefits from additional resources:
Example script (examples/demo.sh):
#!/bin/bash
# Demonstration script showing the pattern in action
Template file (templates/starter.template):
# Ready-to-use template that users can copy
Configuration example (examples/config.example):
# Sample configuration demonstrating best practices
[your-project], [input-file] for context-specific valuesGiven a VirtualList.ts source file implementing virtual scrolling:
skills/virtual-scrolling-pattern/virtual-scrolling-patternBefore finalizing the skill: