Agent Skills Framework
ByteBuddy's Agent Skills system provides a powerful, extensible framework for managing and using AI skills. Based on the open Agent Skills specification, it allows you to create, load, and manage skills that enhance AI capabilities for specific tasks.
🎯 Overview
What are Agent Skills?
Agent Skills are self-contained packages that provide specialized instructions, scripts, and resources to enhance AI capabilities for specific tasks. Each skill follows a standardized format and can be dynamically loaded and activated based on context.
Key Features
- Open Specification: Full compatibility with Agent Skills open specification
- Dynamic Loading: Skills load automatically from multiple directories
- Context-Aware Activation: Skills activate based on conversation context
- Resource Management: Access scripts, references, and assets from skills
- Rule Integration: Skills seamlessly integrate with existing rule system
- Built-in Tools: Comprehensive tools for skill discovery and management
📁 Directory Structure
Standard Skill Structure
.bytebuddy/
└── skills/ # Skills root directory
├── algorithmic-art/ # Skill directory (name must match SKILL.md)
│ ├── SKILL.md # Required, follows Agent Skills specification
│ ├── LICENSE.txt # License file (if license field references)
│ ├── scripts/ # Optional, executable code
│ │ └── generate-art.py # Example script
│ ├── references/ # Optional, reference documentation
│ │ └── REFERENCE.md # Technical reference
│ └── assets/ # Optional, static resources
│ └── templates/
│ └── viewer.html # Template file
└── document-processing/ # Another skill
└── SKILL.mdSkill Locations
ByteBuddy searches for skills in the following directories (in order):
- Global Directory:
~/.bytebuddy/skills/(shared across all projects) - Workspace Directory:
项目根目录/.bytebuddy/skills/(project-specific) - Built-in Directory: Internal system skills (read-only)
📝 Skill Format
SKILL.md File Format
---
name: skill-name # Required, 1-64 characters, lowercase letters, numbers, hyphens
description: Skill description # Required, 1-1024 characters
license: MIT # Optional, license information
compatibility: Compatibility notes # Optional, 1-500 characters
metadata: # Optional, arbitrary key-value pairs
author: Author Name
version: "1.0"
allowed-tools: Allowed tools # Optional, experimental feature
---
# Skill Title
Detailed instructions and guidance for using this skill...
## Usage Scenarios
- Scenario 1
- Scenario 2
## Examples
```bash
# Example command
echo "Using the skill"
```Field Specifications
| Field | Required | Constraints |
|---|---|---|
| name | Yes | 1-64 characters, lowercase letters, numbers, hyphens, cannot start or end with hyphen |
| description | Yes | 1-1024 characters, describes skill functionality and use cases |
| license | No | License name or reference to license file |
| compatibility | No | 1-500 characters, environment requirements |
| metadata | No | Arbitrary key-value pairs for extended metadata |
| allowed-tools | No | Space-separated list of tools (experimental) |
Resource Directories
- scripts/: Executable code (Python, Bash, JavaScript, etc.)
- references/: Reference documentation (technical references, API docs, etc.)
- assets/: Static resources (templates, images, data files, etc.)
⚙️ Configuration
Basic Configuration
Add the following to your .bytebuddy/config.yaml:
name: My ByteBuddy Config
version: 0.0.1
skills:
enabled: true
autoActivate: true
directories:
- ~/.bytebuddy/skills
- .bytebuddy/skills
blacklist:
- experimental-skill
whitelist: []
cache:
enabled: true
ttl: 300000Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | true | Enable/disable skills system |
| autoActivate | boolean | true | Auto-activate skills based on context |
| directories | string[] | ["~/.bytebuddy/skills", ".bytebuddy/skills"] | Directories to search for skills |
| blacklist | string[] | [] | Skills to exclude |
| whitelist | string[] | [] | Skills to include (if empty, all skills allowed) |
| cache.enabled | boolean | true | Enable skill caching |
| cache.ttl | number | 300000 | Cache time-to-live in milliseconds |
🛠️ Built-in Tools
ByteBuddy provides several built-in tools for managing skills:
1. List Skills
// Tool: list_skills
// Description: List all available skills
// Usage: AI can call this to discover available skills2. Activate Skill
// Tool: activate_skill
// Description: Activate a specific skill
// Parameters: skillName (string)
// Usage: AI can activate skills based on context3. Get Skill Resource
// Tool: get_skill_resource
// Description: Get skill resource file content
// Parameters: skillName (string), resourcePath (string)
// Usage: AI can access skill scripts and resources4. Search Skills
// Tool: search_skills
// Description: Search skills by keyword
// Parameters: keyword (string), limit (number)
// Usage: AI can find relevant skills5. Activate Skills by Context
// Tool: activate_skills_by_context
// Description: Auto-activate skills based on conversation context
// Parameters: context (string)
// Usage: AI can automatically activate relevant skills🚀 Creating Your First Skill
Step 1: Create Skill Directory
# Create skill directory
mkdir -p .bytebuddy/skills/my-first-skillStep 2: Create SKILL.md
---
name: my-first-skill
description: My first custom skill for ByteBuddy
license: MIT
compatibility: Requires Python 3.8+
metadata:
author: Your Name
version: "1.0"
---
# My First Skill
This skill helps with specific development tasks...
## Usage Guide
1. Step 1: Describe the task
2. Step 2: Use the skill instructions
3. Step 3: Apply the results
## Examples
```python
# Example Python code
print("Using my first skill")
```Step 3: Add Scripts (Optional)
# Create scripts directory
mkdir -p .bytebuddy/skills/my-first-skill/scripts
# Create a Python script
cat > .bytebuddy/skills/my-first-skill/scripts/process.py << 'EOF'
#!/usr/bin/env python3
import json
import sys
def process_data(input_file):
with open(input_file, 'r') as f:
data = json.load(f)
# Processing logic here
return data
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python process.py <input_file>")
sys.exit(1)
result = process_data(sys.argv[1])
print(json.dumps(result, indent=2))
EOFStep 4: Add References (Optional)
# Create references directory
mkdir -p .bytebuddy/skills/my-first-skill/references
# Create reference documentation
cat > .bytebuddy/skills/my-first-skill/references/config.md << 'EOF'
# Configuration Reference
## Input Format
```json
{
"data": "Data to process"
}Output Format
{
"result": "Processing result",
"status": "success"
}EOF
## 🔄 Skill Lifecycle
### 1. Loading
Skills are loaded automatically when ByteBuddy starts or when the skill directory changes.
### 2. Validation
Each skill is validated for:
- Correct SKILL.md format
- Valid metadata fields
- Resource file accessibility
### 3. Activation
Skills can be activated:
- **Automatically**: Based on conversation context
- **Manually**: Via AI tool calls
- **Programmatically**: Via configuration
### 4. Usage
Once activated, skills provide:
- Instructions to the AI
- Access to scripts and resources
- Enhanced capabilities for specific tasks
## 🎯 Best Practices
### Skill Design
1. **Single Responsibility**: Each skill should focus on one specific task
2. **Clear Documentation**: Provide comprehensive usage instructions
3. **Examples**: Include practical examples
4. **Error Handling**: Scripts should handle errors gracefully
### Performance
1. **Lazy Loading**: Resources load only when needed
2. **Caching**: Enable caching for better performance
3. **Minimal Dependencies**: Keep scripts lightweight
### Security
1. **Sandbox Execution**: Scripts run in isolated environments
2. **Input Validation**: Validate all inputs
3. **Permission Control**: Control resource access
## 📚 Examples
### Example 1: Code Review Skill
````markdown
---
name: code-review-assistant
description: AI-powered code review assistant with best practices
license: Apache-2.0
compatibility: Works with any programming language
metadata:
author: ByteBuddy Team
version: "1.2.0"
---
# Code Review Assistant
This skill helps with comprehensive code reviews...
## Review Checklist
- [ ] Code style and formatting
- [ ] Error handling
- [ ] Performance considerations
- [ ] Security vulnerabilities
- [ ] Test coverage
## Examples
```python
# Before review
def process_data(data):
return data * 2
# After review with improvements
def process_data(data: List[int]) -> List[int]:
"""Process list of integers by doubling each element."""
if not data:
return []
return [item * 2 for item in data]
### Example 2: Database Migration Skill
````markdown
---
name: database-migration
description: Database schema migration and data transformation
license: MIT
compatibility: PostgreSQL, MySQL, SQLite
metadata:
author: Database Team
version: "2.1.0"
---
# Database Migration Assistant
This skill helps with database migrations...
## Migration Steps
1. Backup existing data
2. Create migration scripts
3. Test migration
4. Apply migration
5. Verify results
## Examples
```sql
-- Migration script example
CREATE TABLE users_new (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Data migration
INSERT INTO users_new (email, created_at)
SELECT email, created_at FROM users;
```🔧 Advanced Usage
Skill Dependencies
Skills can declare dependencies in metadata:
metadata:
dependencies: |
python>=3.8
requests>=2.25
pandas>=1.3Skill Versioning
Use semantic versioning in metadata:
metadata:
version: "1.2.3" # Major.Minor.PatchSkill Testing
Create test scripts in the skill directory:
my-skill/
├── SKILL.md
├── scripts/
│ └── main.py
└── tests/
└── test_main.py🚨 Troubleshooting
Common Issues
Skill Not Loading
- Check SKILL.md format
- Verify directory permissions
- Check configuration settings
Resources Not Accessible
- Verify file paths
- Check file permissions
- Ensure correct resource references
Activation Issues
- Check context matching
- Verify skill compatibility
- Review skill metadata
Debug Commands
# List all loaded skills
bytebuddy skills list
# Check skill details
bytebuddy skills show skill-name
# Reload skills
bytebuddy skills reload
# Clear skill cache
bytebuddy skills clear-cache📖 Further Reading
- Agent Skills Open Specification
- ByteBuddy Skills Implementation Guide
- Custom Rules Documentation
- Tool System Documentation
Ready to enhance your AI capabilities? Start creating your own skills today and share them with the community!