Design

From melodic-software/claude-code-plugins · View interactive version

Design is an AI agent skill from the GitHub repository melodic-software/claude-code-plugins. Resolve design decisions (types, contracts, package topology, module boundaries) in discussion rounds before /planning:plan, as design artifacts. Use when: 'design this', 'type modeling', 'figure out the abstractions', 'model this domain', 'what should the types look like', 'how should I structure t

How to use this skill

Skill file

Arguments. [library|module|data|integration|system] [status|thread <name>|discuss|terminology|handoff].

e.g., /planning:design library, /planning:design module, /planning:design status, /planning:design discuss,

/planning:design handoff

Variables

Arguments: $ARGUMENTS

Purpose

Design answers what before /planning:plan answers how: types, boundaries and package topology the

user has validated through discussion. Exploration maps existing code, research gathers external

facts, this skill turns both into a design. When the problem is still rough and no approach is

chosen, diverge first via /planning:brainstorm (cheapest→most-ambitious candidates, user

reacts), then design the direction that resonated.

Level this skill decides: interfaces and contracts, the types, boundaries and module shapes

other code depends on; behavior is the interview's Brief, and files and symbols are

/planning:plan's.

Depth scales to the work:

and reason. Then invoke /planning:design-handoff via the Skill tool, which writes PLAN.md's

one-line ## Design record and hands off to /planning:plan

The stage always runs; early-exit is a valid outcome. Gate artifact: Tier C and light Tier B

early-exits MUST produce design-resolution.md in the topic's design slice

(<memory_dir>/<topic-slug>/design/, default .work/) so /planning:plan's prerequisite check

can verify the gate without conversation memory.

design-resolution.md (early-exit artifact)

---
outcome: early-exit
tier: C
reason: <one line, e.g. single-file bugfix, docs-only>
---

Tier B (required): the type sketch, inline or as a link to type-inventory.md.
/planning:design-handoff quotes it into PLAN.md's `### Contracts`.

Gates

These hold after a compaction re-attach. Later sections say how to carry them out.

behaviors).

user: interactively ask, recommending contain; unattended, apply contain and record the question

as a human decision. Full rule:

CODE0

"Autonomy".

or URL it rests on, or judgment (non-consequential only). A consequential one (cross-repo,

shared infrastructure, irreversible, or security) is grounded before it is presented; one

research cannot settle is withheld, recorded as a deferred thread whose research tag names

the evidence that would settle it.

Action Router

Parse $ARGUMENTS for scope and action:

| Argument | Action |

|----------|--------|

| (empty) | Auto-detect. Read the PLAN.md Brief + conversation to determine scope and phase. Resume if design artifacts exist. Ask if ambiguous |

| library | Library/API design. Packages, types, contracts, dependency graph |

| module | Module design. Domain model, boundaries, contracts. Suggest a domain-event workshop (e.g. EventStorming) when the environment provides one |

| data | Data model design. Entities, relationships, schema decisions |

| integration | Integration design. Cross-system contracts, sequence flows, error handling |

| system | System design. Components, communication patterns, deployment topology |

| status | Status report. Resolution state per thread and question |

| thread <name> | Deep-dive. One design thread |

| discuss | Discussion round. Systematic gap-finding across all artifacts |

| terminology | Naming review. Cross-cutting naming pass over the full type inventory (see "Terminology pass") |

| handoff | Handoff gate. Delegates to /planning:design-handoff (see "Handoff gate") |

Phases

Phases may interleave. Track which have produced artifacts and which have open questions.

All artifacts live in <memory_dir>/<topic-slug>/design/ (default .work/), never committed;

/planning:plan's gate reads the gate files (design-threads.md, design-resolution.md) from

there. Placement:

CODE0.

/planning:design-handoff writes the durable content (module layout, contracts, variation

verdicts, conventions followed) into PLAN.md's ## Design, the copy that reaches the plan, the

implementer's brief, and the pull request body or linked issue where PLAN.md is published. Derive

<topic-slug> from the task or branch name (git branch --show-current; the task alone when that fails), kebab-case, ≤40 chars, shared with /planning:interview and /planning:plan. Skip

artifact creation for read-only actions (status).

Phase 1: Problem Space Decomposition

Read the Brief's ### Problem before decomposing; absent, start from the Problem, `Intent (why,

in the user's words) and Chosen direction lines of <memory_dir>/<topic-slug>/brainstorm.md`'s

## Handoff block when it exists; with neither, establish it:

CODE0. Its

time_units user layer is ${user_config.time_units} (unexpanded means unset).

Scan the whole problem space broadly before diving into any single capability. For each capability

or concern:

library-organization and dependency-preference conventions when it declares them

When the work adds a requirement to existing code, ask before Phase 3: had this requirement been

known when the code was first written, which types and boundaries would it have? Take that answer

as the target shape, not the current shape with the requirement bolted on.

Produce: capability-matrix.md (library scope) or equivalent per scope.

Phase 2: Design Threads

Identify cross-cutting decisions that affect multiple capabilities. For each thread: name the

decision, list concrete options with tradeoffs, and resolve through discussion or defer with

rationale + research tag. Status: resolved (decision made), directional (direction agreed,

details deferred), deferred (needs research).

Two-candidate step. Take it when the codebase has nothing to copy for the thread, more than one

approach is workable, and the decision is hard to reverse (a public contract, a stored format, a

boundary other modules will build on):

  1. Write the criteria the candidates will be judged by into the thread before drafting any

candidate.

  1. Draft at least two candidates that differ in structure: who owns the state, where the module

split falls, or what shape the contract takes. A renamed or reordered copy of the first is not a

second candidate.

  1. Judge each against the written criteria, and record the rejected ones with the reason in

design-threads.md.

When the thread is about how a screen or interaction looks or feels, invoke

/prototype:explore-directions (if enabled) via the Skill tool. When the

candidates differ in logic or state (the rules, a state machine, a data model, an API surface) and

a run can settle the fork, invoke /prototype:pressure-test observe (if enabled) via the Skill tool, because running each candidate on the same inputs shows which one

holds where arguing them only predicts it. The test: name the event sequence or record that the

criteria turn on; when nobody can yet say with confidence how each candidate handles it, a run

settles the fork (pstack's exhaust-the-design-space principle). Confirm the scope of the

throwaway with the user before either route. When neither route applies or its skill is

unavailable, run the three steps here, describing each candidate in prose.

Open these threads when their trigger holds:

processes, overlapping requests, background jobs). Cover which actors write it, what a reader

sees halfway through an update, and whether the type is confined to one owner, immutable, or

guarded.

model, shared vs tenant-scoped data catalog.

files (refactor or strangler scope). Characterization-test strategy, seam map, incremental

extract order, change budget.

reuse an existing seam before adding one, put any new seam as high in the stack as it can go, and

aim for the fewest seams that cover the surface. The change→test-type mapping lives in

the classification table of /testing:plan (if enabled); cite it, or without that plugin

apply standard test-design judgment. The sketch is input, not the decision: /planning:plan's

Test strategy names the test boundaries from it and its Step 5 approval settles them; a seam the

design needs as a contract still goes in Contracts.

Variation-point pass. Always for integration, module, and system; for library and

data, when the design touches an external system or a domain category. List every variation

point (every external integration is one), ask the two questions (likelihood of a second variant,

cost of change after shipping), and open one thread per point that resolves to a verdict: abstract

now, contain now and abstract later (the default for anything external), or leave inline (internal

one-offs only). Run the leak test on every abstraction and contained boundary, and place seams

where the solution's existing architecture style already puts them. Questions, verdicts, leak test,

autonomy rule, and sources:

CODE0.

A variation-intent answer from /planning:interview is settled, never re-asked.

Produce: design-threads.md

System-scope steps

system scope only, and suggested, not required: three more threads in design-threads.md,

named Quality scenarios, Capacity estimates and Risks. Scenarios come from the Brief's

quality requirements, never re-asked, and a prototype Brief defers them in one line; an unknown

capacity input becomes a target assumed ... revisit if ... line; risk rows take

/planning:plan's risk-table columns. How:

CODE0.

Phase 3: Type Modeling

The phase ends with a type-inventory.md in which every type traces to a call site that needs it,

and each type's shape is set by the operations its busiest paths run on it. Two checks prove it:

contract, written as its users will write them, before any type has a name; for a library or

API, at least one sits inside the importing package. A type enters the inventory only if those

calls need it, given the capabilities.

append, bulk replace) with the busiest-path ones flagged, and its structure is the one those

flagged operations favor.

Apply CODE0: Phase 3 meets each of its

situations while it fills type-inventory.md, so find the row that matches and make its decision.

The inventory covers:

naming, collisions with common library types, namespaces) before naming

disambiguating overloaded terms) where declared; otherwise low-coupling/high-cohesion defaults

the moment a domain term resolves, so the glossary owner applies the consumer's format,

placement, and context routing; without it, record the resolved term and rejected synonyms in

the design artifacts

Produce: type-inventory.md

Close Phase 3 by auditing the inventory: for each type, follow one value from where it is made to

where it is read. A fault at any stop sends that type back to the design threads.

  1. Where it is made. When a schema, spec or migration already describes the shape, the entry

derives from it instead of redrawing it. A value from outside the program becomes this type

where it arrives, and nothing further in validates that input again.

  1. What it holds. Try to write a mix of field values the domain forbids; a type that accepts it

is too loose. For each type the design strengthened, name the function that would fail on part

of its input without the extra strength; with none, the strength guards nothing, and that is a

fault too.

  1. Where it is read. Picture one more variant: every reading site must then fail to compile,

not keep running silently. On the same path, every cast, assertion or suppression has a check

in front of it.

Once type modeling stabilizes, run the terminology action over the whole inventory; per-type

naming during modeling does not replace it.

Phase 4: Package/Module Topology

When the work adds, splits, merges or moves a module or its interface, invoke

/architecture:principles (if enabled) via the Skill tool before writing the topology, and name

modules, interfaces, seams and adapters in its terms. For modules that already exist, name

/architecture:improve (if enabled) as the step that finds which ones to reshape; this skill scans

no code. When the architecture plugin is not enabled, say once that it would supply the

module-design vocabulary and the friction scan, and proceed from

CODE0.

Produce: library-topology.md (library scope) or equivalent per scope.

When the dependency graph reads more clearly visually, optionally also emit a self-contained HTML

topology view to the OS temp directory, never beside library-topology.md, which stays the record.

Rules:

CODE0.

Resolve medium first per

CODE0

"Other optional views", with this plugin's medium option ${user_config.medium}, or "" when that

reads empty or unsubstituted (never put a ${user_config.*} string in a shell command), and follow

its result, which names the report line to print.

Phase 5: Discussion Rounds

Each round:

  1. Re-read all design artifacts.
  2. Record as design threads: underspecified types, missing contracts, boundary friction, pattern

concerns, and design-default gaps (configurability, extension axes, observability,

testability).

  1. Present findings ordered by tweak likelihood (the presentation default /planning:plan Step 5

documents): public contracts, data shapes, and user-facing surfaces lead; settled-looking

mechanical threads sit at the bottom. Order only; thread dependencies still govern what can

resolve when.

  1. For each project-wide principle discussion surfaces, when /corrections:codify (if enabled) is among the

available skills, hand it the choice of mechanism; it picks the strongest rung of the

enforcement ladder that can decide the rule and proves the check. Call it as

/corrections:codify "<the principle>" (if enabled). When the corrections plugin is not

enabled, propose the strongest mechanism that can

decide the rule: a change that makes the mistake impossible first, then a check that blocks it,

then a test, and an instruction only when nothing a machine runs can decide it. Say that

the corrections plugin was not available, so the proposal is unproven. When codify stops with no

proposal, as it does below its recurrence threshold, propose the same way and say that it

stopped.

Continue until no new gaps surface, then run the handoff action.

Lifecycle and reversibility

Skip on early-exit, status, or trivial single-file work. Otherwise call each significant decision

a one-way or two-way door, prompt an ADR for each one-way door, and scale investment by subdomain

and quality bar: CODE0.

Terminology pass (`terminology` action)

Over the full type inventory, once type modeling stabilizes:

  1. Check interface-naming form and context-relative naming against the project's conventions
  2. Check collisions with common library/framework type names (e.g. a bare Result<T> when the

stack already ships one)

  1. Check overloaded-term disambiguation and domain accuracy against the project's domain

vocabulary

  1. Record decisions in a terminology table inside type-inventory.md
  2. Invoke /domain-driven-design:ubiquitous-language curate (if enabled) via the Skill tool to sync resolved

terms and rejected synonyms into the project's glossary; the table above is the standalone

fallback

Handoff gate (`handoff` action)

Invoke /planning:design-handoff via the Skill tool. It is the only gate implementation: it checks

design-threads.md (or the design-resolution.md early-exit artifact) and on PASS emits the

plan-ready summary and resume prompt. This skill carries no gate criteria of its own; criteria changes land in

/planning:design-handoff only.

On PASS, offer an interactive design view of PLAN.md's ## Design (its sections, a tick for each one

the reader questions, a copy-out of the reply, sent to this session when connected). PLAN.md stays the

record. Build it only with ${CLAUDE_PLUGIN_ROOT}/scripts/build-view.mjs from that record, never

hand-written; it runs the shared medium resolver and publish gate with this plugin's medium option

${user_config.medium}, or "" when that reads empty or unsubstituted (never put a

${user_config.*} string in a shell command), and you print the report line it prints. Procedure:

CODE0.

Stub files (scaffold_stubs). Before invoking the gate, resolve scaffold_stubs, lowest layer

first: the default false; the plugin's user config (${user_config.scaffold_stubs}, where a

literal unexpanded value means unset); then the scaffold_stubs key of the repository's

docs/conventions/planning.yaml, which wins when set, read only when the working directory's git

root is neither $HOME nor an ancestor of it. Only the bare booleans true and false are valid:

any other value, a quoted "true" included, is named with its file (or user config), key and

value, and that layer is dropped, so a valid higher layer still wins and otherwise the key is

false. Report one line naming the value and its layer, e.g.

scaffold_stubs: true (docs/conventions/planning.yaml). Keys and layers:

CODE0.

With true, add a ## Stub scaffold section to design-threads.md (or to design-resolution.md

on an early exit) listing every new file the design introduces, each with the signatures it will

declare (types, function and method signatures, exported constants), from the resolved type

inventory and contracts. Each stub body is the language's ordinary not-implemented form, with no

per-language reference file. After the gate passes, the handoff output names those files and

signatures so /planning:plan can place the stub phase. With false, write no such section and name no stubs.

Scope-specific artifacts

| Scope | Primary artifacts | Typed artifact | Dialect |

|-------|-------------------|----------------|---------|

| library | capability-matrix.md, type-inventory.md, library-topology.md, design-threads.md | none | none (no typed artifact, so no scope label) |

| module | domain-model.md, module-boundary.md, contracts.md, design-threads.md | none | none (no typed artifact, so no scope label) |

| data | entity-relationships.md, schema-decisions.md, design-threads.md | entity-relationships.md | mermaid erDiagram by default; DBML when diagram_dialect.data resolves to dbml |

| integration | contract-spec.md, sequence-flows.md, design-threads.md | sequence-flows.md, contract-spec.md | mermaid sequenceDiagram for the flows; an OpenAPI 3.1 sketch for the contract spec |

| system | component-map.md, communication-patterns.md, design-threads.md | component-map.md, and only when diagram_dialect.system names a dialect | a C4 container view in LikeC4 or C4-PlantUML, never Mermaid's C4 diagrams |

design-threads.md is common across all scopes.

Typed artifacts: dialect and scope label

Typing adds a declared dialect and a scope label to artifacts this skill already emits; no new

file. Everything the Typed artifact column does not name (schema-decisions.md,

communication-patterns.md, every library and module artifact) stays prose with no dialect and

no scope label. component-map.md is likewise untyped prose with no scope label whenever

diagram_dialect.system is unset, so a downstream lookup finds nothing rather than an unlabeled

diagram.

The scope label. Every typed artifact opens with frontmatter naming the producing scope and the

dialect of its fenced block:

---
scope: data
dialect: mermaid
---

scope is one of data, integration, system. dialect is one of mermaid, dbml,

openapi-3.1, likec4, c4-plantuml. /work-items:decompose (if enabled) reads the label to inline the artifact under a provenance note naming scope and dialect;

without that plugin the label is inert. The body is one fenced block in the declared dialect,

followed by the artifact's prose. Tag the fence with the renderer name: mermaid, dbml, yaml

for the OpenAPI 3.1 sketch, likec4, plantuml. An integration session labels two artifacts,

one per typed file.

Resolving the dialect. diagram_dialect is a team-shared convention key split by artifact kind

(diagram_dialect.data, diagram_dialect.system). Resolve it per session, before writing a typed

artifact, through

CODE0

"Resolution ladder", where <plugin-root> is ${CLAUDE_PLUGIN_ROOT} and <project-root> is ${CLAUDE_PROJECT_DIR} (unexpanded or empty means unset). This skill takes no dialect argument, so the argument layer is always empty.

diagram_dialect.data defaults to mermaid, and every degrade writes the data artifact in

mermaid. diagram_dialect.system has no default: unset or degraded, emit no C4 container view

and behave exactly as with no convention doc at all, reporting its provenance as

unset (no C4 view emitted).

Diagram craft. For mermaid layout, readability, and syntax idiom, invoke

/visualization:visualize (if enabled) via the Skill tool, asking

for the fenced form, since the diagram goes into the typed artifact. Without

it, emit the plainest correct form of the dialect. The typed artifact is produced either way.

Collaborative canvas mode. When a thread's question is structural (module boundaries,

topology, a data shape, a flow) and the person is present, offer once to work it out on a live

canvas through /visualization:visualize (if enabled) in collaborative canvas mode. Offer it on no

other question. When the canvas closes, ask for the fenced form: the typed artifact stays the record.

Key behaviors

numbered round, each with a recommendation; a thread that depends on an unresolved thread waits

for the round after it resolves. Render a round via AskUserQuestion only when the plugin's

use_ask_user_question user config (${user_config.use_ask_user_question}; unexpanded or empty means off) is on and the round

is independent questions that fit one AskUserQuestion call (the per-call question limit:

<https://code.claude.com/docs/en/agent-sdk/user-input#limitations>). Inline prose otherwise

consumers and in external research that reads official docs first, routed to

/discovery:explore (if enabled) and /discovery:research (if enabled). A recommendation that changes is

restated as old → new → why. Contract:

CODE0

CODE0: a fact it settles

is stated with its basis and source tag, not asked

Deferred items carry a research tag naming the external investigation needed

immediately: hand /corrections:codify (if enabled) the choice of

mechanism; it picks the strongest rung of the enforcement ladder that can decide the rule and

proves the check. Call it as /corrections:codify "<the principle>" (if enabled). When the corrections plugin is not enabled, propose the

strongest mechanism that can decide the rule: a change that makes the mistake impossible first,

then a check that blocks it, then a test, and an instruction only when nothing a machine runs

can decide it. Say that the corrections plugin is not enabled, so the proposal is unproven.

When codify stops with no proposal, as it does below its recurrence threshold, propose the same

way and say that it stopped

evolve. Re-read multi-turn shared artifacts (design-threads.md and peers) from disk before

every write, since another turn or agent may have changed them, and prefer appending or refining

over wholesale rewrites

sequence phases

them, summarize current state, and identify remaining gaps

suggest it if available. Suggest /discovery:research (if enabled) for a deferred item needing

external research, and the terminology then handoff actions at the session tail

and system scopes, when discussion touches configurability, extension points, observability,

or testability, open a design thread for it. Extension points start from the Phase 2

variation-point pass. Skip on early-exit, status, or trivial single-file work. Apply

CODE0 first (quality bar, consumer

standards, the Brief's quality requirements, generalize-now-or-wait, per-tenant configurability

as vendor guidance), then recommend from every principle

CODE0 lists.

What this skill does not do

/visualization:visualize (if enabled), else the plainest correct form is emitted

/user-experience:shape (if enabled); look and response are /user-interface:design (if enabled)

module design

Next

Related

Relationship to other skills

| Skill | Relationship |

|-------|-------------|

| /planning:interview | Before. Locks the brief (scope + constraints); design explores the solution space within them |

| /domain-driven-design:ubiquitous-language curate (if enabled) | During. Owns project-glossary updates when design resolves domain language; not type or boundary design |

| /visualization:visualize (if enabled) | During. Owns visual-form choice and mermaid craft for a typed artifact's fenced block |

| /naming:name-it-better (if enabled) | During. Proposes candidates for a name the design leaves undecided; the human picks, and the pick is recorded in the terminology table |

| /architecture:principles (if enabled) | During. Supplies the module-design terms the topology uses when the work changes module structure (Phase 4) |

| /architecture:improve (if enabled) | Before. Finds which existing modules to reshape; design decides the new shape |

| /architecture:adr (if enabled) | During. Records the ADR for a one-way door when its thread resolves (CODE1) |

| /work-items:decompose (if enabled) | After. Reads a typed artifact's scope and dialect label to inline it into the spec container with a provenance note, and quotes each slice's part of PLAN.md's ## Design into that slice's body |

| /discovery:explore (if enabled) | Before. Maps existing code; design creates what should exist |

| /discovery:research (if enabled) | Before + parallel. Gathers external facts; deferred research items can run in parallel |

| /planning:design-handoff | The gate. Owns the design→plan gate criteria and the plan-ready summary |

| /planning:plan | After the handoff gate. Produces HOW; when design artifacts exist it consumes them instead of re-deriving design |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.