Opencode helps users to effortlessly generate code snippets and automate repetitive tasks, enhancing productivity and creativity. Unlock your coding potential with this intuitive AI assistant, ideal for developers of all skill levels.
npx skills add sh/agentsOpencode is an AI-powered development skill that generates code snippets and automates repetitive coding tasks. Designed for developers at any experience level, it helps streamline workflow and boost productivity. The skill provides an intuitive interface to assist with common development challenges, allowing you to focus on higher-level problem-solving rather than routine coding work.
["Identify the specific coding task or repetitive development process you want to automate. Replace [TASK_DESCRIPTION] in the prompt with your exact requirement.","Specify the programming language or framework you're working with in the [LANGUAGE] placeholder. Include any relevant libraries or tools (e.g., 'Python with Prometheus client library').","Run the generated code in your development environment. Test the functionality thoroughly and verify the output matches your expectations.","For monitoring tasks, configure Prometheus to scrape the metrics endpoint (typically port 8000 in the example) and set up alerts if needed.","Iterate by refining the prompt with additional requirements like error handling, performance optimizations, or integration with other services."]
Generate code snippets
Automate repetitive tasks
Simplify debugging processes
npx skills add sh/agentsgit clone https://github.com/sh/agentsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Generate a [LANGUAGE] code snippet to [TASK_DESCRIPTION]. Include comments explaining key steps and best practices. For example: 'Generate a Python function that uses Prometheus client library to expose custom metrics for API response times. Include error handling and a sample query to test the metric.'
```python
from prometheus_client import start_http_server, Counter, Gauge
import time
import random
# Custom metrics for API monitoring
API_RESPONSE_TIME = Gauge('api_response_time_seconds', 'Time spent processing API requests')
API_ERROR_COUNT = Counter('api_errors_total', 'Total number of API errors', ['endpoint', 'error_type'])
API_REQUEST_COUNT = Counter('api_requests_total', 'Total number of API requests', ['endpoint'])
def simulate_api_call(endpoint):
"""Simulate an API call with variable response time and potential errors"""
API_REQUEST_COUNT.labels(endpoint=endpoint).inc()
# Simulate processing time between 0.1 and 2 seconds
start_time = time.time()
time.sleep(random.uniform(0.1, 2))
# Randomly introduce errors (20% chance)
if random.random() < 0.2:
error_type = random.choice(['timeout', 'validation_error', 'server_error'])
API_ERROR_COUNT.labels(endpoint=endpoint, error_type=error_type).inc()
raise Exception(f"API error: {error_type}")
API_RESPONSE_TIME.set(time.time() - start_time)
return {"status": "success", "data": f"Sample response for {endpoint}"}
if __name__ == '__main__':
# Start Prometheus metrics server on port 8000
start_http_server(8000)
print("Prometheus metrics server started on port 8000")
# Simulate API calls
endpoints = ['/users', '/products', '/orders']
while True:
endpoint = random.choice(endpoints)
try:
result = simulate_api_call(endpoint)
print(f"Success: {result}")
except Exception as e:
print(f"Error: {str(e)}")
time.sleep(1)
```
**Prometheus Query to Test Metrics:**
- `rate(api_requests_total[5m])` - Request rate over last 5 minutes
- `sum(api_response_time_seconds) by (endpoint)` - Total response time by endpoint
- `rate(api_errors_total[5m])` - Error rate over last 5 minutes
This snippet demonstrates how to instrument a Python application with Prometheus metrics, including custom gauges and counters for API monitoring. The metrics can be scraped by Prometheus and visualized in Grafana dashboards.Control SaaS spending with visibility and analytics
Automate your browser workflows effortlessly
Orchestrate workloads with multi-cloud support, job scheduling, and integrated service discovery features.
Design, document, and generate code for APIs with interactive tools for developers.
CI/CD automation with build configuration as code
Enhance performance monitoring and root cause analysis with real-time distributed tracing.
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan