Skip to content
Back to skills

Go Microservice Dev

ASecurity

Use when implementing, modifying, scaffolding, generating, or testing a new product's Go microservice, backend feature, or standalone Go CLI/tooling binary using protobuf IDL, Kitex or similar RPC, Hertz or similar HTTP, Wire/DI, MySQL/GORM-style DAL, Redis, MQ, dynamic config, code generation, and focused tests. For reproduction, isolation, or root-cause debugging, use defect-diagnosis first; this skill owns the Go implementation/fix. Triggers also include "用 Go 写一个服务", "Go 后端怎么搞", "Kitex 接口...

  • 6 stars
  • 0 votes
  • 0 copies
  • 8 views
  • Added September 2, 2026
ai-agentspythongosqlnodenodejstestingdebuggingcode-reviewapidatabase

Works with

  • terminal
  • cli
  • api

Security analysis

A100/100

Pro scans all 20 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add ccoalm/ccl-skills --skill go-microservice-dev --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Go Microservice Dev?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Go Microservice Dev
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ccoalm-go-microservice-dev/badge)](https://www.skillsdirectory.com/skills/ccoalm-go-microservice-dev)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: go-microservice-dev
description: Use when implementing, modifying, scaffolding, generating, or testing a new product's Go microservice, backend feature, or standalone Go CLI/tooling binary using protobuf IDL, Kitex or similar RPC, Hertz or similar HTTP, Wire/DI, MySQL/GORM-style DAL, Redis, MQ, dynamic config, code generation, and focused tests. For reproduction, isolation, or root-cause debugging, use defect-diagnosis first; this skill owns the Go implementation/fix. Triggers also include "用 Go 写一个服务", "Go 后端怎么搞", "Kitex 接口怎么写", "GORM 加索引", "用 Go 写个命令行工具", "重构 Go 服务里的某文件/某类(局部)", "拆分 Go 服务中的大文件或大类", "refactor a file/class within a Go service".
---

# Go Microservice Dev

Use this for implementation of new backend products and services. It should adapt to the repo in front of you, but the workflow is independent of any prior codebase. After code/test edits, self-check and invoke `code-review` automatically before completion.

## Skill Routing

- Use this skill for implementation, scaffolding, code generation, handlers, RPC methods, DAL, Redis, MQ, jobs, external clients, DI, and tests.
- Use `product-rd-workflow` first when the request is an end-to-end product delivery workflow, product idea to implementation plan, release workflow, cross-skill coordination, bug postmortem, or durable process improvement.
- Use `defect-diagnosis` first when the task is to reproduce, isolate, instrument, fix, verify, or root-cause a backend defect, regression, repeated failure, review finding, or failing test.
- System design, service boundaries, contract strategy, storage ownership, reliability design, or architecture review without code changes must go to `software-architecture`.
- Use `testing-strategy` when the main question is which unit, integration, contract, or E2E layer should prove behavior; then return here for Go-specific implementation.
- Use `test-artifact-management` when the ask is about generating structured test cases from a Feishu requirements doc or codebase and tracking them in Feishu Bitable before implementation begins.
- Use codebase-specific skills only when the task is explicitly about an existing legacy/workspace repository.
- Development references should turn already-chosen architecture into code, tests, and generated artifacts. If a change requires choosing ownership, security model, source of truth, or release governance, first apply `software-architecture`.
- For money, billing, quota, permission, tenant/user data isolation, high-impact AI, repeated writes, async finality, or incident-explanation risk, apply `product-rd-workflow` high-risk resilience gates and route test-layer design through `testing-strategy`.
- When a change can alter what a client renders or which state, action, or decision path it offers—including strings/templates/config/flags and API/event/schema fields, enums, status/progress, permission/capability signals, defaults, or result shapes—load `../product-ui-ux-design/references/delivery-contract.md`, create the applicable full or lightweight record in that contract, and follow its canonical consumer-universe classification, design/test/client handoffs, and terminal-status rules.
- This Go owner returns only its `producer_record` delta: immutable binding, build/schema/config artifact identity, exact command/environment, and API/event/log/output observation.

- For a standalone Go CLI, this skill owns Go parser/library implementation mechanics. Any change to a user-facing command tree, subcommand, flag/default/action path, help/output/exit behavior, confirmation, progress, or recovery path also loads `terminal-cli-dev`, which owns the terminal contract and its UI/UX/testing handoff. Only internal parser refactors proven to preserve all user-visible semantics may skip that owner.

## Generalization Discipline

- Implement the repo in front of you, but do not import product nouns, service names, package paths, provider names, IDs, dashboards, or organization-specific habits from prior codebases.
- Convert domain-specific source patterns into reusable mechanics: handler shape, contract evolution, repository pattern, transaction boundary, cache key strategy, idempotency, job lease, config, observability, or test style.
- If an observed pattern only works for one product domain, discard it instead of turning it into a rule.
- Resolve conflicts by choosing the safer generic default: explicit contracts over hidden conventions, DB constraints over cache-only correctness, typed config over ad hoc strings, idempotent consumers over retry-only consumers, focused unit tests over live-infra tests by default, and fail-closed for auth/permission/data-integrity paths.
- Fuse patterns only when both are product-agnostic and reduce implementation ambiguity; otherwise keep the simpler rule.
- When adding or revising durable Go implementation guidance, check whether the lesson is generic backend service practice that should also update the sibling stack owners `python-service-dev` and `nodejs-service-dev`, or belongs in a shared workflow skill instead. Record each sibling as `update`, `unchanged`, or `route-to-shared` rather than leaving it unexamined. If the rule depends on Go tooling, protobuf/Kitex/Hertz, Go concurrency, or Go package layout, keep it here and do not force a Python or Node mirror.
- Example: if an existing project uses inline Redis keys but another wraps keys in typed builders, implement typed builders and discard inline string formatting as a reusable pattern.

## Development Workflow

Before editing code, generated files, migrations, configs, or tests, complete enough analysis and planning for the change to be reviewable. Scale the plan to risk: a simple low-risk single-package change can use a short inline plan; multi-file, contract-visible, data/schema, async, release, bug-fix, branch/MR, unclear-risk, or high-risk work needs explicit task split, acceptance checks, verification commands, rollback or stop conditions, and named handoffs to architecture, testing, or diagnosis skills before edits.

Repo-local agent contracts (`AGENTS.md` at the repo root and in source directories) are part of the delivery contract: when a change moves a stable boundary, generated surface, workflow, or directory-local rule, update the nearest contract in the same MR and keep coverage in sync per `product-rd-workflow`'s spec / repo-contract sync gate (tooling: `references/developer-tooling-patterns.md`).

1. Establish the target service shape.
   - Is this an HTTP API, internal RPC, worker/consumer, scheduled task, command-line tool, or shared library?
   - Identify the nearest `go.mod`, service entrypoint, config files, IDL, generated code, DI setup, and test commands.
   - Check whether tests are split into fast unit tests and infrastructure-dependent integration tests.

2. Start from contracts and data.
   - Update protobuf IDL before changing request/response shape.

3. Keep layers clean.
   - Transport layer: protocol mapping, validation, auth context, response mapping.
   - Application/service layer: use-case orchestration and transactions.
   - Domain layer: domain rules and invariants.
   - Infrastructure layer: DB, Redis, MQ, RPC/HTTP clients, object storage, third-party APIs.
   - Generated code: never hand-edit unless explicitly repairing generated output.

4. Wire dependencies explicitly.
   - Constructors should declare what they need.
   - Prefer small interfaces at boundaries where tests or adapters matter.

5. Verify at the right scope.
   - Run focused unit tests for changed packages.
   - When writing the test code itself (structure, naming, smells, fixtures, behavior-vs-state, coverage, isolation, table-driven parameterization), pick the matching § from the decision table in `testing-strategy/references/test-code-authoring-patterns.md`; enable the per-stack lint executors for its machine-decidable smells (conditional logic / sleep / assertion-free tests) per `testing-strategy/references/fitness-functions.md` §4.1.4 (e.g. `forbidigo` for `time.Sleep` in tests).
   - Run integration-ish tests for DB/Redis/MQ wrappers only when environment is available.
   - Apply **TC traceability** when tracking TCs (Bitable, `tc.Mark`, sidecar) and **import-graph deprecation checks** when removing symbols, methods, tests, or packages; read `references/quality-and-testing-patterns.md`.
   - Run codegen and formatting when generated inputs changed.
   - Keep fast tests deterministic; isolate tests that need live infrastructure, long sleeps, generated files, or external credentials.

## Implementation Rules

- Pass `context.Context` through all external calls. The carve-out is narrow and behavioral: only a function that is and stays side-effect-free — no external calls, goroutines, filesystem/env, clock/random, or logging/trace/tenant/feature lookup across its body and callees — may omit `ctx`. A mapper or helper that does, or later gains, any such call takes `ctx`. "ctx on external calls" is not "ctx on every function", but the test is behavior, not the name.
- Set timeouts for RPC/HTTP/DB/Redis/MQ operations.
- Honor an existing context deadline when it is shorter than the local default timeout.
- Use one canonical error model and convert errors at transport boundaries.
- Add or preserve trace/log id in inbound, outbound, and async execution paths.
- Use read/write DB separation if the service stack provides it.
- Use transactions for multi-step writes inside one database.
- Keep GORM/sqlx/raw SQL behind DAL or repository modules; handlers and application services should call intent-focused repository methods, not construct queries directly.
- Treat MQ delivery as at-least-once; consumers must be idempotent.
- Treat write retries as unsafe by default. Add automatic retry only when the operation has a durable idempotency key, unique constraint, state machine, dedupe table, or equivalent proof, and test duplicate submit/callback/MQ/job-restart behavior.
- For money, quota, entitlement, permission, tenant/user isolation, privacy, and sensitive state changes, fail closed on uncertainty and return the canonical error before side effects.
- Do not default missing tenant, actor, subject, or resource scope on high-risk paths. Reject before side effects unless the code is an explicit bootstrap, seed, or maintenance path with separate approval.
- Use Redis locks with unique values and compare-and-delete unlock.
- Keep config typed and environment-specific.
- Keep generated code reproducible with documented commands.
- When bumping shared dependencies or tagging multi-module repos that use local `replace`, read `references/release-ops-patterns.md`.

## Reference Loading

- For source provenance, current extraction boundary, and keep/merge/discard decisions, read `references/source-evidence-map.md` when auditing or re-extracting this skill.
- For feature implementation steps, read `references/feature-playbook.md`.
- For generated code, DB, Redis, MQ, and testing patterns, read `references/engineering-patterns.md`.
- For reliability, context, error handling, async jobs, and external calls, read `references/reliability-patterns.md`.
- For service setup, codegen commands, DI wiring, and test-target hygiene, read `references/scaffold-and-codegen.md`.
- For protobuf/IDL implementation, field numbering, enum/message patterns, generation commands, and compatibility tests, read `references/protobuf-contract-patterns.md`.
- For secret clients, service discovery clients, object storage, external HTTP clients, bounded concurrency, and dependency adapters, read `references/dependency-client-patterns.md`.
- For handler/service/DAL feature work, validation, transactions, pagination, and side effects, read `references/domain-feature-patterns.md`.
- For data access, local/Redis cache, locks, idempotency, and query design, read `references/data-access-patterns.md`.
- For public API auth, external app credentials, authorization-scope checks, callback verification, and audit behavior, read `references/public-api-integration-patterns.md`.
- For HTTP gateway handlers, generated route files, middleware hooks, request binding, response mapping, and generated HTTP clients, read `references/http-gateway-client-patterns.md`.
- For release-facing code, deployment config, health endpoints, canary checks, traffic config, approval tasks, and operations notifications, read `references/release-ops-patterns.md`.
- For test strategy, fakes/mocks, traffic replay, generated-output tests, and CI quality gates, read `references/quality-and-testing-patterns.md`.
- For cross-stack unit/integration/E2E test layer selection, fixtures, flake control, and CI gate design, use `testing-strategy`.
- For runtime middleware, context propagation, service discovery clients, logs, metrics, tracing, and request/response logging controls, read `references/observability-implementation-patterns.md`.
- For DDL-first DB implementation, generated models/DAL, sharding-safe queries, migrations, and transaction tests, read `references/db-schema-and-dal-patterns.md`.
- For Redis clients, key builders, local/distributed cache, CAS scripts, locks, rate limiting, counters, and task queues, read `references/redis-cache-lock-patterns.md`.
- For spreadsheet, CSV, file import/export jobs, row validation, slice processing, and error reports, read `references/bulk-import-export-patterns.md`.
- For durable task state machines, allowed transitions, duplicate delivery, retries, and terminal-state behavior, read `references/state-machine-task-patterns.md`.
- For MQ consumers, producers, typed payload decoding, dynamic activation, pre-handling, retry/drop behavior, and latency alerts, read `references/mq-consumer-patterns.md`.
- For audit logs, history records, redaction, async writes, and query APIs, read `references/audit-history-patterns.md`.
- For dynamic config schemas, rule validation, condition evaluation, routing, and rollout ratios, read `references/config-rule-routing-patterns.md`.
- For replay, shadow execution, response comparison, diff scoring, and replay result storage, read `references/replay-comparison-patterns.md`.
- For bounded concurrency, batch jobs, replay/shadow workers, DB performance guards, and stuck-task repair, read `references/performance-capacity-patterns.md`.
- For webhook or notification clients, templates, async delivery, retries, and alert throttling, read `references/notification-patterns.md`.
- For generated spreadsheets, PDFs, CSVs, reports, object upload, and download artifacts, read `references/artifact-generation-patterns.md`.
- For canonical errors, response builders, error wrapping, validation errors, and transport mapping, read `references/error-contract-patterns.md`.
- For developer CLIs, generators, DDL-to-model generation, generated file safety, and command tests, read `references/developer-tooling-patterns.md`.

Files in this skill

  • SKILL.md29.6 KB
  • agents/openai.yaml208 B
  • references/artifact-generation-patterns.md2 KB
  • references/audit-history-patterns.md3.8 KB
  • references/bulk-import-export-patterns.md4.1 KB
  • references/config-rule-routing-patterns.md2.1 KB
  • references/data-access-patterns.md3.6 KB
  • references/db-schema-and-dal-patterns.md10.8 KB
  • references/dependency-client-patterns.md17.5 KB
  • references/developer-tooling-patterns.md7.8 KB
  • references/domain-feature-patterns.md8 KB
  • references/engineering-patterns.md13.9 KB
  • references/error-contract-patterns.md8.2 KB
  • references/feature-playbook.md3 KB
  • references/http-gateway-client-patterns.md9.3 KB
  • references/mq-consumer-patterns.md4.8 KB
  • references/notification-patterns.md2.7 KB
  • references/observability-implementation-patterns.md10 KB
  • references/performance-capacity-patterns.md2.6 KB
  • references/protobuf-contract-patterns.md6.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.