Initial commit
This commit is contained in:
6
skills/skill-adapter/assets/README.md
Normal file
6
skills/skill-adapter/assets/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# Assets
|
||||
|
||||
Bundled resources for api-rate-limiter skill
|
||||
|
||||
- [ ] rate_limit_template.conf: Template configuration file for the rate limiting implementation.
|
||||
- [ ] error_message_template.json: Template for the JSON error message returned when rate limits are exceeded.
|
||||
32
skills/skill-adapter/assets/config-template.json
Normal file
32
skills/skill-adapter/assets/config-template.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"skill": {
|
||||
"name": "skill-name",
|
||||
"version": "1.0.0",
|
||||
"enabled": true,
|
||||
"settings": {
|
||||
"verbose": false,
|
||||
"autoActivate": true,
|
||||
"toolRestrictions": true
|
||||
}
|
||||
},
|
||||
"triggers": {
|
||||
"keywords": [
|
||||
"example-trigger-1",
|
||||
"example-trigger-2"
|
||||
],
|
||||
"patterns": []
|
||||
},
|
||||
"tools": {
|
||||
"allowed": [
|
||||
"Read",
|
||||
"Grep",
|
||||
"Bash"
|
||||
],
|
||||
"restricted": []
|
||||
},
|
||||
"metadata": {
|
||||
"author": "Plugin Author",
|
||||
"category": "general",
|
||||
"tags": []
|
||||
}
|
||||
}
|
||||
33
skills/skill-adapter/assets/error_message_template.json
Normal file
33
skills/skill-adapter/assets/error_message_template.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"_comment": "Template for error message when rate limits are exceeded",
|
||||
"error": {
|
||||
"code": 429,
|
||||
"_comment": "HTTP status code for Too Many Requests",
|
||||
"message": "Too Many Requests",
|
||||
"_comment": "General error message",
|
||||
"details": {
|
||||
"reason": "Rate limit exceeded",
|
||||
"_comment": "Specific reason for the error",
|
||||
"limit": 100,
|
||||
"_comment": "The allowed request limit",
|
||||
"remaining": 0,
|
||||
"_comment": "Requests remaining in the current window",
|
||||
"reset_at": "2024-01-24T12:00:00Z",
|
||||
"_comment": "ISO 8601 timestamp for when the limit resets",
|
||||
"policy": "100 requests per minute",
|
||||
"_comment": "Human-readable policy description",
|
||||
"algorithm": "token_bucket",
|
||||
"_comment": "Rate limiting algorithm used (token_bucket, sliding_window, fixed_window)",
|
||||
"scope": "user",
|
||||
"_comment": "Scope of the rate limit (user, ip, global)",
|
||||
"key": "user_id:123",
|
||||
"_comment": "Key used for rate limiting (e.g., user ID, IP address)",
|
||||
"retry_after": 60,
|
||||
"_comment": "Seconds to wait before retrying the request (for Retry-After header)",
|
||||
"documentation_url": "https://example.com/api/rate-limiting",
|
||||
"_comment": "URL to documentation about rate limiting",
|
||||
"support_email": "support@example.com"
|
||||
"_comment": "Support email for questions about rate limits"
|
||||
}
|
||||
}
|
||||
}
|
||||
97
skills/skill-adapter/assets/rate_limit_template.conf
Normal file
97
skills/skill-adapter/assets/rate_limit_template.conf
Normal file
@@ -0,0 +1,97 @@
|
||||
# rate_limit_template.conf
|
||||
|
||||
# This is a template configuration file for the API Rate Limiter plugin.
|
||||
# Fill in the placeholders with your desired values.
|
||||
# Save this file as rate_limit.conf (or similar) and specify its path when configuring the plugin.
|
||||
|
||||
# --- General Settings ---
|
||||
# Enable/Disable rate limiting
|
||||
enabled: true # Set to 'false' to disable rate limiting
|
||||
|
||||
# Rate limiting algorithm: token_bucket, sliding_window, fixed_window
|
||||
algorithm: token_bucket
|
||||
|
||||
# Redis connection details
|
||||
redis_host: localhost
|
||||
redis_port: 6379
|
||||
redis_password: "" # Leave blank if no password
|
||||
redis_db: 0
|
||||
|
||||
# --- Global Rate Limits (applied to all requests if no user/IP specific limits are defined) ---
|
||||
global_limit_enabled: false # Enable/disable global rate limiting
|
||||
|
||||
# Number of requests allowed within the specified time window
|
||||
global_requests_per_window: 100
|
||||
|
||||
# Time window in seconds
|
||||
global_window_seconds: 60
|
||||
|
||||
# --- Token Bucket Settings (if algorithm is set to 'token_bucket') ---
|
||||
# Number of tokens in the bucket
|
||||
token_bucket_capacity: 100
|
||||
|
||||
# Rate at which tokens are added to the bucket (tokens per second)
|
||||
token_replenishment_rate: 10
|
||||
|
||||
# --- Sliding Window Settings (if algorithm is set to 'sliding_window') ---
|
||||
# Number of requests allowed within the window
|
||||
sliding_window_limit: 100
|
||||
|
||||
# Window size in seconds
|
||||
sliding_window_seconds: 60
|
||||
|
||||
# --- Fixed Window Settings (if algorithm is set to 'fixed_window') ---
|
||||
# Number of requests allowed within the window
|
||||
fixed_window_limit: 100
|
||||
|
||||
# Window size in seconds
|
||||
fixed_window_seconds: 60
|
||||
|
||||
# --- Per User/IP Rate Limits ---
|
||||
# Enable per-user rate limiting (requires user identification mechanism)
|
||||
user_limit_enabled: false
|
||||
|
||||
# Number of requests allowed per user within the specified time window
|
||||
user_requests_per_window: 50
|
||||
|
||||
# Time window in seconds for user rate limiting
|
||||
user_window_seconds: 60
|
||||
|
||||
# Enable per-IP rate limiting
|
||||
ip_limit_enabled: true
|
||||
|
||||
# Number of requests allowed per IP within the specified time window
|
||||
ip_requests_per_window: 20
|
||||
|
||||
# Time window in seconds for IP rate limiting
|
||||
ip_window_seconds: 60
|
||||
|
||||
# --- Burst Handling ---
|
||||
# Allow a burst of requests beyond the rate limit (e.g., for initial page load)
|
||||
burst_limit_enabled: true
|
||||
|
||||
# Maximum number of requests allowed in a burst
|
||||
burst_limit: 20
|
||||
|
||||
# --- Rate Limit Headers ---
|
||||
# Enable sending rate limit headers in the response
|
||||
enable_rate_limit_headers: true
|
||||
|
||||
# Header name for the rate limit
|
||||
rate_limit_header: X-RateLimit-Limit
|
||||
|
||||
# Header name for the remaining requests
|
||||
rate_limit_remaining_header: X-RateLimit-Remaining
|
||||
|
||||
# Header name for the time until the limit resets (in seconds)
|
||||
rate_limit_reset_header: X-RateLimit-Reset
|
||||
|
||||
# --- Advanced Settings ---
|
||||
# Key prefix for storing rate limit data in Redis
|
||||
redis_key_prefix: rate_limit:
|
||||
|
||||
# Custom error message when rate limit is exceeded
|
||||
rate_limit_exceeded_message: "Rate limit exceeded. Please try again later."
|
||||
|
||||
# HTTP status code to return when rate limit is exceeded
|
||||
rate_limit_exceeded_status_code: 429 # Too Many Requests
|
||||
28
skills/skill-adapter/assets/skill-schema.json
Normal file
28
skills/skill-adapter/assets/skill-schema.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Claude Skill Configuration",
|
||||
"type": "object",
|
||||
"required": ["name", "description"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9-]+$",
|
||||
"maxLength": 64,
|
||||
"description": "Skill identifier (lowercase, hyphens only)"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 1024,
|
||||
"description": "What the skill does and when to use it"
|
||||
},
|
||||
"allowed-tools": {
|
||||
"type": "string",
|
||||
"description": "Comma-separated list of allowed tools"
|
||||
},
|
||||
"version": {
|
||||
"type": "string",
|
||||
"pattern": "^\\d+\\.\\d+\\.\\d+$",
|
||||
"description": "Semantic version (x.y.z)"
|
||||
}
|
||||
}
|
||||
}
|
||||
27
skills/skill-adapter/assets/test-data.json
Normal file
27
skills/skill-adapter/assets/test-data.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"testCases": [
|
||||
{
|
||||
"name": "Basic activation test",
|
||||
"input": "trigger phrase example",
|
||||
"expected": {
|
||||
"activated": true,
|
||||
"toolsUsed": ["Read", "Grep"],
|
||||
"success": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Complex workflow test",
|
||||
"input": "multi-step trigger example",
|
||||
"expected": {
|
||||
"activated": true,
|
||||
"steps": 3,
|
||||
"toolsUsed": ["Read", "Write", "Bash"],
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"fixtures": {
|
||||
"sampleInput": "example data",
|
||||
"expectedOutput": "processed result"
|
||||
}
|
||||
}
|
||||
8
skills/skill-adapter/references/README.md
Normal file
8
skills/skill-adapter/references/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# References
|
||||
|
||||
Bundled resources for api-rate-limiter skill
|
||||
|
||||
- [ ] rate_limiting_algorithms.md: Explains different rate limiting algorithms (token bucket, sliding window, fixed window) in detail.
|
||||
- [ ] redis_setup.md: Provides instructions on setting up Redis for distributed rate limiting.
|
||||
- [ ] api_gateway_integration.md: Describes how to integrate the rate limiting logic with different API gateways (e.g., Kong, Tyk, AWS API Gateway).
|
||||
- [ ] example_rate_limit_config.json: Example configuration file for rate limiting.
|
||||
69
skills/skill-adapter/references/best-practices.md
Normal file
69
skills/skill-adapter/references/best-practices.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# Skill Best Practices
|
||||
|
||||
Guidelines for optimal skill usage and development.
|
||||
|
||||
## For Users
|
||||
|
||||
### Activation Best Practices
|
||||
|
||||
1. **Use Clear Trigger Phrases**
|
||||
- Match phrases from skill description
|
||||
- Be specific about intent
|
||||
- Provide necessary context
|
||||
|
||||
2. **Provide Sufficient Context**
|
||||
- Include relevant file paths
|
||||
- Specify scope of analysis
|
||||
- Mention any constraints
|
||||
|
||||
3. **Understand Tool Permissions**
|
||||
- Check allowed-tools in frontmatter
|
||||
- Know what the skill can/cannot do
|
||||
- Request appropriate actions
|
||||
|
||||
### Workflow Optimization
|
||||
|
||||
- Start with simple requests
|
||||
- Build up to complex workflows
|
||||
- Verify each step before proceeding
|
||||
- Use skill consistently for related tasks
|
||||
|
||||
## For Developers
|
||||
|
||||
### Skill Development Guidelines
|
||||
|
||||
1. **Clear Descriptions**
|
||||
- Include explicit trigger phrases
|
||||
- Document all capabilities
|
||||
- Specify limitations
|
||||
|
||||
2. **Proper Tool Permissions**
|
||||
- Use minimal necessary tools
|
||||
- Document security implications
|
||||
- Test with restricted tools
|
||||
|
||||
3. **Comprehensive Documentation**
|
||||
- Provide usage examples
|
||||
- Document common pitfalls
|
||||
- Include troubleshooting guide
|
||||
|
||||
### Maintenance
|
||||
|
||||
- Keep version updated
|
||||
- Test after tool updates
|
||||
- Monitor user feedback
|
||||
- Iterate on descriptions
|
||||
|
||||
## Performance Tips
|
||||
|
||||
- Scope skills to specific domains
|
||||
- Avoid overlapping trigger phrases
|
||||
- Keep descriptions under 1024 chars
|
||||
- Test activation reliability
|
||||
|
||||
## Security Considerations
|
||||
|
||||
- Never include secrets in skill files
|
||||
- Validate all inputs
|
||||
- Use read-only tools when possible
|
||||
- Document security requirements
|
||||
70
skills/skill-adapter/references/examples.md
Normal file
70
skills/skill-adapter/references/examples.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# Skill Usage Examples
|
||||
|
||||
This document provides practical examples of how to use this skill effectively.
|
||||
|
||||
## Basic Usage
|
||||
|
||||
### Example 1: Simple Activation
|
||||
|
||||
**User Request:**
|
||||
```
|
||||
[Describe trigger phrase here]
|
||||
```
|
||||
|
||||
**Skill Response:**
|
||||
1. Analyzes the request
|
||||
2. Performs the required action
|
||||
3. Returns results
|
||||
|
||||
### Example 2: Complex Workflow
|
||||
|
||||
**User Request:**
|
||||
```
|
||||
[Describe complex scenario]
|
||||
```
|
||||
|
||||
**Workflow:**
|
||||
1. Step 1: Initial analysis
|
||||
2. Step 2: Data processing
|
||||
3. Step 3: Result generation
|
||||
4. Step 4: Validation
|
||||
|
||||
## Advanced Patterns
|
||||
|
||||
### Pattern 1: Chaining Operations
|
||||
|
||||
Combine this skill with other tools:
|
||||
```
|
||||
Step 1: Use this skill for [purpose]
|
||||
Step 2: Chain with [other tool]
|
||||
Step 3: Finalize with [action]
|
||||
```
|
||||
|
||||
### Pattern 2: Error Handling
|
||||
|
||||
If issues occur:
|
||||
- Check trigger phrase matches
|
||||
- Verify context is available
|
||||
- Review allowed-tools permissions
|
||||
|
||||
## Tips & Best Practices
|
||||
|
||||
- ✅ Be specific with trigger phrases
|
||||
- ✅ Provide necessary context
|
||||
- ✅ Check tool permissions match needs
|
||||
- ❌ Avoid vague requests
|
||||
- ❌ Don't mix unrelated tasks
|
||||
|
||||
## Common Issues
|
||||
|
||||
**Issue:** Skill doesn't activate
|
||||
**Solution:** Use exact trigger phrases from description
|
||||
|
||||
**Issue:** Unexpected results
|
||||
**Solution:** Check input format and context
|
||||
|
||||
## See Also
|
||||
|
||||
- Main SKILL.md for full documentation
|
||||
- scripts/ for automation helpers
|
||||
- assets/ for configuration examples
|
||||
7
skills/skill-adapter/scripts/README.md
Normal file
7
skills/skill-adapter/scripts/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Scripts
|
||||
|
||||
Bundled resources for api-rate-limiter skill
|
||||
|
||||
- [ ] generate_rate_limit_config.py: Generates rate limiting configuration files based on user input.
|
||||
- [ ] test_rate_limiting.sh: Tests the rate limiting implementation using curl or similar tools.
|
||||
- [ ] deploy_rate_limiting.sh: Deploys the rate limiting configuration to the API gateway or server.
|
||||
42
skills/skill-adapter/scripts/helper-template.sh
Executable file
42
skills/skill-adapter/scripts/helper-template.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
# Helper script template for skill automation
|
||||
# Customize this for your skill's specific needs
|
||||
|
||||
set -e
|
||||
|
||||
function show_usage() {
|
||||
echo "Usage: $0 [options]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -h, --help Show this help message"
|
||||
echo " -v, --verbose Enable verbose output"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Parse arguments
|
||||
VERBOSE=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_usage
|
||||
exit 0
|
||||
;;
|
||||
-v|--verbose)
|
||||
VERBOSE=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
show_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Your skill logic here
|
||||
if [ "$VERBOSE" = true ]; then
|
||||
echo "Running skill automation..."
|
||||
fi
|
||||
|
||||
echo "✅ Complete"
|
||||
32
skills/skill-adapter/scripts/validation.sh
Executable file
32
skills/skill-adapter/scripts/validation.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# Skill validation helper
|
||||
# Validates skill activation and functionality
|
||||
|
||||
set -e
|
||||
|
||||
echo "🔍 Validating skill..."
|
||||
|
||||
# Check if SKILL.md exists
|
||||
if [ ! -f "../SKILL.md" ]; then
|
||||
echo "❌ Error: SKILL.md not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate frontmatter
|
||||
if ! grep -q "^---$" "../SKILL.md"; then
|
||||
echo "❌ Error: No frontmatter found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check required fields
|
||||
if ! grep -q "^name:" "../SKILL.md"; then
|
||||
echo "❌ Error: Missing 'name' field"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q "^description:" "../SKILL.md"; then
|
||||
echo "❌ Error: Missing 'description' field"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Skill validation passed"
|
||||
Reference in New Issue
Block a user