dbos-golang – skill Lập trình cho agent AI
Hướng dẫn xây dựng ứng dụng Go đáng tin cậy, chịu lỗi với workflow bền vững DBOS. Dùng khi thêm DBOS vào mã Go hiện có, tạo workflow và step, hoặc dùng queue để kiểm soát đồng thời.
Cài skill dbos-golang bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/dbos-golang-9376c.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /dbos-golang – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/dbos-golang-9376c.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $dbos-golang – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/dbos-golang-9376c.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /dbos-golang – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/dbos-golang-9376c.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /dbos-golang – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
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
Reliability and version boundaries
Pin and verify the DBOS Go SDK version before adapting these illustrative fragments; the current SDK documentation uses dbos.Context while this snapshot uses dbos.DBOSContext. Helpers, imports, registrations and application-specific functions are omitted. Do not claim snippets compile as a complete app. Check every returned error before using a handle or result. Workflow IDs and checkpointed steps do not make external payment/API side effects exactly-once: a crash after the remote action but before checkpointing can replay it. Use provider idempotency keys and reconciliation. Authenticate and deduplicate webhook messages before Send; scope workflow access to the caller. Queue limits govern workflow starts, not every request/retry inside a workflow. Cancellation cannot undo committed effects. Keep workflow inputs, outputs and error payloads free of secrets/unnecessary personal data. Do not enable admin endpoints, schedules, paid calls or management mutations without authorization.
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:
go get github.com/dbos-inc/dbos-transact-golang/dbos@latestDBOS Configuration and Launch
A DBOS application MUST create a context, register workflows, and launch before running any workflows:
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:
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.RunWorkflowwith queues ordbos.Go/dbos.Selectfor 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.mdReferences
- https://docs.dbos.dev/
- https://github.com/dbos-inc/dbos-transact-golang
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Skill liên quan
- dbos-python – Hướng dẫn xây dựng ứng dụng Python đáng tin cậy, chịu lỗi với workflow bền vững DBOS…
- dbos-typescript – Hướng dẫn xây dựng ứng dụng TypeScript đáng tin cậy, chịu lỗi với workflow bền vững…
- ddd-tactical-patterns – Áp dụng các mẫu chiến thuật DDD trong code với entity, value object, aggregate…
- monorepo-navigator – Điều hướng, quản lý và tối ưu monorepo. Bao gồm Turborepo, Nx, pnpm workspaces và Lerna…
- debate-review – Đánh giá PR bằng tranh luận giữa hai mô hình cho GitHub PR, GitLab MR, Azure DevOps PR…
- debug-buttercup – Mọi pod chạy trong namespace crs. Dùng khi pod trong namespace crs ở trạng thái…
- debugger – Chuyên gia gỡ lỗi cho lỗi, test thất bại và hành vi không mong đợi. Chủ động dùng khi…
- debugging-and-error-recovery – Hướng dẫn gỡ lỗi có hệ thống để tìm nguyên nhân gốc rễ. Dùng khi test thất bại, build bị…