---
name: go-validation
description: >-
  Validate Go formatting, linting, tests, and vulnerabilities for maintainable and secure code delivery.
  Use when committing Go changes, running CI validation, or debugging failing checks in repositories.
license: Apache-2.0
metadata:
  author: y-miyazaki
  version: "1.0.1"
---

## Input

- Go path or directory (required)
- Validation script (required): `scripts/validate.sh` (run from the go-validation skill directory)
- `--fix` (optional)
- `--verbose` (optional)

## Output Specification

Return structured Markdown in accordance with [references/common-output-format.md](references/common-output-format.md). That file is the source of truth for the output contract.

Structured validation results in fixed tool order.

## Execution Scope

- **Always use `scripts/validate.sh`** for comprehensive validation. Do not run individual commands.
- Individual commands are for debugging only (see [references/common-individual-commands.md](references/common-individual-commands.md)).
- **Do not modify source files** except `--fix` formatting.
- **Do not create or delete files**.

### USE FOR:

- run deterministic Go validation before commit or merge
- reproduce CI failures for Go format/lint/test/vulnerability checks
- verify coverage threshold and blocking validation status

### DO NOT USE FOR:

- perform architecture or design reviews
- generate new source code as a primary task
- validate non-Go projects

## Reference Files Guide

- [common-checklist.md](references/common-checklist.md) (always read)
- [common-output-format.md](references/common-output-format.md) (always read)
- [common-troubleshooting.md](references/common-troubleshooting.md) (read on failure)
- [common-individual-commands.md](references/common-individual-commands.md) (read on failure)
- [category-security.md](references/category-security.md) (read on failure)
- [category-testing.md](references/category-testing.md) (read on failure)

## Workflow

1. Run `bash scripts/validate.sh`.
2. For fast iteration, run `bash scripts/validate.sh <path>` where `<path>` is a Go package or directory.
3. Use `--verbose` to collect tool-level diagnostics.
4. Use `--fix` only for formatting issues, then review diffs.
5. Retry at most 2 times after fixes; if checks still fail, return blocking failures and stop.

### Error Handling

| Condition                             | Severity    | Action                                                                                                |
| ------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------- |
| `scripts/validate.sh` missing         | Fatal       | Stop; report missing script                                                                           |
| No Go files under target path         | Info        | Report no reviewable Go code; stop                                                                    |
| Single tool fails, others succeed     | Recoverable | Report passing tools; defer failed tool with exit status                                              |
| All tools fail                        | Fatal       | Return `status: failed` with per-tool stderr summaries                                                |
| `common-checklist.md` unavailable     | Fatal       | Stop; report missing dependency                                                                       |
| `common-output-format.md` unavailable | Recoverable | Note missing file; emit `## Checks Summary`, `## Checks (Failed/Deferred Only)`, and `## Issues` only |

### Examples

- Prompt: `Validate Go formatting, lint, tests, and vulnerabilities`
- Command: `bash scripts/validate.sh --verbose`
- Result: Structured report per [references/common-output-format.md](references/common-output-format.md) (per-tool pass/fail).
