Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:52:16 +08:00
commit 2d26d607e7
17 changed files with 1359 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
# Assets
Bundled resources for api-event-emitter skill
- [ ] event_schema_template.json: A template for defining event schemas in JSON format.
- [ ] docker-compose.yml: A Docker Compose file for setting up a local message queue for development and testing.
- [ ] example_events.json: A collection of example events that can be used to test the API.

View 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": []
}
}

View File

@@ -0,0 +1,56 @@
version: "3.9"
services:
# Message Queue Service (e.g., RabbitMQ)
message_queue:
image: rabbitmq:3.9-management-alpine # Or choose your preferred message queue and version
container_name: rabbitmq_server
ports:
- "5672:5672" # AMQP protocol port
- "15672:15672" # Management UI port (optional)
environment:
RABBITMQ_DEFAULT_USER: "guest" # REPLACE_ME: Change default user in production
RABBITMQ_DEFAULT_PASS: "guest" # REPLACE_ME: Change default password in production
RABBITMQ_DEFAULT_VHOST: "/"
volumes:
- rabbitmq_data:/var/lib/rabbitmq # Persist data across restarts (optional)
healthcheck:
test: ["CMD", "rabbitmqctl", "status"]
interval: 30s
timeout: 10s
retries: 5
# Optional: Event Streaming Platform (e.g., Kafka) - uncomment to include
# event_streaming:
# image: confluentinc/cp-kafka:latest
# container_name: kafka_server
# ports:
# - "9092:9092"
# environment:
# KAFKA_BROKER_ID: 1
# KAFKA_LISTENERS: PLAINTEXT://:9092
# KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092 # REPLACE_ME: Adjust for your environment
# KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
# depends_on:
# - zookeeper
# healthcheck:
# test: ["CMD", "kafka-topics", "--list", "--zookeeper", "zookeeper:2181"]
# interval: 30s
# timeout: 10s
# retries: 5
# Optional: Zookeeper (required for Kafka) - uncomment to include if using Kafka
# zookeeper:
# image: confluentinc/cp-zookeeper:latest
# container_name: zookeeper_server
# ports:
# - "2181:2181"
# environment:
# ZOOKEEPER_CLIENT_PORT: 2181
# ZOOKEEPER_TICK_TIME: 2000
# Define persistent volumes
volumes:
rabbitmq_data: # Named volume for RabbitMQ data persistence
# kafka_data: # Uncomment if using Kafka
# zookeeper_data: # Uncomment if using Zookeeper

View File

@@ -0,0 +1,69 @@
{
"_comment": "Template for defining event schemas in JSON format",
"schema_version": "1.0",
"event_name": "user.created",
"description": "Event triggered when a new user is created.",
"source": "user-service",
"timestamp": "2024-10-27T10:00:00Z",
"payload": {
"_comment": "Data associated with the user.created event",
"user_id": {
"type": "string",
"format": "uuid",
"description": "Unique identifier for the user"
},
"username": {
"type": "string",
"minLength": 3,
"maxLength": 50,
"description": "Username of the new user"
},
"email": {
"type": "string",
"format": "email",
"description": "Email address of the new user"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the user was created"
},
"profile": {
"type": "object",
"description": "User profile information",
"properties": {
"first_name": {
"type": "string",
"description": "First name of the user"
},
"last_name": {
"type": "string",
"description": "Last name of the user"
}
},
"required": [
"first_name",
"last_name"
]
}
},
"required": [
"user_id",
"username",
"email",
"created_at"
],
"examples": [
{
"_comment": "Example of a user.created event",
"user_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"username": "newuser123",
"email": "newuser@example.com",
"created_at": "2024-10-27T10:00:00Z",
"profile": {
"first_name": "John",
"last_name": "Doe"
}
}
]
}

View File

@@ -0,0 +1,62 @@
{
"_comment": "Example events for testing the API event emitter plugin",
"user_created": {
"_comment": "Event emitted when a new user is created",
"event_type": "user.created",
"data": {
"user_id": "user123",
"username": "johndoe",
"email": "john.doe@example.com",
"created_at": "2024-10-27T10:00:00Z"
}
},
"product_added": {
"_comment": "Event emitted when a new product is added to the catalog",
"event_type": "product.added",
"data": {
"product_id": "prod456",
"product_name": "Awesome Widget",
"description": "A fantastic widget for all your needs",
"price": 19.99,
"created_at": "2024-10-27T10:05:00Z"
}
},
"order_placed": {
"_comment": "Event emitted when a user places an order",
"event_type": "order.placed",
"data": {
"order_id": "order789",
"user_id": "user123",
"order_date": "2024-10-27T10:10:00Z",
"total_amount": 39.98,
"items": [
{
"product_id": "prod456",
"quantity": 2
}
]
}
},
"payment_processed": {
"_comment": "Event emitted when a payment is successfully processed",
"event_type": "payment.processed",
"data": {
"payment_id": "payment012",
"order_id": "order789",
"amount": 39.98,
"payment_date": "2024-10-27T10:15:00Z",
"payment_method": "credit_card",
"status": "success"
}
},
"user_updated": {
"_comment": "Event emitted when a user's profile is updated",
"event_type": "user.updated",
"data": {
"user_id": "user123",
"username": "john.doe.updated",
"email": "john.doe.updated@example.com",
"updated_at": "2024-10-27T10:20:00Z"
}
}
}

View 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)"
}
}
}

View 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"
}
}

View File

@@ -0,0 +1,7 @@
# References
Bundled resources for api-event-emitter skill
- [ ] event_driven_architecture_best_practices.md: A guide to designing and implementing event-driven APIs, including topics like event schema design, idempotency, and error handling.
- [ ] message_queue_configuration.md: Documentation on configuring popular message queues like RabbitMQ and Kafka.
- [ ] api_event_emitter_api_reference.md: Detailed API reference for the event emitter plugin, including endpoints, request/response formats, and error codes.

View 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

View 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

View File

@@ -0,0 +1,7 @@
# Scripts
Bundled resources for api-event-emitter skill
- [ ] generate_event_schema.py: Generates event schema based on user input or existing API definitions.
- [ ] deploy_event_queue.sh: Deploys a message queue (e.g., RabbitMQ, Kafka) using Docker or a cloud provider's CLI.
- [ ] test_event_emitter.py: Sends test events to the API and verifies that they are processed correctly.

View 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"

View 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"