moodle-amd-javascript

moodle-amd-javascript is a cursor rule for Cursor from SaadRahman01/claude-moodle-dev. It costs 0 tokens per session (2,092 once invoked), scanned A, original, MIT.

Coding rules for Moodle’s browser-side JavaScript, including its module system, templates, core helpers, and tests.

In plain words
What is it for?
Adding interactive plugin features, calling Moodle web services, rendering templates, showing dialogs or notifications, and testing browser code.
Why use it?
It prevents common mistakes such as editing generated files, using incorrect module names, or loading outdated builds.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Adding interactive plugin features, calling Moodle web services, rendering templates, showing dialogs or notifications, and testing browser code.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/saadrahman01/claude-moodle-dev/moodle-amd-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.

Clone the repo
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev

Made for: Cursor.

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

README.md
[![agentmods](https://agentmods.dev/badge/rules/saadrahman01/claude-moodle-dev/moodle-amd-javascript/github.svg)](https://agentmods.dev/rules/saadrahman01/claude-moodle-dev/moodle-amd-javascript)
Your own site
<a href="https://agentmods.dev/rules/saadrahman01/claude-moodle-dev/moodle-amd-javascript"><img src="https://agentmods.dev/badge/rules/saadrahman01/claude-moodle-dev/moodle-amd-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 moodle-amd-javascript

Your own site · 80×15
<a href="https://agentmods.dev/rules/saadrahman01/claude-moodle-dev/moodle-amd-javascript"><img src="https://agentmods.dev/badge/rules/saadrahman01/claude-moodle-dev/moodle-amd-javascript.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,092 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.00000 $0.02092
Opus 5.5 $0.00000 $0.00837
Sonnet 5.5 $0.00000 $0.00418
Haiku 4.5 $0.00000 $0.00209

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

Security

Grade A, and why

moodle-amd-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.

adapters/cursor/.cursor/rules/moodle-amd-javascript.mdc · 252 lines

How it starts

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

Moodle AMD JavaScript

Overview

Moodle uses AMD (RequireJS) for browser JS. Source goes in <plugin>/amd/src/*.js (ES6+), built into minified AMD in amd/build/*.min.js via grunt. Never edit amd/build/ directly. Modules import Moodle core helpers via string IDs (core/ajax, core/str, core/templates).

When to Use

  • Adding interactive JS to a plugin
  • Calling a web service from the browser (core/ajax)
  • Rendering a Mustache template client-side
  • Showing a modal, notification, or toast
  • Building a custom AMD module + grunt config
  • Debugging "module not found" / "build out of date" warnings

Skip when: writing pure backend PHP — use moodle-plugin-development.

File layout

<plugin>/
  amd/
    src/
      foo.js              # ES6 source — edit this
      bar.js
    build/                # generated; commit but never hand-edit
      foo.min.js
      foo.min.js.map

Module ID at runtime = <component>/<filename> (no extension):

  • local/example/amd/src/marker.js → local_example/marker
  • mod/quiz/amd/src/preflight.js → mod_quiz/preflight

Module skeleton

// amd/src/marker.js
import Ajax from 'core/ajax';
import Notification from 'core/notification';
import {get_string as getString} from 'core/str';
import Templates from 'core/templates';

const SELECTORS = {
    BUTTON: '[data-action="mark-present"]',
    ROW: '[data-region="attendance-row"]',
};

/**
 * Initialise: bind click handlers.
 *
 * @param {number} sessionid
 */
export const init = (sessionid) => {
    document.addEventListener('click', async (e) => {
        const btn = e.target.closest(SELECTORS.BUTTON);
        if (!btn) {
            return;
        }
        e.preventDefault();
        const userid = parseInt(btn.dataset.userid, 10);
        try {
            const result = await markPresent(sessionid, userid);
            const html = await Templates.render('local_example/row', result);
            const row = btn.closest(SELECTORS.ROW);
            Templates.replaceNode(row, html, '');
        } catch (err) {
            Notification.exception(err);
        }
    });
};

const markPresent = (sessionid, userid) => {
    const request = Ajax.call([{
        methodname: 'local_example_mark_present',
        args: {sessionid, userid},
    }]);
    return request[0];
};

Read the full file on GitHub · 252 lines

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 · 252 lines · 0 tokens per session scan A 3d335d52d8ac

Subscribe to this mod's changes

moodle-amd-javascript is a cursor rule published in the GitHub repository SaadRahman01/claude-moodle-dev (40 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,092 tokens. 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.