一键导入
plan-error-catalogs
Error code constants, messages per WP
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Error code constants, messages per WP
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Test failure diagnosis, source code fixes, and regression detection
Environment verification, dependency installation, baseline test verification
Contract-first single-task implementation dispatched by Coder Coordinator
Integration test writing for component boundaries and external dependencies
Unit test writing and execution with coverage threshold enforcement
API reference documentation skill. Produces and updates API endpoint documentation from contract files in .sdd/docs/api-reference.md.
| name | plan-error-catalogs |
| description | Error code constants, messages per WP |
| argument-hint | Invoked by Planner Coordinator - do not call directly |
Phase: 2 (Contract Generation) Common contract:
.github/skills/PLAN-SKILL-CONTRACT.mdSpec refs: FR-048, FR-049, FR-050, FR-039
This skill is dispatched by the Planner Coordinator during Phase 2. It reads the plan accumulator and generates language-specific error catalog contract files scoped per work package.
| # | Input | Description |
|---|---|---|
| 1 | skill_path | Path to this SKILL.md file |
| 2 | plan_dir | Path to .sdd/plans/ directory |
| 3 | contracts_dir | Path to .sdd/plans/contracts/ directory |
| 4 | spec_path | Path to the source spec file |
| 5 | spec_artifacts_dir | Path to spec companion artifacts |
| 6 | research_summary | Key findings from the research phase |
| 7 | target_language | Programming language for contract generation |
| 8 | patterns | Active plan-domain patterns to avoid |
| 9 | phase | Phase indicator (always 2 for this skill) |
error-catalog.<ext> from spec_artifacts_dir. Read spec and artifact files in parallel.error-catalog.<ext> to contracts_dir/<WP-slug>/ per applicable WPRead the plan accumulator. For each WP, determine if it:
Skip WPs that:
Build the error-code-to-WP mapping:
AUTH_INVALID_TOKEN -> WP01
AUTH_EXPIRED_TOKEN -> WP01
USER_NOT_FOUND -> WP02
USER_ALREADY_EXISTS -> WP02
ORDER_INVALID_STATE -> WP03
Check if spec_artifacts_dir contains an error-catalog.<ext> file. If it exists:
If the spec artifact does NOT exist:
Process WPs in numerical order to determine error code ownership:
Build the ownership table:
| Error Code | Owner WP | Used by |
|---|---|---|
| AUTH_INVALID_TOKEN | WP01 | WP02, WP03 |
| USER_NOT_FOUND | WP02 | WP03 |
| VALIDATION_ERROR | WP01 | WP02, WP03, WP04 |
For each applicable WP, generate <contracts_dir>/<WP-slug>/error-catalog.<ext>:
// Generated by: plan-error-catalogs skill
// Source spec: <spec_path>
// Work package: WP<NN>-<slug>
// Target language: <target_language>
// DO NOT EDIT MANUALLY -- regenerated on plan revision
// TypeScript example
export const ErrorCodes = {
// Authentication errors
AUTH_INVALID_TOKEN: 'AUTH_001',
AUTH_EXPIRED_TOKEN: 'AUTH_002',
AUTH_INSUFFICIENT_PERMISSIONS: 'AUTH_003',
// User errors
USER_NOT_FOUND: 'USER_001',
USER_ALREADY_EXISTS: 'USER_002',
USER_INVALID_EMAIL: 'USER_003',
} as const;
export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
# Python example
from enum import Enum
class ErrorCode(str, Enum):
# Authentication errors
AUTH_INVALID_TOKEN = 'AUTH_001'
AUTH_EXPIRED_TOKEN = 'AUTH_002'
AUTH_INSUFFICIENT_PERMISSIONS = 'AUTH_003'
# User errors
USER_NOT_FOUND = 'USER_001'
USER_ALREADY_EXISTS = 'USER_002'
USER_INVALID_EMAIL = 'USER_003'
Error code format:
DOMAIN_DESCRIPTIVE_NAME for constant namesDOMAIN_NNN for code values (string-based, not numeric)Map each error code to its HTTP status:
export const ERROR_HTTP_STATUS: Record<ErrorCode, number> = {
[ErrorCodes.AUTH_INVALID_TOKEN]: 401,
[ErrorCodes.AUTH_EXPIRED_TOKEN]: 401,
[ErrorCodes.AUTH_INSUFFICIENT_PERMISSIONS]: 403,
[ErrorCodes.USER_NOT_FOUND]: 404,
[ErrorCodes.USER_ALREADY_EXISTS]: 409,
[ErrorCodes.USER_INVALID_EMAIL]: 422,
};
# Python example
ERROR_HTTP_STATUS: dict[ErrorCode, int] = {
ErrorCode.AUTH_INVALID_TOKEN: 401,
ErrorCode.AUTH_EXPIRED_TOKEN: 401,
ErrorCode.AUTH_INSUFFICIENT_PERMISSIONS: 403,
ErrorCode.USER_NOT_FOUND: 404,
ErrorCode.USER_ALREADY_EXISTS: 409,
ErrorCode.USER_INVALID_EMAIL: 422,
}
If the application is not HTTP-based (CLI, library), omit this mapping and note why.
export const ERROR_MESSAGES: Record<ErrorCode, string> = {
[ErrorCodes.AUTH_INVALID_TOKEN]: 'Authentication failed. Please log in again.',
[ErrorCodes.AUTH_EXPIRED_TOKEN]: 'Your session has expired. Please log in again.',
[ErrorCodes.AUTH_INSUFFICIENT_PERMISSIONS]: 'You do not have permission to perform this action.',
[ErrorCodes.USER_NOT_FOUND]: 'User not found.',
[ErrorCodes.USER_ALREADY_EXISTS]: 'A user with this email already exists.',
[ErrorCodes.USER_INVALID_EMAIL]: 'The email address provided is invalid.',
};
Message template rules:
'User {userId} not found'export const ERROR_LOG_MESSAGES: Record<ErrorCode, string> = {
[ErrorCodes.AUTH_INVALID_TOKEN]: 'Invalid token received. Token prefix: {tokenPrefix}',
[ErrorCodes.USER_NOT_FOUND]: 'User lookup failed. ID: {userId}, source: {source}',
[ErrorCodes.USER_ALREADY_EXISTS]: 'Duplicate user creation attempted. Email: {email}',
};
Internal messages:
When the same error code is used by multiple WPs, apply the first-WP-defines pattern:
shared/ -- shared/ is reserved for config-schema files written by plan-cross-wp-validation only (Section 7.2)Import syntax by language:
import { ErrorCodes } from '../WP01-slug/error-catalog';from ..wp01_slug.error_catalog import ErrorCodeReplace WP01-slug / wp01_slug with the actual slug of the owner WP.
If a WP's error catalog file exceeds 800 lines, split generation across multiple writes.
<contracts_dir>/<WP-slug>/error-catalog.<ext> -- do NOT write to shared/