跳到正文
cccskills
免费在 GitHub 公开

agent-ready-go

Prepares Go applications to work effectively with AI coding agents. Use when setting up a new Go project or retrofitting an existing one to ensure: structured JSON logging (slog/Zap/ZeroLog/Logrus), machine-readable command output, thorough golangci-lint configuration, non-interactive CLI design with --yes flags, structured error handling with meaningful exit codes, proper context.Context propagation, graceful shutdown, health check endpoints, and a standardized Makefile. Triggers when a user asks to make their Go app "agent-ready," "AI-friendly," wants to improve agent tooling/observability in a Go project, or needs to audit an existing Go project against agent-readiness best practices.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(8)

  • SKILL.md6.3 KB
  • assets/Makefile2.5 KB
  • references/config.md4.0 KB
  • references/error-handling.md5.6 KB
  • references/logging.md7.1 KB
  • references/non-interactive.md4.8 KB
  • references/services.md5.8 KB
  • references/testing.md6.5 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

<!-- Copyright 2025-2026 Richard Shade. Licensed under Apache-2.0. --> <!-- SPDX-License-Identifier: Apache-2.0 -->

Agent-Ready Go

Make Go applications work effectively with AI coding agents by ensuring all tooling produces machine-readable output, errors are structured, and commands run non-interactively by default.

Workflow

Making a Go app agent-ready involves these steps:

  1. Audit — identify gaps against the agent-readiness checklist
  2. Structured logging — add/configure slog, Zap, ZeroLog, or Logrus with JSON output
  3. Machine-readable output — ensure all commands can emit JSON
  4. Linting — add .golangci.yml with thorough config
  5. Testing — ensure go test -race -count=1 -timeout=5m with coverage thresholds
  6. Error handling — structured errors, meaningful exit codes
  7. Non-interactive design — --yes/-y flags, env vars over prompts
  8. Makefile — standardize build, test, lint, cover targets

For greenfield projects, apply all steps. For existing projects, run the audit first and address only what's missing.

Step 1: Audit

Run this checklist against the project. Address each ❌:

  • Structured logger configured (slog / Zap / ZeroLog / Logrus)
  • Logger outputs JSON when not a TTY or when LOG_FORMAT=json
  • CLI commands support --json or --output json flag
  • .golangci.yml exists with a thorough linter set
  • go test -race passes
  • Code coverage ≥ 80% enforced
  • go vet ./... passes clean
  • All errors wrapped with context (fmt.Errorf("...: %w", err))
  • Exit codes: 0 = success, non-zero = failure (no panics in CLI entry)
  • context.Context threaded through all I/O-bound functions
  • Interactive prompts have --yes/-y bypass flag
  • Makefile with build, test, lint, cover, ci targets
  • Graceful shutdown on SIGTERM/SIGINT (HTTP services)
  • Health check endpoints (/healthz, /readyz) for HTTP services
  • govulncheck ./... passes clean
  • NO_COLOR respected; no ANSI codes in non-TTY output
  • Config loaded from env vars with validation at startup

Step 2: Structured Logging

See references/logging.md for setup patterns for slog, Zap, ZeroLog, and Logrus.

Key requirements:

  • Use JSON format when !isatty(os.Stdout.Fd()) or LOG_FORMAT=json
  • Include fields: level, ts, msg, plus context fields
  • Never use fmt.Println for operational log output
  • Log to stderr; keep stdout clean for machine-readable data

Step 3: Machine-Readable Output

Agents parse stdout to validate results. Every non-trivial command must support JSON output.

var outputJSON bool
cmd.Flags().BoolVar(&outputJSON, "json", false, "output results as JSON")

if outputJSON {
    enc := json.NewEncoder(os.Stdout)
    enc.SetIndent("", "  ")
    _ = enc.Encode(result)
} else {
    fmt.Printf("Created: %s\n", result.Name)
}

Rule: structured data → stdout; progress/human messages → stderr.

fmt.Fprintln(os.Stderr, "Processing...")  // progress to stderr
json.NewEncoder(os.Stdout).Encode(result) // data to stdout

Step 4: Linting

Copy assets/.golangci.yml to the project root, then:

golangci-lint run ./...

Requires golangci-lint v1.59+ (v1.x series).

See references/testing.md for linter explanations and tuning guidance.

Step 5: Testing

See references/testing.md for full testing setup.

go test -race -count=1 -timeout=5m -coverprofile=coverage.out ./...
go tool cover -func=coverage.out | tail -1

Enforce minimum coverage in CI:

COVERAGE=$(go tool cover -func=coverage.out | tail -1 | awk '{print $3}' | tr -d '%')
[ $(echo "$COVERAGE >= 80" | bc -l) -eq 1 ] || { echo "Coverage ${COVERAGE}% < 80%"; exit 1; }

Step 6: Error Handling

See references/error-handling.md for structured error patterns and exit code conventions.

Quick rules:

  • Always wrap: fmt.Errorf("loading config: %w", err)
  • CLI main() catches all errors and exits with appropriate code
  • Never call os.Exit deep in business logic — return errors up
  • Never panic outside of init() / package-level setup

Step 7: Non-Interactive Design

See references/non-interactive.md for patterns.

Any prompt that blocks agent execution must have a --yes/-y bypass:

if !yes {
    confirmed, _ := promptConfirm("Delete all records?")
    if !confirmed {
        return nil
    }
}
// proceed

Step 8: Makefile

Copy assets/Makefile to the project root. Adjust BINARY_NAME and MAIN_PKG for the project.

Standard targets: make build, make test, make lint, make cover, make ci (runs full pipeline).

Resources

FileContents
references/logging.mdslog, Zap, ZeroLog, Logrus JSON setup
references/testing.mdRace detector, coverage, golangci-lint tuning
references/error-handling.mdStructured errors, exit codes, context
references/non-interactive.md--yes flags, env vars, stdin detection
references/services.mdHTTP graceful shutdown, health checks, OTel, request ID
references/config.mdConfiguration management, env var parsing, validation
assets/.golangci.ymlProduction-ready linter config
assets/MakefileStandard build/test/lint/cover targets

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Use when creating or updating AGENTS.md files, .github/copilot-instructions.md, or other AI agent rule files, onboarding AI agents to a project, standardizing agent documentation, or when anyone mentions AGENTS.md, agent rules, project onboarding, or codebase documentation for AI agents.

中文简介正在准备中。当前显示原文说明。

dirien/yet-another-agent-harness202026年5月31日 更新

Use when designing new high-level system architecture, reviewing existing designs, or making architectural decisions. Invoke to create architecture diagrams, write Architecture Decision Records (ADRs), evaluate technology trade-offs, design component interactions, and plan for scalability. Use for system design, architecture review, microservices structuring, ADR authoring, scalability planning, and infrastructure pattern selection — distinct from code-level design patterns or database-only design tasks.

中文简介正在准备中。当前显示原文说明。

dirien/yet-another-agent-harness202026年5月31日 更新

Use when building CLI tools, implementing argument parsing, or adding interactive prompts. Invoke for parsing flags and subcommands, displaying progress bars and spinners, generating bash/zsh/fish completion scripts, CLI design, shell completions, and cross-platform terminal applications using commander, click, typer, or cobra.

中文简介正在准备中。当前显示原文说明。

dirien/yet-another-agent-harness202026年5月31日 更新

Convert an AWS CloudFormation stack or template to Pulumi. This skill MUST be loaded whenever a user requests migration or conversion of CloudFormation to Pulumi.

中文简介正在准备中。当前显示原文说明。

dirien/yet-another-agent-harness202026年5月31日 更新

Analyzes code diffs and files to identify bugs, security vulnerabilities (SQL injection, XSS, insecure deserialization), code smells, N+1 queries, naming issues, and architectural concerns, then produces a structured review report with prioritized, actionable feedback. Use when reviewing pull requests, conducting code quality audits, identifying refactoring opportunities, or checking for security issues. Invoke for PR reviews, code quality checks, refactoring suggestions, review code, code quality. Complements specialized skills (security-reviewer, test-master) by providing broad-scope review across correctness, performance, maintainability, and test coverage in a single pass.

中文简介正在准备中。当前显示原文说明。

dirien/yet-another-agent-harness202026年5月31日 更新

commit

免费

Atomic, semantic-boundary git commit workflow

中文简介正在准备中。当前显示原文说明。

dirien/yet-another-agent-harness202026年5月31日 更新

查看 dirien 的全部技能

报告此技能的问题