/architecture:map-data [--scope module|all|<module>] [--include-columns] [--dialect mermaid|dbml] [--out <dir>]from architecture
Generates entity-relationship diagrams from committed schema declarations (Prisma, Entity Framework, SQL migrations) without a database connection. Reports disagreements between sources.
Ships in architecture. 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.
Read when SKILL.md points to them; scripts run unread.
The current repository is both the consumer, whose convention home declares where artifacts land, and the default subject, whose tracked files declare the schema.
Collect with an individual Bash call, one command per call: the project root,
git rev-parse --show-toplevel. Treat a failure (not a repository, git unavailable) as an unknown
value and carry on; ${CLAUDE_PROJECT_DIR} is the resolver's --root either way.
Answer "what are the entities and how do they relate" from declarations in the tree. Every entity and every cardinality traces to a named file. The scripts collect and render. Do not draw a box the script did not emit, and do not invent a cardinality the script did not record.
This is not a C4 diagram: an entity-relationship diagram is not one of the C4 views (the record is under Gotchas).
Read ${CLAUDE_PLUGIN_ROOT}/reference/config.md first. This skill writes into architecture_dir.
It does not read landscape_dialect and adds no dialect key: the diagram dialect is
diagram_dialect.data from the authoring-formats topic doc.
Run bash "${CLAUDE_PLUGIN_ROOT}/lib/resolve-convention-home.sh" --root "${CLAUDE_PROJECT_DIR}"
and resolve architecture_dir per ${CLAUDE_PLUGIN_ROOT}/reference/config.md "Where the config lives" and
"Resolution order, per key"; never parse the root instruction file yourself.
Resolve diagram_dialect.data by restating this ladder, then running the resolver rather than
parsing the topic doc yourself. The ladder is a resolution order, not a task list:
1. Anchor at the repository root: `${CLAUDE_PROJECT_DIR}` when set, otherwise
`git rev-parse --show-toplevel`. Never a CWD-relative read.
2. Resolve the convention home `<home>` with the bundled resolver above. Never hand-parse the root
file.
3. The printed home is repo-relative: join it to the root, then pass
`<root>/<home>/authoring-formats/README.md` to the resolver.
4. Layer order is one layer deep: an explicit `--dialect` argument, then the team convention doc,
then the documented default `mermaid`. There is no personal override.
5. Default: `diagram_dialect.data` is `mermaid`. Allowed values are `mermaid` and `dbml`.
6. Degrade soft, and say so. No pointer, no doc, no key, or an unrecognized value each resolve to
`mermaid`. The resolver names the cause on stderr. Do not hard-fail and do not ask the operator
to create the surface mid-task.
7. Report provenance: the key, the value, and the layer (`argument`, `team convention doc <path>`,
or `default`).
bash "${CLAUDE_PLUGIN_ROOT}/lib/resolve-diagram-dialect.sh" --kind data \
--formats "<root>/<home>/authoring-formats/README.md"
Omit --formats when no convention home resolved. Stdout is mermaid or dbml. An explicit
--dialect on the invocation wins and the resolver is not required.
This skill never writes the consumer's root instruction file or its topic doc.
"${CLAUDE_SKILL_DIR}/scripts/collect-data.sh" \
--repo "<subject-repo>" --out "<architecture_dir>/data-model.json" \
--generated-on "<YYYY-MM-DD|unknown>"
Pass --generated-on from git -C <root> log -1 --format=%cs, or unknown when that fails.
Pass --live only when the invocation asked for a live connection: the script opens none, writes a
refusal, and does not read the schema.
The record is schema_version 1, one object per line. status is drawn or refused; a refusal
names reason and writes no relationships. Shipped tiers, first present wins the diagram:
*.prisma model blocks.Entity<T>() or, in a file that declares exactly one class X : IEntityTypeConfiguration<T>
(also among several base types), at the Configure builder parameter. HasOne/HasMany take a
generic argument or, for one-to-many, a lambda navigation (HasMany(e => e.Posts).WithOne(e => e.Blog),
HasOne(e => e.Blog).WithMany(e => e.Posts)); the navigation's target comes from the property
declared on the configured entity's class in the scanned .cs files (ICollection, List,
IList, IEnumerable or HashSet of one identifier for a collection, T or T? for a
reference). HasForeignKey and HasPrincipalKey take one string literal or one single-member
lambda. Requiredness is an explicit IsRequired(), IsRequired(true) or IsRequired(false);
with none, it is the foreign-key property's declared type on the dependent class: T?,
Nullable<T> and string? are optional, and int, uint, long, ulong, short, ushort,
byte, sbyte, Guid, DateTime and DateTimeOffset are required.*.sql under a migrations directory at any depth, including one
at the repository root, replayed in path order. The readable statements are CREATE TABLE
(with inline REFERENCES, table-level FOREIGN KEY, UNIQUE and PRIMARY KEY),
CREATE UNIQUE INDEX, DROP INDEX, DROP TABLE, and ALTER TABLE with ADD COLUMN,
DROP COLUMN, ADD [CONSTRAINT n] FOREIGN KEY | UNIQUE | PRIMARY KEY, and DROP CONSTRAINT
naming a constraint the migrations declared. Any other ALTER TABLE action (RENAME,
ALTER COLUMN, a DROP CONSTRAINT it cannot map) refuses the tier with sql-alter-unreadable.A second shipped tier that disagrees becomes a mismatch row. The diagram stays on the winning tier.
A tier that loses and cannot be read (an EF chain outside the subset, an unreadable migration) does
not refuse the record: it is left out of the comparison and listed as a not-compared row.
Django models, SQLAlchemy columns, EF [ForeignKey] annotations, and a Prisma many-to-many with no
fields: list refuse the record (partial-read or a named reason), as does an EF chain outside the
subset when EF is the winning tier (ef-fluent-unreadable), a migration outside the subset when
SQL is the winning tier (sql-alter-unreadable), and a composite foreign key with no unique column
set inside it (unknown-cardinality). A shipped diagram beside an unread mechanism would be a
partial read.
A module is the first path segment of the declaring file, or . at the repository root. It is
listed only when the winning tier declares an entity in it.
"${CLAUDE_SKILL_DIR}/scripts/render-data.sh" \
--record "<architecture_dir>/data-model.json" --out "<architecture_dir>" \
--dialect "<mermaid|dbml>" --scope "<module|all|id>"
Add --include-columns only when the invocation asked for columns. The default scope is module:
one module is drawn; several modules write a refusal that lists them and the script exits 3. Draw
nothing until the operator passes --scope <id> or --scope all. In a non-interactive run, stop
after that refusal. Do not pick a module. With more than one module in scope, every node is named
module/Entity, so orders/User and billing/User stay two nodes.
Mermaid writes an erDiagram inside data-model.md. DBML writes data-model.dbml and points at
it from data-model.md. Column names and types appear in the diagram only with --include-columns;
the relationship list and the mismatch list are not a column dump.
The script prints one summary line. Keep it:
data: status=<drawn|refused> reason=<reason|none> tier=<tier> tool=<tool> modules=<n> entities=<n> relationships=<n> mismatches=<n> columns=<yes|no> dialect=<mermaid|dbml> scope=<id|all|unresolved|none>
Exit 1 means the record is unreadable or not schema_version 1 in the one-object-per-line layout; nothing was written. Report that message. Do not reformat the record by hand.
End every run with this block, in this order:
none written when the run stopped before a home existed.drawn or refused, and the reason when it is a refusal.none on a refusal.mermaid or dbml, and the layer it came from.all, or unresolved with the module list.After the report, offer an interactive view of data-model.json in one sentence. The markdown and
the record stay authoritative. Build it only with ${CLAUDE_PLUGIN_ROOT}/scripts/build-view.mjs data,
never hand-written; the shared medium resolver decides the destination, 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 its report line is printed. Procedure:
${CLAUDE_PLUGIN_ROOT}/reference/rendered-view.md.
diagram_dialect.data.HasOne(lambda) paired
with WithOne, a navigation with no single declared type (an expression-bodied property, a
positional record member, an undeclared name), two declarations of one class property in the
same module, a file with zero or several IEntityTypeConfiguration<T> classes, an IsRequired
argument other than true or false, and, when IsRequired is absent, a foreign key that is
undeclared or has a plain string, enum or other type, because its nullability depends on the
project's nullable setting. A [ForeignKey] annotation is not read.--out, and no confirmed architecture_dir is a stop./architecture:adr./planning:design data./architecture:map-landscape.diagram_dialect.data (mermaid or dbml). Pointer:
when checking which views C4 defines, fetch
C4 diagrams § Static structure diagrams
and § Supporting diagrams live.@relation(fields:, references:). The reader takes the
scalar that fields names as the foreign key, and reads the relation as required when neither
the relation field nor that scalar carries ?. Pointer: when
checking where Prisma stores a one-to-many foreign key or what makes it required, fetch
one-to-many relations § 1-n in the database
and
§ Required vs optional relation fields
live.HasMany/HasOne,
WithOne/WithMany, HasForeignKey, and IsRequired, including the lambda form. Without
IsRequired it takes requiredness from the foreign-key property's nullability alone, whatever
the navigation's: int? BlogId is optional and int BlogId required, even beside
Blog Blog = null!. That reading was observed in an EF Core 10.0.0 probe with nullable
reference types on; the probe is not recorded in this repository. Pointer: when checking how EF
sets requiredness, fetch
foreign and principal keys § Non-nullable foreign key columns
and
one-to-many § Required one-to-many
live. The script's stderr names the property or chain that stopped a refused read; the
record's reason stays ef-fluent-unreadable. A declaration in the configuration file's own
module is preferred over the rest of the repository. A chain outside the subset refuses the
record only when EF is the winning tier. Beside a Prisma schema it is a not-compared row, so a
test or sample file cannot block the diagram.sql-alter-unreadable on any other ALTER TABLE action, because a renamed
table or a changed column would leave the replayed shape wrong. A migration it cannot read never
produces a mismatch claim against the winning tier.module/Entity whenever more than one module is in scope, quoted in
Mermaid ("orders/User"). Pointer: when checking which entity names Mermaid needs quoted, fetch
entity relationship diagrams § Entities and relationships
live.||--o{ for a required foreign key. That matches both Prisma and EF: the many side may be
empty. The same EF page states there is no standard way to require a minimum number of
dependents. Do not draw ||--|{ from a required foreign key.||--o| or |o--o|. The
referenced entity is on the left, so || says each dependent row names exactly one principal,
and o| says the principal has zero or one dependent. A required unique foreign key is
||--o|; an optional one is |o--o|. Never ||--||, which would demand a dependent for every
principal. Uniqueness is a Prisma @unique, @id, @@unique([..]) or @@id([..]), or a SQL
UNIQUE, PRIMARY KEY, CREATE UNIQUE INDEX or ALTER TABLE ... ADD UNIQUE, whose columns
lie inside the foreign-key columns. A composite foreign key with no such set has no readable
cardinality, so the record refuses with unknown-cardinality rather than drawing one-to-many.
Pointer: when checking the cardinality markers or what makes a relation one-to-one, fetch
entity relationship diagrams § Relationship syntax
and
one-to-one relations § 1-1 in the database
live.references: [..] and SQL
REFERENCES t(col) fill it, and EF HasPrincipalKey("Col") does. Where the declaration names
none, the Ref becomes a // comment that says so, because DBML needs a column on both sides;
the script never assumes id.git ls-files is the source list. An untracked schema is not a
declaration. A directory that is not a git repository is a refusal.--live is a refusal. No connection string is read and no client is invoked. Offline tiers
are not silently substituted.What SKILL.md sets; muted values are Claude Code's defaults
bashThree short reads, in order
erd, entity-relationship, schema-diagram, prisma, entity-framework, sql-migration
npx claudepluginhub melodic-software/claude-code-plugins --plugin architecture15 skills in this plugin
/adrArchitecture decision records: record (retires reversed record on yes; if no convention, writes nothing until human picks a shape), audit unbacked records (read-only), prune accepted. Use for 'write an ADR', 'record this decision', why we chose X, design interview, current ADRs. Skip if no alternative was weighed, or indices/migrations/status./enforce-boundariesEnforce boundariesArchitecture module-boundary checks in the repo: each rule recorded in ## Boundary rules gets the strongest supported mechanism, proven to fail on an injected violation and pass once removed. Use for 'enforce our boundary rules', 'add an architecture test', 'make this layering rule fail the build', or confirmed boundary findings./improveCodebase scan for module friction (shallow modules, module seams, locality, cross-boundary leaks): HTML report, Design-It-Twice interview. Use for 'improve architecture', 'shallow modules', 'locality', deepening, compare interface, derive conventions, layer boundaries, which references cross a boundary. Not for cross-dimension: /improvement:find./improve-layoutImprove layoutCo-change folder-layout check from git history: finds co-change clusters and folder spread, judges cards against repo layout style, and interviews on a target layout (moves no files). Use for 'co-change layout', 'co-change clusters', or whether co-changing files live in the right folders. Not for module depth/boundaries: /architecture:improve./map-componentsMap componentsC4 component view of a deployable's modules: one arrow per internal build reference, citing its declaration. Use for 'component diagram', 'what is inside this service', 'module dependencies', arrow direction, or layering. Not for repos (/architecture:map-landscape), deployables (/architecture:map-containers), module design (/architecture:improve)./map-containersMap containersC4 container diagram of a system: deployables, stores and brokers their tracked config binds, and resolved endpoint edges. Use for 'what actually runs', 'deployables and databases', 'modular monolith', or service-to-broker binding. Not for repos (/architecture:map-landscape), one deployable (/architecture:map-components), or environment topology.Other plugins' skills for the same job