Communitygithub.com

go测试模式

涵盖表格驱动测试、子测试、基准测试、模糊测试和测试覆盖率的Go测试模式。遵循TDD方法论和惯用的Go实践。在编写Go测试时使用——表格驱动用例、子测试、基准测试、模糊测试或覆盖率分析。

go测试模式 是什么?

本技能提供了一套完整的Go测试模式指南,旨在帮助开发者编写可靠、可维护的测试,并严格遵循测试驱动开发(TDD)方法论。它详细阐述了RED-GREEN-REFACTOR循环,并通过逐步示例和代码片段展示了如何在Go项目中实践TDD。该技能支持主流的Go测试平台和工具链,并覆盖了从基础单元测试到高级测试技术的方方面面。主要功能包括:表格驱动测试(Table-Driven Tests),这是Go中的标准测试模式,用于以最少的代码实现全面的覆盖;子测试和子基准测试(Subtests and Sub-benchmarks),用于组织相关的测试用例并支持并行执行;测试辅助函数(Test Helpers),如`t.Helper()`用于简化错误报告;黄金文件(Golden Files)测试,用于验证输出与预期文件是否一致;基于接口的模拟(Mocking with Interfaces)技术,用于隔离测试依赖;性能基准测试(Benchmarks),包括不同数据大小和内存分配的基准测试;Go 1.18+的模糊测试(Fuzzing),用于发现边界情况和漏洞;以及HTTP处理程序的测试(HTTP Handler Testing)。此外,还提供了关于测试覆盖率运行和排除生成代码的实用命令。该技能的核心理念是提倡通过清晰的测试结构、惯用的Go代码风格和全面的测试策略来提升代码质量和开发效率。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/golang-testing

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Go 测试模式

全面的 Go 测试模式,用于编写可靠、可维护的测试,遵循 TDD 方法论。

何时激活

  • 编写新的 Go 函数或方法
  • 为现有代码添加测试覆盖
  • 为性能关键代码创建基准测试
  • 实现用于输入验证的模糊测试
  • 在 Go 项目中遵循 TDD 工作流

Go 的 TDD 工作流

RED-GREEN-REFACTOR 循环

RED     → 首先编写一个失败的测试
GREEN   → 编写最少量的代码使测试通过
REFACTOR → 改进代码,同时保持测试通过
REPEAT  → 继续下一个需求

Go 中的逐步 TDD 实践

// 第1步:定义接口/签名
// calculator.go
package calculator

func Add(a, b int) int {
    panic("not implemented") // 占位符
}

// 第2步:编写失败的测试 (RED)
// calculator_test.go
package calculator

import "testing"

func TestAdd(t *testing.T) {
    got := Add(2, 3)
    want := 5
    if got != want {
        t.Errorf("Add(2, 3) = %d; want %d", got, want)
    }
}

// 第3步:运行测试 - 验证 FAIL
// $ go test
// --- FAIL: TestAdd (0.00s)
// panic: not implemented

// 第4步:实现最少量的代码 (GREEN)
func Add(a, b int) int {
    return a + b
}

// 第5步:运行测试 - 验证 PASS
// $ go test
// PASS

// 第6步:如果需要,重构代码,验证测试仍然通过

表格驱动测试

Go 测试的标准模式。以最少的代码实现全面的测试覆盖。

func TestAdd(t *testing.T) {
    tests := []struct {
        name     string
        a, b     int
        expected int
    }{
        {"positive numbers", 2, 3, 5},
        {"negative numbers", -1, -2, -3},
        {"zero values", 0, 0, 0},
        {"mixed signs", -1, 1, 0},
        {"large numbers", 1000000, 2000000, 3000000},
    }

    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            got := Add(tt.a, tt.b)
            if got != tt.expected {
                t.Errorf("Add(%d, %d) = %d; want %d",
                    tt.a, tt.b, got, tt.expected)
            }
        })
    }
}

带有错误情况的表格驱动测试

func TestParseConfig(t *testing.T) {
    tests := []struct {
        name    string
        input   string
        want    *Config
        wantErr bool
    }{
        {
            name:  "valid config",
            input: `{"host": "localhost", "port": 8080}`,
            want:  &Config{Host: "localhost", Port: 8080},
        },
        {
            name:    "invalid JSON",
            input:   `{invalid}`,
            wantErr: true,
        },
        {
            name:    "empty input",
            input:   "",
            wantErr: true,
        },
        {
            name:  "minimal config",
            input: `{}`,
            want:  &Config{}, // 零值配置
        },
    }

    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            got, err := ParseConfig(tt.input)

            if tt.wantErr {
                if err == nil {
                    t.Error("expected error, got nil")
                }
                return
            }

            if err != nil {
                t.Fatalf("unexpected error: %v", err)
            }

            if !reflect.DeepEqual(got, tt.want) {
                t.Errorf("got %+v; want %+v", got, tt.want)
            }
        })
    }
}

子测试和子基准测试

组织相关的测试

func TestUser(t *testing.T) {
    // 所有子测试共享的设置
    db := setupTestDB(t)

    t.Run("Create", func(t *testing.T) {
        user := &User{Name: "Alice"}
        err := db.CreateUser(user)
        if err != nil {
            t.Fatalf("CreateUser failed: %v", err)
        }
        if user.ID == "" {
            t.Error("expected user ID to be set")
        }
    })

    t.Run("Get", func(t *testing.T) {
        user, err := db.GetUser("alice-id")
        if err != nil {
            t.Fatalf("GetUser failed: %v", err)
        }
        if user.Name != "Alice" {
            t.Errorf("got name %q; want %q", user.Name, "Alice")
        }
    })

    t.Run("Update", func(t *testing.T) {
        // ...
    })

    t.Run("Delete", func(t *testing.T) {
        // ...
    })
}

并行子测试

func TestParallel(t *testing.T) {
    tests := []struct {
        name  string
        input string
    }{
        {"case1", "input1"},
        {"case2", "input2"},
        {"case3", "input3"},
    }

    for _, tt := range tests {
        tt := tt // 捕获范围变量
        t.Run(tt.name, func(t *testing.T) {
            t.Parallel() // 并行运行子测试
            result := Process(tt.input)
            // 断言...
            _ = result
        })
    }
}

测试辅助函数

辅助函数

func setupTestDB(t *testing.T) *sql.DB {
    t.Helper() // 标记此为辅助函数

    db, err := sql.Open("sqlite3", ":memory:")
    if err != nil {
        t.Fatalf("failed to open database: %v", err)
    }

    // 测试完成时清理
    t.Cleanup(func() {
        db.Close()
    })

    // 运行迁移
    if _, err := db.Exec(schema); err != nil {
        t.Fatalf("failed to create schema: %v", err)
    }

    return db
}

func assertNoError(t *testing.T, err error) {
    t.Helper()
    if err != nil {
        t.Fatalf("unexpected error: %v", err)
    }
}

func assertEqual[T comparable](t *testing.T, got, want T) {
    t.Helper()
    if got != want {
        t.Errorf("got %v; want %v", got, want)
    }
}

临时文件和目录

func TestFileProcessing(t *testing.T) {
    // 创建临时目录 - 自动清理
    tmpDir := t.TempDir()

    // 创建测试文件
    testFile := filepath.Join(tmpDir, "test.txt")
    err := os.WriteFile(testFile, []byte("test content"), 0644)
    if err != nil {
        t.Fatalf("failed to create test file: %v", err)
    }

    // 运行测试
    result, err := ProcessFile(testFile)
    if err != nil {
        t.Fatalf("ProcessFile failed: %v", err)
    }

    // 断言...
    _ = result
}

黄金文件

针对存储在 testdata/ 中的预期输出文件进行测试。

var update = flag.Bool("update", false, "update golden files")

func TestRender(t *testing.T) {
    tests := []struct {
        name  string
        input Template
    }{
        {"simple", Template{Name: "test"}},
        {"complex", Template{Name: "test", Items: []string{"a", "b"}}},
    }

    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            got := Render(tt.input)

            golden := filepath.Join("testdata", tt.name+".golden")

            if *update {
                // 更新黄金文件: go test -update
                err := os.WriteFile(golden, got, 0644)
                if err != nil {
                    t.Fatalf("failed to update golden file: %v", err)
                }
            }

            want, err := os.ReadFile(golden)
            if err != nil {
                t.Fatalf("failed to read golden file: %v", err)
            }

            if !bytes.Equal(got, want) {
                t.Errorf("output mismatch:\ngot:\n%s\nwant:\n%s", got, want)
            }
        })
    }
}

使用接口进行模拟

基于接口的模拟

// 为依赖项定义接口
type UserRepository interface {
    GetUser(id string) (*User, error)
    SaveUser(user *User) error
}

// 生产实现
type PostgresUserRepository struct {
    db *sql.DB
}

func (r *PostgresUserRepository) GetUser(id string) (*User, error) {
    // 真实的数据库查询
}

// 测试用模拟实现
type MockUserRepository struct {
    GetUserFunc  func(id string) (*User, error)
    SaveUserFunc func(user *User) error
}

func (m *MockUserRepository) GetUser(id string) (*User, error) {
    return m.GetUserFunc(id)
}

func (m *MockUserRepository) SaveUser(user *User) error {
    return m.SaveUserFunc(user)
}

// 使用模拟进行测试
func TestUserService(t *testing.T) {
    mock := &MockUserRepository{
        GetUserFunc: func(id string) (*User, error) {
            if id == "123" {
                return &User{ID: "123", Name: "Alice"}, nil
            }
            return nil, ErrNotFound
        },
    }

    service := NewUserService(mock)

    user, err := service.GetUserProfile("123")
    if err != nil {
        t.Fatalf("unexpected error: %v", err)
    }
    if user.Name != "Alice" {
        t.Errorf("got name %q; want %q", user.Name, "Alice")
    }
}

基准测试

基本基准测试

func BenchmarkProcess(b *testing.B) {
    data := generateTestData(1000)
    b.ResetTimer() // 不计入设置时间

    for i := 0; i < b.N; i++ {
        Process(data)
    }
}

// 运行: go test -bench=BenchmarkProcess -benchmem
// 输出: BenchmarkProcess-8   10000   105234 ns/op   4096 B/op   10 allocs/op

不同数据大小的基准测试

func BenchmarkSort(b *testing.B) {
    sizes := []int{100, 1000, 10000, 100000}

    for _, size := range sizes {
        b.Run(fmt.Sprintf("size=%d", size), func(b *testing.B) {
            data := generateRandomSlice(size)
            b.ResetTimer()

            for i := 0; i < b.N; i++ {
                // 创建副本以避免对已排序数据进行排序
                tmp := make([]int, len(data))
                copy(tmp, data)
                sort.Ints(tmp)
            }
        })
    }
}

内存分配基准测试

func BenchmarkStringConcat(b *testing.B) {
    parts := []string{"hello", "world", "foo", "bar", "baz"}

    b.Run("plus", func(b *testing.B) {
        for i := 0; i < b.N; i++ {
            var s string
            for _, p := range parts {
                s += p
            }
            _ = s
        }
    })

    b.Run("builder", func(b *testing.B) {
        for i := 0; i < b.N; i++ {
            var sb strings.Builder
            for _, p := range parts {
                sb.WriteString(p)
            }
            _ = sb.String()
        }
    })

    b.Run("join", func(b *testing.B) {
        for i := 0; i < b.N; i++ {
            _ = strings.Join(parts, "")
        }
    })
}

模糊测试 (Go 1.18+)

基本模糊测试

func FuzzParseJSON(f *testing.F) {
    // 添加种子语料库
    f.Add(`{"name": "test"}`)
    f.Add(`{"count": 123}`)
    f.Add(`[]`)
    f.Add(`""`)

    f.Fuzz(func(t *testing.T, input string) {
        var result map[string]interface{}
        err := json.Unmarshal([]byte(input), &result)

        if err != nil {
            // 无效的 JSON 对于随机输入是可预期的
            return
        }

        // 如果解析成功,重新编码应该工作
        _, err = json.Marshal(result)
        if err != nil {
            t.Errorf("Marshal failed after successful Unmarshal: %v", err)
        }
    })
}

// 运行: go test -fuzz=FuzzParseJSON -fuzztime=30s

多输入模糊测试

func FuzzCompare(f *testing.F) {
    f.Add("hello", "world")
    f.Add("", "")
    f.Add("abc", "abc")

    f.Fuzz(func(t *testing.T, a, b string) {
        result := Compare(a, b)

        // 属性: Compare(a, a) 应始终等于 0
        if a == b && result != 0 {
            t.Errorf("Compare(%q, %q) = %d; want 0", a, b, result)
        }

        // 属性: Compare(a, b) 和 Compare(b, a) 应有相反的符号
        reverse := Compare(b, a)
        if (result > 0 && reverse >= 0) || (result < 0 && reverse <= 0) {
            if result != 0 || reverse != 0 {
                t.Errorf("Compare(%q, %q) = %d, Compare(%q, %q) = %d; inconsistent",
                    a, b, result, b, a, reverse)
            }
        }
    })
}

测试覆盖率

运行覆盖率

# 基本覆盖率
go test -cover ./...

# 生成覆盖率文件
go test -coverprofile=coverage.out ./...

# 在浏览器中查看覆盖率
go tool cover -html=coverage.out

# 按函数查看覆盖率
go tool cover -func=coverage.out

# 使用竞态检测的覆盖率
go test -race -coverprofile=coverage.out ./...

覆盖率目标

代码类型目标
核心业务逻辑100%
公共 API90%+
通用代码80%+
生成的代码排除

从覆盖率中排除生成代码

//go:generate mockgen -source=interface.go -destination=mock_interface.go

// 在覆盖率配置文件中,使用构建标签排除:
// go test -cover -tags=!generate ./...

HTTP 处理程序测试

func TestHealthHandler(t *testing.T) {
    // 创建请求
    req := httptest.NewRequest(http.MethodGet, "/health", nil)
    w := httptest.NewRecorder()

    // 调用处理程序
    HealthHandler(w, req)

    // 检查响应
    resp := w.Result()
    defer resp.Body.Close()

    if resp.StatusCode != http.StatusOK {
        t.Errorf("got status %d; want %d", resp.StatusCode, http.StatusOK)
    }

    body, _ := io.ReadAll(resp.Body)
    if string(body) != "OK" {
        t.Errorf("got body %q; want %q", body, "OK")
    }
}

func TestAPIHandler(t *testing.T) {
    tests := []struct {
        name       string
        method     string
        path       string
        body       string
        wantStatus int
        wantBody   string
    }{
        {
            name:       "get user",
            method:     http.MethodGet,
            path:       "/users/123",
            wantStatus: http.StatusOK,
            wantBody:   `{"id":"123","name":"Alice"}`,
        },
        {
            name:       "not found",
            method:     http.MethodGet,
            path:       "/users/999",
            wantStatus: http.StatusNotFound,
        },
        {
            name:       "create user",
            method:     http.MethodPost,
            path:       "/users",
            body:       `{"name":"Bob"}`,
            wantStatus: http.StatusCreated,
        },
    }

    handler := NewAPIHandler()

    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            var bodyReader io.Reader
            if tt.body != "" {
                bodyReader = strings.NewReader(tt.body)
            }

            req := httptest.NewRequest(tt.method, tt.path, bodyReader)
            w := httptest.NewRecorder()

            handler.ServeHTTP(w, req)

            resp := w.Result()
            defer resp.Body.Close()

            if resp.StatusCode != tt.wantStatus {
                t.Errorf("got status %d; want %d", resp.StatusCode, tt.wantStatus)
            }

            if tt.wantBody != "" {
                body, _ := io.ReadAll(resp.Body)
                if string(body) != tt.wantBody {
                    t.Errorf("got body %q; want %q", body, tt.wantBody)
                }
            }
        })
    }
}

集成测试模式

使用测试容器

func TestPostgresIntegration(t *testing.T) {
    if testing.Short() {
        t.Skip("skipping integration test in short mode")
    }

    // 使用 testcontainers-go 启动 Postgres 容器
    ctx := context.Background()
    postgres, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
        ContainerRequest: testcontainers.ContainerRequest{
            Image: "postgres:15-alpine",
            Env: map[string]string{
                "POSTGRES_DB":       "testdb",
                "POSTGRES_PASSWORD": "testpass",
            },
            ExposedPorts: []string{"5432/tcp"},
            WaitingFor:   wait.ForLog("database system is ready to accept connections"),
        },
        Started: true,
    })
    if err != nil {
        t.Fatalf("failed to start postgres: %v", err)
    }
    defer postgres.Terminate(ctx)

    // 获取连接字符串
    host, _ := postgres.Host(ctx)
    port, _ := postgres.MappedPort(ctx, "5432")

    dsn := fmt.Sprintf("host=%s port=%d user=postgres password=testpass dbname=testdb sslmode=disable",
        host, port.Int())

    db, err := sql.Open("postgres", dsn)
    if err != nil {
        t.Fatalf("failed to open database: %v", err)
    }
    defer db.Close()

    // 运行测试...
}

测试环境变量依赖

type Config struct {
    DatabaseURL string
    APIKey      string
    Debug       bool
}

func configFromEnv() *Config {
    return &Config{
        DatabaseURL: os.Getenv("DATABASE_URL"),
        APIKey:      os.Getenv("API_KEY"),
        Debug:       os.Getenv("DEBUG") == "true",
    }
}

func TestConfigFromEnv(t *testing.T) {
    // 设置环境变量
    t.Setenv("DATABASE_URL", "postgres://localhost:5432/testdb")
    t.Setenv("API_KEY", "test-api-key-123")
    t.Setenv("DEBUG", "true")

    config := configFromEnv()

    if config.DatabaseURL != "postgres://localhost:5432/testdb" {
        t.Errorf("got DatabaseURL %q; want %q", config.DatabaseURL, "postgres://localhost:5432/testdb")
    }
    if config.APIKey != "test-api-key-123" {
        t.Errorf("got APIKey %q; want %q", config.APIKey, "test-api-key-123")
    }
    if !config.Debug {
        t.Error("expected Debug to be true")
    }
}

常见测试陷阱

避免全局状态污染

// 错误做法:修改全局变量
var config = loadConfig()

func TestConfig(t *testing.T) {
    config.Port = 9090 // 污染了其他测试
    // ...
}

// 正确做法:测试中使用局部配置
func TestConfig(t *testing.T) {
    cfg := &Config{Port: 9090}
    // ...
}

正确使用 t.Parallel()

// 错误做法:在循环中共享范围变量
func TestDataRace(t *testing.T) {
    tests := []struct {
        name string
        data int
    }{
        {"a", 1},
        {"b", 2},
    }

    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            t.Parallel()
            // 可能的数据竞争:在子测试运行时,tt 可能被修改
            _ = tt.data
        })
    }
}

// 正确做法:捕获循环变量
func TestNoDataRace(t *testing.T) {
    tests := []struct {
        name string
        data int
    }{
        {"a", 1},
        {"b", 2},
    }

    for _, tt := range tests {
        tt := tt // 捕获范围变量
        t.Run(tt.name, func(t *testing.T) {
            t.Parallel()
            _ = tt.data // 安全
        })
    }
}

正确处理 *testing.T 和 *testing.B

// 为测试和基准测试重用代码
func testProcess(t *testing.TB, input string) {
    t.Helper()
    result := Process(input)
    if result == nil {
        t.Fatal("Process returned nil")
    }
}

func TestProcess(t *testing.T) {
    testProcess(t, "test input")
}

func BenchmarkProcess(b *testing.B) {
    for i := 0; i < b.N; i++ {
        testProcess(b, "bench input")
    }
}

持续集成中的测试

GitHub Actions 的 Go 测试工作流

name: Go Tests
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: '1.22'
      - name: Run tests
        run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
      - name: Upload coverage
        uses: codecov/codecov-action@v3
        with:
          file: ./coverage.out

Makefile 目标

.PHONY: test test-race test-cover bench fuzz

test:
	go test -v ./...

test-race:
	go test -race ./...

test-cover:
	go test -coverprofile=coverage.out ./...
	go tool cover -html=coverage.out -o coverage.html

bench:
	go test -bench=. -benchmem ./...

fuzz:
	go test -fuzz=. -fuzztime=30s ./...

test-short:
	go test -short -v ./...

推荐包

包用途
testing标准库测试工具
net/http/httptestHTTP 处理程序测试
encoding/jsonJSON 序列化/反序列化
reflect深度比较 (reflect.DeepEqual)
testify流行的 Go 测试库,提供断言
gomock模拟框架
testcontainers-go集成测试容器

快速参考

# 运行所有测试
go test ./...

# 运行带有详细输出的测试
go test -v ./...

# 运行特定测试
go test -run TestAdd ./...

# 运行特定子测试
go test -run 'TestAdd/positive' ./...

# 运行基准测试
go test -bench=. ./...

# 运行模糊测试
go test -fuzz=. ./...

# 查看覆盖率
go test -cover ./...

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相关技能