go-test

A Go testing command that follows test-driven development, or TDD: write a failing test, implement the smallest change that passes it, then improve the code.

In plain words
What is it for?
Use it for new Go functions, bug fixes, core logic, or increasing test coverage with table-driven tests and coverage checks.
Why use it?
It makes expected behaviour explicit before implementation and helps catch regressions while new Go code is being built.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/codelably/harmony-claude-code/go-test
Clone the repo
git clone --depth 1 https://github.com/codelably/harmony-claude-code
Per session 50 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,720 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00050 $0.01720
Opus 5 $0.00025 $0.00860
Sonnet 5 $0.00010 $0.00344
Haiku 4.5 $0.00005 $0.00172

Measured yesterday against content hash 82b25f783f97, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

go-test scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/go-test.md · 269 lines

How it starts

The opening of the file, as written. The whole thing — 269 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Go TDD 命令

此命令使用地道的 Go 测试模式为 Go 代码强制执行测试驱动开发(Test-Driven Development,TDD)方法论。

此命令的作用

  1. 定义类型/接口:首先搭建函数签名的支架
  2. 编写表驱动测试(Table-Driven Tests):创建全面的测试用例(RED/红灯)
  3. 运行测试:验证测试因预期的原因失败
  4. 实现代码:编写通过测试所需的最少代码(GREEN/绿灯)
  5. 重构(Refactor):在保持测试通过的同时优化代码
  6. 检查覆盖率:确保 80% 以上的覆盖率

何时使用

在以下场景使用 /go-test

  • 实现新的 Go 函数
  • 为现有代码增加测试覆盖率
  • 修复 Bug(先编写失败的测试)
  • 构建核心业务逻辑
  • 在 Go 中学习 TDD 工作流(Workflow)

TDD 周期

RED(红灯)      → 编写失败的表驱动测试
GREEN(绿灯)    → 实现通过测试所需的最少代码
REFACTOR(重构) → 优化代码,保持测试通过
REPEAT(循环)   → 下一个测试用例

会话示例

User: /go-test 我需要一个验证电子邮件地址的函数

Agent:
# TDD 会话:电子邮件验证器

## 第 1 步:定义接口

```go
// validator/email.go
package validator

// ValidateEmail 检查给定的字符串是否为有效的电子邮件地址。
// 如果有效返回 nil,否则返回描述问题的错误。
func ValidateEmail(email string) error {
    panic("not implemented")
}

第 2 步:编写表驱动测试 (RED)

// validator/email_test.go
package validator

import (
    "testing"
)

func TestValidateEmail(t *testing.T) {
    tests := []struct {
        name    string
        email   string
        wantErr bool
    }{
        // 有效邮箱
        {"simple email", "[email protected]", false},
        {"with subdomain", "[email protected]", false},
        {"with plus", "[email protected]", false},
        {"with dots", "[email protected]", false},

        // 无效邮箱
        {"empty string", "", true},
        {"no at sign", "userexample.com", true},
        {"no domain", "user@", true},
        {"no local part", "@example.com", true},
        {"double at", "user@@example.com", true},
        {"spaces", "user @example.com", true},
        {"no tld", "user@example", true},
    }

    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            err := ValidateEmail(tt.email)
            if tt.wantErr && err == nil {
                t.Errorf("ValidateEmail(%q) = nil; want error", tt.email)
            }
            if !tt.wantErr && err != nil {
                t.Errorf("ValidateEmail(%q) = %v; want nil", tt.email, err)
            }
        })
    }
}

第 3 步:运行测试 - 验证失败

$ go test ./validator/...

Read the full file on GitHub · 269 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 269 lines · 50 tokens per session scan A 82b25f783f97

Subscribe to this mod's changes

go-test is a command published in the GitHub repository codelably/harmony-claude-code (42 stars, last pushed 6mo ago), licensed MIT. It adds 50 tokens to every session and 1,720 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.