From kamae-ts
Guides server-side TypeScript domain modeling with discriminated unions, pure state transitions, Result types, schema-validated boundaries, and PII protection. Triggers on business logic types, use cases, repositories, and error handling.
npx claudepluginhub iwasa-kosui/kamae-ts --plugin kamae-tsThis skill uses the workspace's default tool permissions.
Six topic files cover the principles. Read only the file(s) relevant to the current task. The library guides under `result-libraries/` and `validation-libraries/` are read on demand based on the project's `package.json`.
boundary-defense.mddeclarative-style.mddomain-modeling.mderror-handling.mdexamples/sensitive-type-arktype.tsexamples/sensitive-type-valibot.tsexamples/sensitive-type.tsexamples/taxi-request-arktype.tsexamples/taxi-request-valibot.tsexamples/taxi-request.tsresult-libraries/byethrow.mdresult-libraries/fp-ts.mdresult-libraries/neverthrow.mdresult-libraries/option-t.mdstate-modeling.mdtest-data.mdvalidation-libraries/arktype.mdvalidation-libraries/valibot.mdvalidation-libraries/zod.mdReviews server-side TypeScript code for kamae principles: discriminated unions, branded types, Result error handling, boundary validation, PII protection. For PRs, audits of domain models, repositories, use cases.
Provides TypeScript functional patterns for ADTs, discriminated unions, Result/Option types, branded types. Use for state machines, type-safe domain models, and error handling.
Guides FP domain modeling with algebraic data types, smart constructors, primitive wrappers, and type-level validation to make illegal states unrepresentable.
Share bugs, ideas, or general feedback.
Six topic files cover the principles. Read only the file(s) relevant to the current task. The library guides under result-libraries/ and validation-libraries/ are read on demand based on the project's package.json.
Before any other step, glob and Read rules in priority order:
.claude/rules/*.md (project-level overrides at the working-tree root)~/.claude/rules/*.md (user-global preferences)../../rules/defaults/*.md relative to this SKILL.md (plugin defaults)For each file:
applies-to is kamae or *.name. For each name, keep only the highest-tier instance (1 > 2 > 3); within a tier the lexicographically last filename wins.library-preference rule overrides Step 1 detection; a convention rule shapes generated code; an override rule replaces guidance from a specific topic file.If no rules are found, proceed with the plugin defaults already documented in ../../rules/defaults/.
See ../../rules/README.md for the rule format.
Read package.json once. Note which Result library and validation library are present:
neverthrow > byethrow > fp-ts > option-t. Load the matching guide under result-libraries/ when error-handling is in scope.zod > valibot > arktype. Load the matching guide under validation-libraries/ when boundary or branded-type work is in scope.If none are present, ask the user before proceeding.
Each topic below is one file. Read it lazily — only the file(s) you need for the current task.
Represent states with discriminated unions using kind as the unified discriminant. Use type (not interface), Companion Object pattern, branded types via the project's validation library, Readonly<>, function property notation, and one-concept-per-file structure.
Express transitions with pure functions. Argument types constrain valid source states; return types make targets explicit. Invalid transitions become compile errors. Use assertNever for exhaustiveness.
Treat errors as values via Result. Define error types as discriminated unions so callers branch exhaustively. Do not throw exceptions in domain code.
Validate every external input (API requests, DB results, file/queue/env) with a schema at runtime. Trust types inside the domain. Do not use type assertions — as const and as const satisfies Type are the only allowed forms; when the type is unknown, parse through a validation-library schema instead. Apply Sensitive<T> to PII fields; the validation schema auto-wraps them.
Use filter / map / reduce with companion-object predicates instead of imperative loops. Model domain events as immutable records.
Define fixtures with as const satisfies Type to preserve discriminant literal types and prevent widening.
Worked end-to-end examples are in examples/. Read them only when the topic guide cites a specific example.
These are recommendations, not strict rules. Use judgment based on context. If you deviate from a principle, state the reason in a comment. Justifiable reasons include: external library requires class inheritance, immutable object creation cost is a measured performance concern, or a different pattern has been adopted by team agreement.