drupal-javascript

drupal-javascript is a skill for Claude Code from edutrul/drupal-ai. It costs 33 tokens per session (668 once invoked), scanned A, original, MIT.

A reference skill for adding browser-side JavaScript to Drupal websites.

In plain words
What is it for?
Use it to define JavaScript and CSS libraries, attach them in Twig templates, use Drupal behaviors and settings, and create custom AJAX commands.
Why use it?
It explains Drupal-specific setup so custom scripts load correctly and do not process the same page elements repeatedly.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

Good fit Use it to define JavaScript and CSS libraries, attach them in Twig templates, use Drupal behaviors and settings, and create custom AJAX commands.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/edutrul/drupal-ai/drupal-javascript
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.

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

Made for: Claude Code.

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-javascript

README.md
[![agentmods](https://agentmods.dev/badge/skills/edutrul/drupal-ai/drupal-javascript/github.svg)](https://agentmods.dev/skills/edutrul/drupal-ai/drupal-javascript)
Your own site
<a href="https://agentmods.dev/skills/edutrul/drupal-ai/drupal-javascript"><img src="https://agentmods.dev/badge/skills/edutrul/drupal-ai/drupal-javascript/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for drupal-javascript

Your own site · 80×15
<a href="https://agentmods.dev/skills/edutrul/drupal-ai/drupal-javascript"><img src="https://agentmods.dev/badge/skills/edutrul/drupal-ai/drupal-javascript.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 33 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 668 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00033 $0.00668
Opus 5.5 $0.00013 $0.00267
Sonnet 5.5 $0.00007 $0.00134
Haiku 4.5 $0.00003 $0.00067

Measured 1mo ago against content hash daef6ee73162, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

drupal-javascript 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 1mo 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-javascript/SKILL.md · 124 lines

How it starts

The opening of the file, as written. The whole thing — 124 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Drupal JavaScript

Defining a Library (*.libraries.yml)

# my_module.libraries.yml
my-behavior:
  version: 1.0
  js:
    js/my-behavior.js: {}
  css:
    component:
      css/my-style.css: {}
  dependencies:
    - core/drupal
    - core/jquery
    - core/once

Drupal Behavior Pattern

// js/my-behavior.js
(function (Drupal, once) {
  'use strict';

  Drupal.behaviors.myBehavior = {
    attach(context, settings) {
      // Use `once` to prevent double-processing
      once('my-behavior', '.my-selector', context).forEach(function (element) {
        // Process element
        element.addEventListener('click', function (e) {
          e.preventDefault();
          // Handle click
        });
      });
    },
    detach(context, settings, trigger) {
      // Clean up if needed (e.g., 'unload' trigger)
    },
  };
}(Drupal, once));

Attaching a Library in Twig

Attach a JavaScript/CSS library from a Twig template:

{{ attach_library('my_module/my-behavior') }}

Accessing drupalSettings in JS

Drupal.behaviors.myBehavior = {
  attach(context, settings) {
    const myKey = settings.myModule?.key;
    if (myKey) {
      console.log('Value:', myKey);
    }
  },
};

AJAX Commands from PHP

use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Core\Ajax\InvokeCommand;
use Drupal\Core\Ajax\HtmlCommand;

$response = new AjaxResponse();
$response->addCommand(new ReplaceCommand('#wrapper', $build));
$response->addCommand(new HtmlCommand('#message', $this->t('Done!')));
$response->addCommand(new InvokeCommand('.my-class', 'addClass', ['active']));
return $response;

Custom AJAX Command

// Register command
Drupal.AjaxCommands.prototype.myCommand = function (ajax, response, status) {
  document.querySelector(response.selector).textContent = response.data;
};
// PHP side
use Drupal\Core\Ajax\CommandInterface;

final class MyCommand implements CommandInterface {
  public function __construct(
    private readonly string $selector,
    private readonly string $data,
  ) {}

  public function render(): array {
    return [
      'command' => 'myCommand',
      'selector' => $this->selector,
      'data' => $this->data,
    ];
  }
}

Read the full file on GitHub · 124 lines

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. 1mo ago First seen · 124 lines · 33 tokens per session scan A daef6ee73162

Subscribe to this mod's changes

drupal-javascript is a skill published in the GitHub repository edutrul/drupal-ai (72 stars, last pushed 4mo ago), licensed MIT. It adds 33 tokens to every session and 668 once invoked, about $0.0001 per session on Opus 5.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.

Related

Other skills, from other repositories