dbos-golang
Guide for building reliable, fault-tolerant Go applications with DBOS durable workflows. Use when adding DBOS to existing Go code, creating workflows and steps, or using queues for concurrency control.
About this skill
This skill acts as an essential knowledge base for AI agents tasked with developing or enhancing Go applications using DBOS durable workflows. It provides detailed best practices and architectural guidance to ensure high reliability and fault tolerance. The skill covers crucial aspects such as seamlessly integrating DBOS into existing Go projects, designing robust workflows and individual steps, implementing sophisticated concurrency control mechanisms using DBOS queues, and managing inter-workflow communication through events, messages, and streams. Furthermore, it guides the agent on proper configuration and launching of DBOS applications, interacting with DBOS from external clients, and strategic testing of DBOS-enabled applications. By leveraging this skill, an AI agent can generate well-architected, production-ready Go applications that fully capitalize on DBOS's capabilities for durability and resilience.
Best use case
An AI agent is prompted to create a new Go application requiring strong fault tolerance and durability, or to refactor an existing Go codebase to incorporate DBOS durable workflows and adhere to best practices for resilience and concurrency.
Guide for building reliable, fault-tolerant Go applications with DBOS durable workflows. Use when adding DBOS to existing Go code, creating workflows and steps, or using queues for concurrency control.
The AI agent will generate Go code that correctly implements DBOS durable workflows, adheres to established best practices for reliability and fault tolerance, and effectively leverages DBOS features like queues and communication mechanisms. The resulting application will be well-structured, testable, robust, and resilient to failures.
Practical example
Example input
Develop a highly available Go service for an e-commerce platform that handles order processing, payment confirmation, and inventory updates using DBOS durable workflows. Ensure that payment processing is idempotent and inventory updates are concurrent-safe. Outline the architecture and key DBOS components.
Example output
```json
{
"explanation": "To construct a highly available e-commerce service with DBOS, I will design an 'OrderFulfillment' workflow. This will involve defining durable steps, employing queues for concurrency, and using events for inter-service communication, all guided by the 'dbos-golang' best practices.",
"go_code_plan_summary": {
"workflow_definition": "Define an `OrderFulfillment` workflow (e.g., `func OrderFulfillmentWorkflow(ctx context.Context, orderID string) error`) marked with `@DBOSWorkflow`.",
"steps_breakdown": [
"**Step 1: ProcessOrderPlacement** (Initial step): Validate and persist the order details. This step would be idempotent and use DBOS transactions.",
"**Step 2: HandlePayment** (Durable step): Use a DBOS queue (e.g., `dbos.Queue` with a unique payment ID) to ensure only one payment attempt per order, making it idempotent. This step would interact with a payment gateway.",
"**Step 3: UpdateInventory** (Durable step): Secure concurrent inventory updates using another DBOS queue or mutex to prevent overselling. Update stock levels based on the order.",
"**Step 4: NotifyCustomer** (Durable step): Publish a `dbos.Event` or send a `dbos.Message` to notify the customer of order status (e.g., 'Order Confirmed', 'Payment Failed')."
],
"concurrency_strategy": "For `HandlePayment` and `UpdateInventory`, utilize DBOS durable queues. The queue ensures that operations for a given order or item are processed sequentially, preventing race conditions and ensuring idempotency.",
"communication_strategy": "Leverage `dbos.EventPublish` for asynchronous notifications to other microservices (e.g., shipping, analytics) or directly to the customer communication service after critical steps are completed.",
"error_handling_and_retries": "Implement retry logic for transient errors within steps via DBOS's built-in capabilities. For business logic failures (e.g., payment declined), design compensation workflows or error-specific events.",
"testing_recommendations": "Employ DBOS testing tools to simulate failures at various workflow steps, verify transactional integrity, and confirm correct event propagation and queue behavior."
},
"additional_guidelines_applied": [
"Ensure all workflow steps are designed to be idempotent to handle retries gracefully.",
"Utilize DBOS's transactional guarantees for all state changes within steps.",
"Configure DBOS application settings for optimal performance and resilience, including database connection pooling and logging."
]
}
```When to use this skill
- Adding DBOS to existing Go code
- Creating workflows and steps within a DBOS application
- Using queues for concurrency control in Go applications
- Implementing workflow communication (events, messages, streams) with DBOS
When not to use this skill
- When the development task does not involve Go programming or DBOS durable workflows.
- For tasks primarily focused on front-end development, unrelated database interactions, or other domains outside of backend application reliability with DBOS in Go.
- When an agent needs to directly execute DBOS operations rather than understanding how to build or integrate them into a Go application.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/dbos-golang/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How dbos-golang Compares
| Feature / Agent | dbos-golang | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | easy | N/A |
Frequently Asked Questions
What does this skill do?
Guide for building reliable, fault-tolerant Go applications with DBOS durable workflows. Use when adding DBOS to existing Go code, creating workflows and steps, or using queues for concurrency control.
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as easy. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# DBOS Go Best Practices
Guide for building reliable, fault-tolerant Go applications with DBOS durable workflows.
## When to Use
Reference these guidelines when:
- Adding DBOS to existing Go code
- Creating workflows and steps
- Using queues for concurrency control
- Implementing workflow communication (events, messages, streams)
- Configuring and launching DBOS applications
- Using the DBOS Client from external applications
- Testing DBOS applications
## Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Lifecycle | CRITICAL | `lifecycle-` |
| 2 | Workflow | CRITICAL | `workflow-` |
| 3 | Step | HIGH | `step-` |
| 4 | Queue | HIGH | `queue-` |
| 5 | Communication | MEDIUM | `comm-` |
| 6 | Pattern | MEDIUM | `pattern-` |
| 7 | Testing | LOW-MEDIUM | `test-` |
| 8 | Client | MEDIUM | `client-` |
| 9 | Advanced | LOW | `advanced-` |
## Critical Rules
### Installation
Install the DBOS Go module:
```bash
go get github.com/dbos-inc/dbos-transact-golang/dbos@latest
```
### DBOS Configuration and Launch
A DBOS application MUST create a context, register workflows, and launch before running any workflows:
```go
package main
import (
"context"
"log"
"os"
"time"
"github.com/dbos-inc/dbos-transact-golang/dbos"
)
func main() {
ctx, err := dbos.NewDBOSContext(context.Background(), dbos.Config{
AppName: "my-app",
DatabaseURL: os.Getenv("DBOS_SYSTEM_DATABASE_URL"),
})
if err != nil {
log.Fatal(err)
}
defer dbos.Shutdown(ctx, 30*time.Second)
dbos.RegisterWorkflow(ctx, myWorkflow)
if err := dbos.Launch(ctx); err != nil {
log.Fatal(err)
}
}
```
### Workflow and Step Structure
Workflows are comprised of steps. Any function performing complex operations or accessing external services must be run as a step using `dbos.RunAsStep`:
```go
func fetchData(ctx context.Context) (string, error) {
resp, err := http.Get("https://api.example.com/data")
if err != nil {
return "", err
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
return string(body), nil
}
func myWorkflow(ctx dbos.DBOSContext, input string) (string, error) {
result, err := dbos.RunAsStep(ctx, fetchData, dbos.WithStepName("fetchData"))
if err != nil {
return "", err
}
return result, nil
}
```
### Key Constraints
- Do NOT start or enqueue workflows from within steps
- Do NOT use uncontrolled goroutines to start workflows - use `dbos.RunWorkflow` with queues or `dbos.Go`/`dbos.Select` for concurrent steps
- Workflows MUST be deterministic - non-deterministic operations go in steps
- Do NOT modify global variables from workflows or steps
- All workflows and queues MUST be registered before calling `Launch()`
## How to Use
Read individual rule files for detailed explanations and examples:
```
references/lifecycle-config.md
references/workflow-determinism.md
references/queue-concurrency.md
```
## References
- https://docs.dbos.dev/
- https://github.com/dbos-inc/dbos-transact-golangRelated Skills
grpc-golang
Build production-ready gRPC services in Go with mTLS, streaming, and observability. Use when designing Protobuf contracts with Buf or implementing secure service-to-service transport.
dbos-python
Guide for building reliable, fault-tolerant Python applications with DBOS durable workflows. Use when adding DBOS to existing Python code, creating workflows and steps, or using queues for concurrency control.
nft-standards
Master ERC-721 and ERC-1155 NFT standards, metadata best practices, and advanced NFT features.
nextjs-app-router-patterns
Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.
new-rails-project
Create a new Rails project
networkx
NetworkX is a Python package for creating, manipulating, and analyzing complex networks and graphs.
network-engineer
Expert network engineer specializing in modern cloud networking, security architectures, and performance optimization.
nestjs-expert
You are an expert in Nest.js with deep knowledge of enterprise-grade Node.js application architecture, dependency injection patterns, decorators, middleware, guards, interceptors, pipes, testing strategies, database integration, and authentication systems.
nerdzao-elite
Senior Elite Software Engineer (15+) and Senior Product Designer. Full workflow with planning, architecture, TDD, clean code, and pixel-perfect UX validation.
nerdzao-elite-gemini-high
Modo Elite Coder + UX Pixel-Perfect otimizado especificamente para Gemini 3.1 Pro High. Workflow completo com foco em qualidade máxima e eficiência de tokens.
native-data-fetching
Use when implementing or debugging ANY network request, API call, or data fetching. Covers fetch API, React Query, SWR, error handling, caching, offline support, and Expo Router data loaders (useLoaderData).
n8n-workflow-patterns
Proven architectural patterns for building n8n workflows.