Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计通过

error-messages错误信息

Agent Skill

error-messages 用于记录任务执行中的错误、用户纠正、经验和能力缺口,适合在 Codex、Claude、Cursor、Gemini CLI 中希望让 Agent 持续沉淀问题、修正和最佳实践时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

582

周安装

25

GitHub Stars

4,435

下载量

204
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:error-messages(错误信息)
来源仓库:https://github.com/github/gh-aw
仓库路径:skills/error-messages
安装命令:
npx skills add https://github.com/github/gh-aw --skill error-messages
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/github/gh-aw --skill error-messages

简介

error-messages 遵循 gh-aw 项目的错误信息风格指南,确保验证错误清晰且可操作。

  • 适用于命令行工具或 Web API 中返回结构化的错误响应。
  • 要求每条错误回答三个问题:什么问题、期望什么格式、如何修正。
  • 安装方式:通过 npx 从 GitHub 仓库添加,通常作为开发规范参考而非执行工具。
  • 禁止暴露内部错误细节,所有原始信息应仅用于服务端日志。

SKILL.md

Error Message Style Guide

This guide establishes the standard format for validation error messages in the gh-aw codebase. All validation errors should be clear, actionable, and include examples.

Error Message Template

[what's wrong]. [what's expected]. [example of correct usage]

Each error message should answer three questions:

  1. What's wrong? - Clearly state the validation error
  2. What's expected? - Explain the valid format or values
  3. How to fix it? - Provide a concrete example of correct usage

Good Examples

These examples follow the template and provide actionable guidance:

Time Delta Validation (from time_delta.go)

return nil, fmt.Errorf("invalid time delta format: +%s. Expected format like +25h, +3d, +1w, +1mo, +1d12h30m", deltaStr)

Why it's good:

  • Clearly identifies the invalid input
  • Lists multiple valid format examples
  • Shows combined formats (+1d12h30m)

Type Validation with Example

return "", fmt.Errorf("manual-approval value must be a string, got %T. Example: manual-approval: \"production\"", val)

Why it's good:

  • Shows actual type received (%T)
  • Provides concrete YAML example
  • Uses proper YAML syntax with quotes

Enum Validation with Options

return fmt.Errorf("invalid engine: %s. Valid engines are: copilot, claude, codex, custom. Example: engine: copilot", engineID)

Why it's good:

  • Lists all valid options
  • Provides simplest example
  • Uses consistent formatting

MCP Configuration

return fmt.Errorf("tool '%s' mcp configuration must specify either 'command' or 'container'. Example:\ntools:\n  %s:\n    command: \"npx @my/tool\"", toolName, toolName)

Why it's good:

  • Explains mutual exclusivity
  • Shows realistic tool name
  • Formats multi-line YAML example

Bad Examples

These examples lack clarity or actionable guidance:

Too Vague

return fmt.Errorf("invalid format")

Problems:

  • Doesn't specify what format is invalid
  • Doesn't explain expected format
  • No example provided

Missing Example

return fmt.Errorf("manual-approval value must be a string")

Problems:

  • States requirement but no example
  • User doesn't know proper YAML syntax
  • Could be clearer about type received

Incomplete Information

return fmt.Errorf("invalid engine: %s", engineID)

Problems:

  • Doesn't list valid options
  • No guidance on fixing the error
  • User must search documentation

When to Include Examples

Always include examples for:

  1. Format/Syntax Errors - Show the correct syntax fmt.Errorf("invalid date format. Expected: YYYY-MM-DD HH:MM:SS. Example: 2024-01-15 14:30:00")
  2. Enum/Choice Fields - List all valid options fmt.Errorf("invalid permission level: %s. Valid levels: read, write, none. Example: permissions:\n contents: read", level)
  3. Type Mismatches - Show expected type and example fmt.Errorf("timeout-minutes must be an integer, got %T. Example: timeout-minutes: 10", value)
  4. Complex Configurations - Provide complete valid example fmt.Errorf("invalid MCP server config. Example:\nmcp-servers:\n my-server:\n command: \"node\"\n args: [\"server.js\"]")

When Examples May Be Optional

Examples can be omitted when:

  1. Error is from wrapped error - When wrapping another error with context return fmt.Errorf("failed to parse configuration: %w", err)
  2. Error is self-explanatory with clear context return fmt.Errorf("duplicate unit '%s' in time delta: +%s", unit, deltaStr)
  3. Error points to specific documentation return fmt.Errorf("unsupported feature. See https://docs.example.com/features")

Formatting Guidelines

Use Type Verbs for Dynamic Content

  • %s - strings
  • %d - integers
  • %T - type of value
  • %v - general value
  • %w - wrapped errors

Multi-line Examples

For YAML configuration examples spanning multiple lines:

fmt.Errorf("invalid config. Example:\ntools:\n  github:\n    mode: \"remote\"")

Quoting in Examples

Use proper YAML syntax in examples:

// Good - shows quotes when needed
fmt.Errorf("Example: name: \"my-workflow\"")

// Good - shows no quotes for simple values
fmt.Errorf("Example: timeout-minutes: 10")

Consistent Terminology

Use the same field names as in YAML:

// Good - matches YAML field name
fmt.Errorf("timeout-minutes must be positive")

// Bad - uses different name
fmt.Errorf("timeout must be positive")

Error Message Testing

All improved error messages should have corresponding tests:

func TestErrorMessageQuality(t *testing.T) {
    err := validateSomething(invalidInput)
    require.Error(t, err)

    // Error should explain what's wrong
    assert.Contains(t, err.Error(), "invalid")

    // Error should include expected format or values
    assert.Contains(t, err.Error(), "Expected")

    // Error should include example
    assert.Contains(t, err.Error(), "Example:")
}

Migration Strategy

When improving existing error messages:

  1. Identify the error - Find validation error that lacks clarity
  2. Analyze context - Understand what's being validated
  3. Apply template - Add what's wrong + expected + example
  4. Add tests - Verify error message content
  5. Update comments - Document the validation logic

Examples by Category

Format Validation

// Time deltas
fmt.Errorf("invalid time delta format: +%s. Expected format like +25h, +3d, +1w, +1mo, +1d12h30m", input)

// Dates
fmt.Errorf("invalid date format: %s. Expected: YYYY-MM-DD or relative like -1w. Example: 2024-01-15 or -7d", input)

// URLs
fmt.Errorf("invalid URL format: %s. Expected: https:// URL. Example: https://api.example.com", input)

Type Validation

// Boolean expected
fmt.Errorf("read-only must be a boolean, got %T. Example: read-only: true", value)

// String expected
fmt.Errorf("workflow name must be a string, got %T. Example: name: \"my-workflow\"", value)

// Object expected
fmt.Errorf("permissions must be an object, got %T. Example: permissions:\n  contents: read", value)

Choice/Enum Validation

// Engine selection
fmt.Errorf("invalid engine: %s. Valid engines: copilot, claude, codex, custom. Example: engine: copilot", id)

// Permission levels
fmt.Errorf("invalid permission level: %s. Valid levels: read, write, none. Example: contents: read", level)

// Tool modes
fmt.Errorf("invalid mode: %s. Valid modes: local, remote. Example: mode: \"remote\"", mode)

Configuration Validation

// Missing required field
fmt.Errorf("tool '%s' missing required 'command' field. Example:\ntools:\n  %s:\n    command: \"node server.js\"", name, name)

// Mutually exclusive fields
fmt.Errorf("cannot specify both 'command' and 'container'. Choose one. Example: command: \"node server.js\"")

// Invalid combination
fmt.Errorf("http MCP servers cannot use 'container' field. Example:\ntools:\n  my-http:\n    type: http\n    url: \"https://api.example.com\"")

References

  • Excellent example to follow: pkg/workflow/time_delta.go
  • Pattern inspiration: Go standard library error messages
  • Testing examples: pkg/workflow/*_test.go

Tools

When writing error messages, consider:

  • The user's perspective (what do they need to fix it?)
  • The context (where in the workflow is the error?)
  • The documentation (should we reference specific docs?)
  • The complexity (is multi-line example needed?)

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.8%
按下载量换算77

Claude

30.12%
按下载量换算61

Cursor

19.89%
按下载量换算41

Gemini CLI

9.48%
按下载量换算19

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills