Problem/Motivation

When working with AI tools to generate or review content, the AI needs to understand the field constraints of each entity type: what fields exist, their types, cardinality, allowed values, required status, and so on. Currently there is no way to export this structural information in a machine-readable format without manually inspecting the Drupal UI or reading raw config YAML.

The existing content-first:export command exports rendered content. There is no equivalent for exporting the architecture — the field schema — of entity types.

Proposed resolution

Add a new drush command content-first:export-architecture (alias cf:architecture) that introspects field definitions using EntityFieldManagerInterface and writes one YAML file per entity type, with all bundles nested inside.

Example output for architecture-entity-node.yml:

_defaults: langcode: type: string label: Language mandatory: false translatable: true limit: no cardinality: 1 status: type: boolean label: Published mandatory: false translatable: false limit: no cardinality: 1 article: _description: "Use articles for time-sensitive content." field_image: type: image label: Image mandatory: false translatable: true limit: no cardinality: 1 allowed_extensions: [jpg, jpeg, png, webp] alt_required: true field_tags: type: taxonomy label: Tags mandatory: false translatable: false limit: no cardinality: unlimited target_type: taxonomy_term target_bundles: [tags] 

The command supports:

  • --entity-types — comma-separated entity type IDs to export (default: node)
  • --bundles — optional bundle filter
  • --folder — output directory (default: private://content_first/)
  • --follow-references — auto-discovers and exports referenced entity types (paragraphs, taxonomy terms, etc.)

A new service EntityArchitectureExporter handles all field inspection logic. It exports the following per field:

  • Human-readable type (e.g. textarea, taxonomy, paragraphs, select)
  • label, description (when set), mandatory, translatable
  • limit (max_length for string fields, no otherwise), cardinality
  • default value when configured
  • For select fields: options key-value map
  • For text/textarea fields: allowed_formats
  • For file/image fields: allowed_extensions, max_filesize, alt_required, min_resolution/max_resolution
  • For numeric fields: min, max, prefix, suffix
  • For link fields: link_type (internal/external/any), link_title
  • For entity reference fields: target_type and target_bundles

Fields that are identical across all bundles are hoisted into a _defaults section to reduce repetition. Bundle descriptions (from getDescription() on the bundle entity) appear as _description.

Internal and system fields are excluded: nid, tid, vid, uuid, all revision_ fields, created, changed, default_langcode, content_translation_, moderation_state, promote, sticky, layout_builder__layout.

Remaining tasks

  • Review and test against sites using paragraphs, media, and taxonomy references
  • Add unit tests for EntityArchitectureExporter
  • Consider whether _defaults extraction should be opt-out via a flag

API changes

New service content_first.entity_architecture_exporter — class Drupal\content_first\Architecture\EntityArchitectureExporter.

New drush command content-first:export-architecture / cf:architecture added to ContentFirstCommands. The constructor gains three new arguments: EntityFieldManagerInterface, EntityTypeBundleInfoInterface, and EntityArchitectureExporter.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

gedur created an issue. See original summary.

gedur’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • gedur committed 13e1dcfb on 2.x
    Issue #3593733: Add drush command to export entity field architecture as...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.