AgentSkillsCN

test

运行带有覆盖率统计的 Go 测试,并深入分析测试失败的原因。适用于代码测试、变更验证,或评估测试覆盖率时使用。

SKILL.md
--- frontmatter
name: test
description: Run Go tests with coverage and analyze failures. Use when testing code, verifying changes, or checking test coverage.
argument-hint: "[package-path or test-name]"
allowed-tools: Bash(go test *), Bash(go vet *), Read, Grep, Glob

Run Go Tests

Run tests based on the argument provided:

Determine scope

  • No argument: run all tests with go test -v -cover ./...
  • Package path (e.g. ./internal/claude/): run go test -v -cover $ARGUMENTS
  • Test name (e.g. TestEncodePath): find the package containing the test, then run go test -v -run $ARGUMENTS ./...

Steps

  1. Run go vet on the target package first
  2. Run the tests with -v -cover flags
  3. If tests fail:
    • Read the failing test file and the source code it tests
    • Identify the root cause
    • Suggest a fix with specific code changes
  4. If all pass: report coverage percentage and any packages with low coverage (<70%)

Output format

Follow the project convention from CLAUDE.md:

  • [OK] for passing results
  • [X] for failures with details
  • [i] for coverage info