create-skill-from-source-code
Skill này làm gì
Skill này hướng dẫn AI agent đọc một file mã nguồn và viết tài liệu giáo dục từ nó, dưới dạng một file skill. Nó dành cho những người muốn dạy hoặc ghi chép một triển khai tham chiếu.
Khi nào nên dùng
- ✓Khi bạn có một triển khai tham chiếu và muốn làm tài liệu học tập từ nó.
- ✓Khi bạn cần tài liệu tái sử dụng giải thích cách một đoạn mã hoạt động.
- ✓Khi bạn muốn ghi lại kiến trúc, kỹ thuật chính và ví dụ sử dụng.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/create-skill-from-source-code/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Đọc file mã nguồn này và viết một hướng dẫn rõ ràng giải thích các mẫu chính của nó, rồi chỉ cách dùng chúng.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent đọc toàn bộ file mã nguồn, xác định các mẫu kiến trúc, cấu trúc dữ liệu và thuật toán, rồi ghi chú các điểm tích hợp. Sau đó nó viết tài liệu với tiêu đề đúng, phần phân tích, mẫu mã và ví dụ.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Create Skill from Source Code
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.
Overview
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.
Prerequisites
- Access to the source code file(s) you want to document
- Understanding of the target audience for the skill
- Knowledge of the programming language/framework used
Workflow Steps
1. Read and Parse the Source Code
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.
2. Identify Key Architectural Patterns
Analyze the code to identify:
- Core architectural patterns: What design patterns are used? (e.g., Observer, Factory, MVC)
- Key implementation techniques: How are specific challenges solved?
- Important data structures: What structures enable the functionality?
- Critical algorithms: What are the main algorithmic approaches?
- Integration points: How does the code interact with external systems?
Take notes on 3-5 major patterns that define the implementation.
3. Create the Skill Directory Structure
# 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
4. Generate Comprehensive SKILL.md
Create a SKILL.md file with the following structure:
Required YAML Frontmatter
---
name: descriptive-skill-name
description: Brief one-sentence description of what the skill teaches
---
Frontmatter rules:
- Must be enclosed in
---fences name: lowercase, use hyphens for spacesdescription: concise but informative (1-2 sentences max)
Document Body Structure
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
5. Verify File Creation and Frontmatter
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:
- File starts with
---on line 1 - YAML contains at least
nameanddescriptionfields - Frontmatter closes with
--- - Content follows immediately after
6. Add Auxiliary Files (Optional)
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
Tips for Creating Effective Skills
Make It Generalizable
- Abstract away specific variable names, file paths, or domain-specific detail
Câu hỏi thường gặp
Agent xác định gì trong mã?
Nó tìm các mẫu thiết kế, kỹ thuật chính, cấu trúc dữ liệu quan trọng, thuật toán và điểm tích hợp.
Hướng dẫn dành cho ai?
Skill yêu cầu agent xem xét đối tượng người đọc trước khi viết.
Có bao gồm ví dụ mã không?
Có, skill bao gồm các template mã và ví dụ sử dụng trong đầu ra.
Chi tiết
Mô tả gốc của tác giả
Analyze existing source code to identify key patterns and generate comprehensive educational skill documentation with proper YAML frontmatter, architectural analysis, code templates, and usage examples.
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #13043
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
Skill tương tự
technical-documentation
394kGiúp agent của bạn viết và rà soát tài liệu kỹ thuật cùng file hướng dẫn cho agent, rõ ràng để mọi người và công cụ AI đều dễ làm theo.
architecture-decision-records
280kGiúp agent của bạn ghi lại các quyết định quan trọng về cấu trúc dự án, giúp hiểu lý do đằng sau các lựa chọn và giữ lịch sử thay đổi rõ ràng.
code-tour
280kGiúp agent của bạn tạo các hướng dẫn đọc code từng bước, có tham chiếu chính xác đến file và dòng, hữu ích cho phần giới thiệu, giải thích và rà soát.