drupal-form-alter

drupal-form-alter is a skill for Claude Code, Codex from edutrul/drupal-ai. It costs 44 tokens per session (490 once invoked), scanned A, original, MIT.

Guidance for changing Drupal forms, the pages where users enter or edit information. It covers changing fields, defaults, visibility, validation, and submit actions in Drupal code.

In plain words
What is it for?
Use it to hide fields, make values required, add defaults, change descriptions, and attach custom validation or submit handlers.
Why use it?
It helps developers customize forms without editing Drupal core and shows how to target one form or a particular form type.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/edutrul/drupal-ai/drupal-form-alter
Any agent
npx skills add edutrul/drupal-ai --skill drupal-form-alter
Clone the repo
git clone --depth 1 https://github.com/edutrul/drupal-ai

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for drupal-form-alter

README.md
[![agentmods](https://agentmods.dev/badge/skills/edutrul/drupal-ai/drupal-form-alter.svg)](https://agentmods.dev/skills/edutrul/drupal-ai/drupal-form-alter)
Your own site
<a href="https://agentmods.dev/skills/edutrul/drupal-ai/drupal-form-alter"><img src="https://agentmods.dev/badge/skills/edutrul/drupal-ai/drupal-form-alter.svg" alt="Measured on agentmods" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 490 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00044 $0.00490
Opus 5 $0.00022 $0.00245
Sonnet 5 $0.00009 $0.00098
Haiku 4.5 $0.00004 $0.00049

Measured 4d ago against content hash c7ee015ac9e2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

drupal-form-alter scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/drupal-form-alter/SKILL.md · 71 lines

What it actually says

Drupal Form Alter

OOP Hook (Drupal 10.3+ / 11)

// src/Hook/MyModuleHooks.php
namespace Drupal\my_module\Hook;

use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Core\Form\FormStateInterface;

final class MyModuleHooks {

  #[Hook('form_alter')]
  public function formAlter(array &$form, FormStateInterface $form_state, string $form_id): void {
    if ($form_id === 'node_article_form' || $form_id === 'node_article_edit_form') {
      // Alter the article node form.
      $form['title']['#description'] = t('Enter a descriptive title.');
    }
  }

  // Target a specific form more efficiently
  #[Hook('form_node_article_form_alter')]
  public function formNodeArticleFormAlter(array &$form, FormStateInterface $form_state): void {
    $form['#validate'][] = [MyModuleHooks::class, 'validateArticleForm'];
    $form['actions']['submit']['#submit'][] = [MyModuleHooks::class, 'submitArticleForm'];
  }

}

Common Alterations

// Make a field required
$form['field_subtitle']['widget'][0]['value']['#required'] = TRUE;

// Add a field default value
$form['field_subtitle']['widget'][0]['value']['#default_value'] = 'Default';

// Hide a field
$form['field_internal']['#access'] = FALSE;

// Add a CSS class
$form['#attributes']['class'][] = 'my-custom-form';

// Change submit button label
$form['actions']['submit']['#value'] = t('Save Article');

// Add a custom submit handler (runs AFTER default)
$form['actions']['submit']['#submit'][] = '::mySubmitHandler';

// Prepend a custom validate handler
array_unshift($form['#validate'], '::myValidateHandler');

Get Form Object

$form_object = $form_state->getFormObject();
if ($form_object instanceof NodeForm) {
  $node = $form_object->getEntity();
}
Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 71 lines · 44 tokens per session scan A c7ee015ac9e2

Subscribe to this mod's changes

drupal-form-alter is a skill published in the GitHub repository edutrul/drupal-ai (71 stars, last pushed 3mo ago), licensed MIT. It adds 44 tokens to every session and 490 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.