|
| 1 | +--- |
| 2 | +name: drush-webmaster |
| 3 | +description: | |
| 4 | + Manage Drupal content, entities, views, menus, fields, and site structure |
| 5 | + using drush webmaster (wm:*) commands. Use when asked to "list content types", |
| 6 | + "find articles by author", "create a new page", "edit node 42", "add a field", |
| 7 | + "build a view", "add a menu link", "translate this", |
| 8 | + "publish this node", "site schema", "search for content", |
| 9 | + "clone this entity", "moderate content", or any Drupal |
| 10 | + entity/content management task. |
| 11 | + Proactively invoke this skill (do NOT attempt raw SQL, drush eval, or direct |
| 12 | + Drupal API calls) when the user wants to query, create, edit, inspect, or |
| 13 | + manage Drupal content, entities, views, menus, blocks, vocabularies, media, |
| 14 | + translations, or site configuration. |
| 15 | +--- |
| 16 | + |
| 17 | +# Drush Webmaster Commands |
| 18 | + |
| 19 | +The `wm:*` command suite provides YAML-based Drupal site management. |
| 20 | +All output is structured YAML. Run `drush wm:<command> --help` for |
| 21 | +full documentation on any command before using it. |
| 22 | + |
| 23 | +## Discovery (Start Here) |
| 24 | + |
| 25 | +### `wm:schema:dump` — Full site schema for AI context |
| 26 | + |
| 27 | +**Run this first** when working with an unfamiliar site or section. |
| 28 | + |
| 29 | +``` |
| 30 | +drush wm:schema:dump |
| 31 | +drush wm:schema:dump --section=content-types |
| 32 | +drush wm:schema:dump --section=content-types --section=vocabularies |
| 33 | +``` |
| 34 | + |
| 35 | +Available sections: `content-types`, `vocabularies`, `views`, `menus`, |
| 36 | +`blocks`, `media-types`, `entity-types`, `site` |
| 37 | + |
| 38 | +### `wm:site:info` — Site name, slogan, email, paths |
| 39 | + |
| 40 | +``` |
| 41 | +drush wm:site:info |
| 42 | +``` |
| 43 | + |
| 44 | +## Before Modifying (Discover First) |
| 45 | + |
| 46 | +Before running any create, edit, or delete operation, run the |
| 47 | +appropriate discovery command. This prevents validation errors. |
| 48 | + |
| 49 | +| Operation | Run first | |
| 50 | +|-----------|-----------| |
| 51 | +| Create entity | `wm:content-type:get <bundle>` — required fields | |
| 52 | +| Edit entity | `wm:entity:get <type> <id>` — current values | |
| 53 | +| Delete entity | `wm:entity:get <type> <id>` — confirm correct entity | |
| 54 | +| Add field to bundle | `wm:field:list <type> <bundle>` then `wm:field:types` | |
| 55 | +| Create/edit view | `wm:view:tables` then `wm:view:available:fields` | |
| 56 | +| Translate entity | `wm:translation:languages` — see configured languages | |
| 57 | +| Moderate entity | `wm:entity:transitions <type> <id>` — transitions | |
| 58 | +| Bulk operations | `wm:content-type:get` or `wm:entity:query` — scope | |
| 59 | + |
| 60 | +Skip discovery when context is already known or the user |
| 61 | +asks to proceed directly. |
| 62 | + |
| 63 | +## Querying & Inspecting Entities |
| 64 | + |
| 65 | +### `wm:entity:query` — Find entities by field conditions |
| 66 | + |
| 67 | +``` |
| 68 | +drush wm:entity:query node article \ |
| 69 | + --where="status=1" --where="uid=5" \ |
| 70 | + --sort=created:DESC |
| 71 | +drush wm:entity:query node --where="status=0" --count |
| 72 | +drush wm:entity:query node article --where="field_image=NULL" --fields=id,title |
| 73 | +drush wm:entity:query node blog --limit=50 --offset=50 |
| 74 | +``` |
| 75 | + |
| 76 | +Where operators: `=`, `!=`, `>`, `<`, `>=`, `<=`, |
| 77 | +`=NULL`, `!=NULL`, `=a,b,c` (IN list) |
| 78 | + |
| 79 | +### `wm:entity:get` — Get single entity with field values |
| 80 | + |
| 81 | +``` |
| 82 | +drush wm:entity:get node 1 |
| 83 | +drush wm:entity:get node 1 --fields=title,body |
| 84 | +``` |
| 85 | + |
| 86 | +### `wm:entity:field:get` / `wm:entity:field:set` — Get/set single field value |
| 87 | + |
| 88 | +``` |
| 89 | +drush wm:entity:field:get node 1 title |
| 90 | +drush wm:entity:field:set node 1 title "New Title" |
| 91 | +drush wm:entity:field:set node 1 body \ |
| 92 | + '{"value":"<p>HTML</p>","format":"full_html"}' |
| 93 | +``` |
| 94 | + |
| 95 | +### `wm:search` — Full-text search (requires Search module) |
| 96 | + |
| 97 | +``` |
| 98 | +drush wm:search "contact form" |
| 99 | +``` |
| 100 | + |
| 101 | +## Creating & Editing Entities (YAML Workflow) |
| 102 | + |
| 103 | +``` |
| 104 | +drush wm:entity:edit node 5089 # Export to YAML |
| 105 | +drush wm:entity:apply node 5089 --dry-run # Preview changes |
| 106 | +drush wm:entity:apply node 5089 # Apply changes |
| 107 | +
|
| 108 | +drush wm:entity:new node article # Create template |
| 109 | +drush wm:entity:apply node new # Create entity |
| 110 | +
|
| 111 | +drush wm:entity:bulk-create # Bulk operations |
| 112 | +drush wm:entity:bulk-update |
| 113 | +drush wm:entity:bulk-delete |
| 114 | +
|
| 115 | +drush wm:entity:clone node 42 |
| 116 | +drush wm:entity:deep-clone node 42 |
| 117 | +drush wm:entity:diff node 42 43 |
| 118 | +drush wm:entity:history node 42 |
| 119 | +drush wm:entity:revert node 42 |
| 120 | +``` |
| 121 | + |
| 122 | +## Content Types & Fields |
| 123 | + |
| 124 | +``` |
| 125 | +drush wm:content-type:list |
| 126 | +drush wm:content-type:get article |
| 127 | +drush wm:content-type:stats |
| 128 | +drush wm:content-type:create |
| 129 | +drush wm:content-type:update article |
| 130 | +drush wm:content-type:delete article |
| 131 | +
|
| 132 | +drush wm:field:list node article |
| 133 | +drush wm:field:get node article title |
| 134 | +drush wm:field:add |
| 135 | +drush wm:field:update |
| 136 | +drush wm:field:delete |
| 137 | +drush wm:field:types |
| 138 | +``` |
| 139 | + |
| 140 | +## Views |
| 141 | + |
| 142 | +``` |
| 143 | +drush wm:view:list |
| 144 | +drush wm:view:get content |
| 145 | +drush wm:view:create |
| 146 | +drush wm:view:clone content |
| 147 | +drush wm:view:edit blog |
| 148 | +drush wm:view:apply blog --dry-run |
| 149 | +drush wm:view:apply blog |
| 150 | +drush wm:view:preview content |
| 151 | +drush wm:view:delete content |
| 152 | +
|
| 153 | +drush wm:view:tables |
| 154 | +drush wm:view:available:fields node_field_data |
| 155 | +drush wm:view:available:filters node_field_data |
| 156 | +drush wm:view:available:sorts node_field_data |
| 157 | +``` |
| 158 | + |
| 159 | +## Menus, Vocabularies, Blocks & Media |
| 160 | + |
| 161 | +``` |
| 162 | +drush wm:menu:list |
| 163 | +drush wm:menu:get main |
| 164 | +drush wm:menu:create |
| 165 | +drush wm:menu:link:add |
| 166 | +drush wm:menu:link:update |
| 167 | +
|
| 168 | +drush wm:vocabulary:list |
| 169 | +drush wm:vocabulary:get tags |
| 170 | +drush wm:vocabulary:create |
| 171 | +
|
| 172 | +drush wm:block:list |
| 173 | +drush wm:block:place |
| 174 | +drush wm:block:types |
| 175 | +
|
| 176 | +drush wm:media-type:list |
| 177 | +drush wm:media-type:get image |
| 178 | +``` |
| 179 | + |
| 180 | +## Translation Management |
| 181 | + |
| 182 | +Requires the Language and Content Translation Drupal modules. |
| 183 | + |
| 184 | +``` |
| 185 | +drush wm:translation:languages |
| 186 | +drush wm:entity:translations node 1 |
| 187 | +drush wm:entity:translation:get node 1 fr |
| 188 | +drush wm:entity:translation:set node 1 fr '{"title":"Bonjour"}' |
| 189 | +drush wm:entity:translation:delete node 1 fr |
| 190 | +``` |
| 191 | + |
| 192 | +## Content Moderation |
| 193 | + |
| 194 | +Requires the Content Moderation Drupal module. |
| 195 | + |
| 196 | +``` |
| 197 | +drush wm:entity:transitions node 1 |
| 198 | +drush wm:entity:moderate node 1 published |
| 199 | +drush wm:entity:moderate node 1 published --dry-run |
| 200 | +``` |
| 201 | + |
| 202 | +Always run `wm:entity:transitions` first to discover valid state transitions. |
| 203 | + |
| 204 | +## Key Workflow Pattern |
| 205 | + |
| 206 | +Default to Discover, then Inspect, then Modify. |
| 207 | + |
| 208 | +1. **Discover**: `wm:schema:dump`, |
| 209 | + `wm:content-type:get`, `wm:entity:query` |
| 210 | +2. **Inspect**: `wm:entity:get`, `wm:view:get`, |
| 211 | + `wm:field:list`, `wm:entity:transitions` |
| 212 | +3. **Edit**: `wm:entity:edit` then modify YAML then |
| 213 | + `wm:entity:apply --dry-run` then `wm:entity:apply` |
| 214 | +4. **Create**: `wm:entity:new` then fill template |
| 215 | + then `wm:entity:apply node new` |
0 commit comments