error-model-validation-architect
Skill18 starsChanged 9 months agoMITView on GitHub
Design and implement consistent API validation and error-handling behavior for Kotlin plus Spring services. Use when defining error payloads, mapping framework and domain exceptions, standardizing HTTP status codes, adding `@ControllerAdvice`, preventing internal-detail leakage, or ensuring clients can rely on stable machine-readable error semantics across endpoints.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- JetBrains/skillsedited, first seen Apr 28, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- JetBrains/skills★ 36096% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository24 other files it gives its agents.
- ci-cd-containerization-advisorSkill
- configuration-properties-profiles-kotlin-safeSkill
- dependency-conflict-resolverSkill
- domain-decomposition-api-design-advisorSkill
- gradle-kotlin-dsl-doctorSkill
- integration-resilience-engineerSkill
- jackson-kotlin-serialization-specialistSkill
- java-kotlin-migration-assistantSkill
- jpa-spring-data-kotlin-mapperSkill
- kotlin-idiomatic-refactorer-spring-awareSkill
- kotlin-spring-proxy-compatibilitySkill
- observability-integratorSkill
- performance-concurrency-advisorSkill
- production-incident-responderSkill
- project-context-ingestionSkill
- schema-migration-plannerSkill
- spring-context-di-reasoningSkill
- spring-kotlin-code-reviewSkill
- spring-mvc-webflux-api-builderSkill
- spring-security-configurator-auditorSkill
- stacktrace-log-triageSkill
- test-suite-builderSkill
- transaction-consistency-designerSkill
- upgrade-breaking-change-navigatorSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. About 0 are common, 13 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Treat validation and error mapping as part of API design, not a post-processing afterthought.
- Distinctive: line 36
Do not collapse all non-success outcomes into one generic error envelope.
- Very specific: line 40
Use 400 for malformed input, type mismatch, or invalid transport shape.
- Very specific: line 41
Use 401 for authentication failure and 403 for authorization failure.
- Very specific: line 42
Use 404 when the addressed resource is absent.
- Very specific: line 43
Use 409 for state conflicts, optimistic locking failures, duplicate idempotency keys, and uniqueness races when conflict semantics matter.
- Very specific: line 44
Use 422 when the payload is structurally valid but violates business rules.
- Very specific: line 45
Use 429, 502, 503, or 504 deliberately when gateway or dependency behavior is part of the contract.
- Distinctive: line 57
If using RFC 7807 Problem Details, decide which extensions are stable parts of the contract and which are internal.
- Distinctive: line 61
Keep transport validation separate from domain validation even if both ultimately reject the request.
- Very specific: line 62
Use Kotlin @field: targets for Bean Validation annotations on DTO constructor properties.
- Distinctive: line 63
Prefer dedicated validators or domain rules over abusing regex annotations for business semantics.
- Distinctive: line 71
If the platform uses Problem Details, verify framework-generated problem payloads do not diverge from custom ones during upgrades.
- Distinctive: line 76
If the service is public, keep error-code taxonomy versionable and stable even when internal exception types change.
- Distinctive: line 77
When multiple validation layers reject the same request, choose the most user-actionable signal instead of stacking redundant errors.
- Distinctive: line 78
If a downstream dependency failure is part of the business path, decide whether the contract should expose dependency semantics or …
- Distinctive: line 93
Do not leak stack traces, SQL fragments, class names, tokens, or secrets to clients.
- Distinctive: line 94
Do not use one generic message for all failures if clients need actionable categories.
- Very specific: line 95
Do not map every domain failure to 400.
- Distinctive: line 96
Do not let security exceptions bypass the common contract unintentionally.
- Distinctive: line 97
Do not rely on the framework default error shape if the service claims to have a stable API contract.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Error Model Validation Architect
Source mapping: Tier 2 high-value skill derived from Kotlin_Spring_Developer_Pipeline.md (SK-07).
Mission
Turn ad-hoc exception handling into a deliberate public contract. Treat validation and error mapping as part of API design, not a post-processing afterthought.
Inputs To Read
- Endpoint contracts and sample payloads.
- Existing exception classes and error payloads.
- Validation annotations, custom validators, and business rule failures.
- Current
@ControllerAdvice, security exception handling, and framework defaults. - Logging and observability conventions, especially correlation ids and PII policy.
Design The Error Taxonomy
Separate at least these categories:
- malformed request or unreadable JSON
- transport-level validation failure
- not found
- conflict or concurrency failure
- business rule rejection
- authentication and authorization failure
- downstream dependency failure
- unexpected internal failure
Do not collapse all non-success outcomes into one generic error envelope.
Status Code Rules
- Use
400for malformed input, type mismatch, or invalid transport shape. - Use
401for authentication failure and403for authorization failure. - Use
404when the addressed resource is absent. - Use
409for state conflicts, optimistic locking failures, duplicate idempotency keys, and uniqueness races when conflict semantics matter. - Use
422when the payload is structurally valid but violates business rules. - Use
429,502,503, or504deliberately when gateway or dependency behavior is part of the contract. - Reserve
500for genuinely unexpected internal failures.
Advanced Contract Decisions
- Separate machine-readable error code from human-readable message. Clients should not parse prose.
- Decide whether field-level validation errors should be aggregated or first-failure only. Make the rule consistent.
- Preserve nested field paths for complex payloads and collections.
- Decide whether localization is a server concern, client concern, or documentation-only concern.
- Standardize correlation or trace identifiers in the error payload only if the platform can produce them consistently.
- Decide how unknown fields, enum mismatches, and unreadable date formats surface. These are common client-integration pain points.
- Map downstream failures carefully. Not every remote
500should become your own500. - If using RFC 7807 Problem Details, decide which extensions are stable parts of the contract and which are internal.
Validation Rules
- Keep transport validation separate from domain validation even if both ultimately reject the request.
- Use Kotlin
@field:targets for Bean Validation annotations on DTO constructor properties. - Prefer dedicated validators or domain rules over abusing regex annotations for business semantics.
- Validate required configuration or invariants at startup when they are not truly request-scoped.
Framework Exception Coverage
- Cover
MethodArgumentNotValidException,ConstraintViolationException,HttpMessageNotReadableException,MethodArgumentTypeMismatchException, missing-parameter exceptions, and unsupported media-type cases explicitly if the API claims a stable error contract. - Decide how security exceptions participate in the shared error model.
AuthenticationEntryPointandAccessDeniedHandleroften need explicit alignment with controller advice. - Decide how async, scheduled, and messaging failures are reported differently from HTTP failures. One global envelope does not fit every boundary.
- If the platform uses Problem Details, verify framework-generated problem payloads do not diverge from custom ones during upgrades.
Expert Heuristics
- Let validation errors help the client recover, but let internal logs help operators diagnose. These are different audiences and should not share the same detail level.
- If the service is public, keep error-code taxonomy versionable and stable even when internal exception types change.
- When multiple validation layers reject the same request, choose the most user-actionable signal instead of stacking redundant errors.
- If a downstream dependency failure is part of the business path, decide whether the contract should expose dependency semantics or normalize them to your own domain.
Output Contract
Return these sections:
Error taxonomy: the categories and stable codes.Status mapping: which exception or failure type maps to which status and why.Payload shape: the fields that belong in every error.Framework coverage: which framework exceptions must be handled explicitly.Minimal implementation plan: advice class, exception types, and tests to add.Logging rule: what to log server-side versus what to expose to clients.
Guardrails
- Do not leak stack traces, SQL fragments, class names, tokens, or secrets to clients.
- Do not use one generic message for all failures if clients need actionable categories.
- Do not map every domain failure to
400. - Do not let security exceptions bypass the common contract unintentionally.
- Do not rely on the framework default error shape if the service claims to have a stable API contract.
Quality Bar
A good run of this skill gives clients a predictable error language and gives operators enough server-side detail to debug safely. A bad run produces a pretty error JSON that still conflates malformed input, business rejection, and internal failure.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

