Create a skill that scaffolds new operation types for the AI module
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3582766. -->
Reported by: [marcus_johansson](https://www.drupal.org/user/385947)
Related to !1399
>>>
<p>[Tracker]<br>
<strong>Update Summary: </strong>[One-line status update for stakeholders]<br>
<strong>Short Description: </strong>Create a skill that scaffolds new operation types for the AI module<br>
<strong>Check-in Date: </strong>MM/DD/YYYY<br>
[/Tracker]</p>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Creating a new operation type in the AI module requires authoring multiple files following a specific pattern: an interface with the <code>#[OperationType]</code> attribute, an input class implementing <code>InputInterface</code> (or extending <code>InputBase</code>), an output class implementing <code>OutputInterface</code>, and optionally a plugin base class. The discovery mechanism in <code>OperationTypeDiscovery</code> expects these files to follow a specific directory structure under <code>src/OperationType/{OperationName}/</code>.</p>
<p>Currently, developers need to manually study the existing operation types (such as Chat, Embeddings, TextToImage, etc.) or the test example (<code>EchoInterface</code>, <code>EchoInput</code>, <code>EchoOutput</code>) to understand the required pattern. This is error-prone and time-consuming, especially for contributors who are new to the AI module architecture.</p>
<p>A Claude Code skill could automate this scaffolding process, ensuring that all required files are generated correctly and consistently. The skill would ask the developer for the necessary information (operation name, methods, input/output fields) and generate the complete set of files following the established patterns in the codebase.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ul>
<li>Create a Claude Code skill (e.g. <code>/create-operation-type</code>) that scaffolds a new operation type for the AI module.</li>
<li>The skill should generate the following files under <code>src/OperationType/{OperationName}/</code>:
<ul>
<li><code>{OperationName}Interface.php</code> - extending <code>OperationTypeInterface</code> with the <code>#[OperationType]</code> attribute</li>
<li><code>{OperationName}Input.php</code> - implementing <code>InputInterface</code> or extending <code>InputBase</code></li>
<li><code>{OperationName}Output.php</code> - implementing <code>OutputInterface</code></li>
</ul>
</li>
<li>The skill should prompt the developer for: the operation type name, a human-readable label, the primary method signature, and what data the input/output classes should hold.</li>
<li>Generated code should follow the same patterns used by existing operation types like Chat, Embeddings, and the Echo test example.</li>
<li>The skill should use the <code>#[OperationType]</code> PHP 8 attribute (not legacy Drupal annotations) for discovery.</li>
<li>The skill should reference the existing <code>OperationTypeDiscovery</code> class to ensure generated files are placed where discovery expects them.</li>
<li>Consider including a step to remind the developer that providers need to implement the new interface and register the operation type in their <code>getSupportedOperationTypes()</code> method.</li>
</ul>
<h3 id="summary-ai-usage">AI usage (if applicable)</h3>
<p>[x] AI Assisted Issue<br>
This issue was generated with AI assistance, but was reviewed and refined by the creator.</p>
<p>[ ] AI Assisted Code<br>
This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.</p>
<p>[ ] AI Generated Code<br>
This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.</p>
<p>[ ] Vibe Coded<br>
This code was generated by an AI and has only been functionally tested.</p>
<p>- <strong>This issue was created with the help of AI</strong></p>
issue