/craft:refactoring-principlesfrom craft
Cross-language refactoring principles: trace business flow before refactoring, consumer-driven value object design, imports as coupling signals, and the deletion test for abstractions.
Ships in craft. 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.
This skill defines the abstract rules. Language-specific examples live in:
php-refactoring(PHP / Symfony)ts-refactoring(TypeScript / Node)- (others as they join the stack)
A local refactoring that ignores the global flow produces incomplete abstractions. Before touching any code, trace the data flow end-to-end.
Process:
Criterion: if an object can be constructed from N different sources, the refactoring must identify all of them before defining the structure.
When creating or modifying a value object, list all its consumers to define the required properties. Do not limit the analysis to the creation point.
Process:
Criterion: a value object is complete when no consumer needs an external mapping to interpret it.
Before considering the value object "done", re-check it against every creation point too:
A file's imports reveal its real dependencies. After a refactoring, verify that remaining imports are consistent with the class's responsibility.
Post-refactoring check:
Criterion: if a file imports a type that does not match its layer/responsibility, code needs to be moved.
Before keeping a wrapper, layer, or indirection, imagine deleting it and inlining it into its callers.
Process:
Criterion: an abstraction justifies its existence only when removing it would duplicate real complexity across callers — not when it merely renames a single indirection.
Exemption: a seam mandated by the project's layered architecture (e.g. a mapper enforcing the domain/infrastructure boundary) is exempt from this test — it earns its keep by enforcing the dependency direction, not by hiding complexity.
When the refactoring must preserve an observable behaviour no existing test pins, set up a characterization net before touching the code: see craft:testing-principles §16.
| Rule | Principle |
|---|---|
| Complete business flow | Trace all sources and destinations before refactoring |
| Trace consumers | List all usages to define a value object's structure |
| Imports = coupling | Imports reveal dependencies; verify their consistency |
| Complete value objects | Include everything consumers need; no external mappings |
| Pin first | Unpinned behaviour gets a characterization net before the refactoring (craft:testing-principles §16) |
| Deletion test | An abstraction earns its keep only if deleting it duplicates complexity across callers |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub fabiensalles/claude-marketplace --plugin craft8 skills in this plugin
/code-style-principlesACTIVATE whenever writing or modifying production code in src/, in any language — this is the base layer these rules build on. ACTIVATE for code review, formatting questions, or 'coding standards'. Covers cross-language code style: control-structure spacing, early-return pattern, continue-vs-if/else in loops, explicit (non-truthy/falsy) checks, flattening nested null checks, parameter ordering. These rules go BEYOND standard linters. Language-specific syntax (no-empty in PHP, template literals in TS, nowdoc, optional chaining vs nullsafe) lives in php-code-conventions / ts-code-conventions, which apply on top of this skill rather than instead of it. DO NOT use for: language-specific syntax already covered by php-code-conventions / ts-code-conventions (see php:php-code-conventions + typescript:ts-code-conventions for PHP/TS specifics)./ddd-fp-principlesACTIVATE when modeling DDD aggregates, value objects and domain logic using functional patterns — immutable records, curried operations, Result types, validation/enrichment pipelines, handler orchestration. ACTIVATE for 'aggregate', 'smart constructor', 'make*', 'validation pipeline', 'enrichment', 'domain handler' in a functional context. Provides cross-language functional DDD principles. For OOP-style DDD (classes, decorators, module-bounded contexts) see craft:ddd-principles. Companion examples: ddd-ts-fp.Other plugins' skills for the same job