/ddd-ts-kit:clean-codefrom ddd-ts-kit
Enforces clean code rules from ddd-ts-kit: business names, small functions, stepdown order, comments only for what code cannot say, no technical names in domain.
Ships in ddd-ts-kit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The checker holds these rules (npx ddd-ts-kit check); this skill says how to satisfy them
without fighting them. Reference: docs/ARCHITECTURE.md section 6.
CONTEXT.md). If it is not there, the concept
is not understood yet: add the term with its meaning first (skill ddd-ts-kit:glossary), or ask.order.cancel(reason)),
never setStatus, update, process, handle, manage, doX.Manager, Helper, Util, Data, Info, Processor, Wrapper, Impl, Base,
Abstract, Dto, Entity, Model in a name of the domain or of a use case
(language/no-technical-name). A technical suffix is allowed only where it names the architectural role outside the
domain (OrderRepository, PlaceOrderHandler), or where the business itself says the word:
a term of the glossary holds it (Scoring model lets ScoringModel through, Copy of data
lets CopyOfData through). Add that row only when a domain expert uses the term, never to
silence the rule; without it the generator and the checker refuse the name.const appointment = await this.appointmentRepository.findById(id),
for (const reminder of due). Never target, data, item, obj, info, element, tmp
and the like in domain/ and application/ (naming/business-name): they hide which concept a
line handles. npx eslint --fix renames a binding built by X.create(..), new X(..) or read
from a repository; rename a loop variable and the others yourself, after the message.fetch here and retrieve there.isOverdue), a collection as a plural, a function that
answers as a question, a function that acts as a verb.throw SlotTaken.forCalendar(calendar.id, slot.startsAt), a
class named after what is refused, in terms of the glossary and the qualifiers invalid,
unknown, already, too, no, missing, required (BookingTooLate), never ...Error, and a static factory named after what the
refusal is about, for, with, because, on or at then a capital letter (forCalendar,
withNotice, becauseOf). The class reads its code from the closed list of its context,
readonly code = SchedulingCodes.SlotTaken in <context>.codes.ts. Never
new SlotTaken(...), never a factory named create or slotTaken (errors/through-factory,
errors/factory-name, errors/code-listed). Add one with
npx ddd-ts-kit generate error <context> <Refusal> <factory>. Under
"stack.refusals": "factories", the factory sits on the error class of the concept and its code
says the same words: AppointmentError.slotTaken(..) sets SLOT_TAKEN.npx ddd-ts-kit generate vocabulary <context> <Name> --value <value>..., an object as const
and its union type) and read by its key, AppointmentStatus.NoShow; a permission is read from
its set, billingPermissions['invoice.issue'], never by its id (language/declared-vocabulary).
A word of another language that spells the same string stays its word, typed by it outside
domain/: Record<ProductListedV1Payload['state'], InvoiceStatus>, 'issued' satisfies TheirType.domain/ and application/: 0, 1, -1 and an index only; a duration, a
limit or a rate is a constant of the module, const MINUTES_PER_HOUR = 60;, or a value object
of the business (clean/no-magic-number). Both rules hold under "stack.literals": "named",
which init writes; a project whose config does not say keeps them silent.static readonly eventName = '<context>.<aggregate>.<fact>',
and its readonly name reads it (events/name-declared-once); a reaction reads it too, @DomainEventHandler(InvoiceIssued), and an integration event handler reads
the type it handles from the contract, invoiceIssuedV1.type.domain/ that answers a plain object of data, ({ amount, currency }), is a value
object written as a function: make it a class, npx ddd-ts-kit generate value-object <context> <Name>,
with its rules in the static factory and its operations as methods (domain/value-object-class,
under "stack.values": "classes", which init writes). A function that answers value objects
it builds, a record derived by a spread, a specification and a state machine stay functions; a
decision answered as { kind: 'refused', reason } is a refusal thrown by a factory.publish(draft) and schedule(draft, date), not publish(draft, true).else after a return or throw.Read top to bottom like an article: what, then how.
export class Invoice extends AggregateRoot {
static issue(...) // 1. factories
static rehydrate(...)
pay(payment: Payment) // 2. public intentions, most important first
cancel(reason: Reason)
private assertPayable() // 3. each private helper below its first caller
private remainingAmount()
}
In a module: the exported function first, then its helpers in call order. Constants and types a reader needs to understand the first function go above it; everything else below.
Default: none. Clear code with good names is the documentation. Write a comment only when it carries what the code cannot:
| Keep | Example |
|---|---|
| why a non-obvious choice | // Rounded per line, not on the total: required by the tax authority (art. 242) |
| a warning | // Order matters: the outbox append must share the transaction of the save |
| an external reference | RFC, law, vendor bug link |
| the contract of a public API or port | what a method guarantees, units, error raised |
Delete: paraphrases of the next line, banners, section dividers, closing-brace labels,
change history, author, commented-out code, @param id the id. If a block needs a comment to
say what it does, extract it and name it.
Clock, never new Date() or Date.now() in domain or application. Pass
clock.now() into the aggregate method; aggregates do not hold a clock.IdGenerator.application/ports/, with a fake.process.env outside src/platform/config/.One exported class, interface or function per file, named after it in kebab-case; at most
350 lines, reached by extracting a responsibility (a value object, a domain service, a policy,
a file of its own), never by shortening or deleting a comment, a test or a written rule. A type or a function of the domain with no role directory is a concept not named
yet: its home is in the table "a concept with no role of its own" of docs/ARCHITECTURE.md,
never a types/ or utils/ folder. Members are private, never #name. A blank line before a
return that is not alone in its block and around if, for, try. Every if, else, for, while and do
has braces and its body on its own lines, never if (a) return b;: a branch is visible at a
glance, and a statement added to it later cannot silently fall outside it. npm run format
(Biome, line width 120), then npm run lint:fix, settle layout: do not spend tokens on it. A
blank line the lint asks for after the formatter wrapped a long line is expected, and the
second command adds it. With "formatOnWrite": true in ddd-ts-kit.config.json, the guard runs the project's Biome on each file as it is written (not under the regulated profile). Never Prettier nor a bare npx biome: another width, or an unrelated
package of that name.
No any (use unknown and narrow), no !, no as outside mappers, no @ts-ignore. Model
alternatives as discriminated unions so that switch is exhaustive. Make invalid states
unrepresentable instead of validating them later.
Fix the code, not the rule. Suppressing (// ddd-ts-kit-disable-next-line <rule> -- reason),
lowering a severity or raising a limit needs the owner's explicit agreement and a decision
record: skill ddd-ts-kit:deviation.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub ddd-ts-kit/ddd-ts-kit --plugin ddd-ts-kit26 skills in this plugin
/access-controlUse when adding a permission, a role or an ownership rule, when code needs the connected user or the tenant, when filtering a list by rights, or on an authz/* rule. Authentication, authorization, access scopes, policies, RBAC, ABAC, ReBAC./bootstrapChooses the stack and creates the project with the ddd-ts-kit CLI: config, platform, database, pipeline, contexts, in an empty directory or an existing backend. Run by the user with /ddd-ts-kit:bootstrap./bounded-contextsUse when cutting a system into bounded contexts, when a concept has no home, a context grows two vocabularies or too large, two contexts need each other, or on boundaries, subdomains, sub-contexts, modules, splitting or merging contexts. Core, supporting or generic.Other plugins' skills for the same job