Moodle Plugin Development logo

Moodle Plugin Development

Community
SaadRahman01
moodle-plugin-development

Use when creating, modifying, upgrading, or reviewing Moodle plugins (local, mod, block, format, theme, auth, enrol, report, qtype, filter, repository) - covers version.php, db/install.xml + upgrade.php, db/access.php capabilities, db/services.php web services, lang strings, classes/ PSR-4 autoloading, lib.php hooks, settings.php, privacy provider, and Moodle coding standards.

Overview

PublisherSaadRahman01
Repositoryclaude-moodle-dev
Skill namemoodle-plugin-development
Stars
42
Forks
7
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by SaadRahman01 on GitHub. Read the source before you install it.

Installation

Install the Moodle Plugin Development AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/SaadRahman01/claude-moodle-dev/tree/main/skills/moodle-plugin-development
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git /tmp/claude-moodle-dev
mkdir -p .claude/skills
cp -r /tmp/claude-moodle-dev/skills/moodle-plugin-development .claude/skills/moodle-plugin-development
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Moodle Plugin Development in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Moodle Plugin Development on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Moodle Plugin Development is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Moodle Plugin Development

Overview

Moodle plugins follow strict frankenstyle naming and a fixed file layout. Every plugin lives under a type-specific directory (local/, mod/, blocks/, course/format/, theme/, auth/, enrol/, report/, question/type/, filter/, repository/, etc.) and is identified by <type>_<name> (e.g., local_school, mod_quiz, format_schoolgram).

Core principle: Moodle code must declare defined('MOODLE_INTERNAL') || die(); at top of every PHP file (except classes under classes/ autoloaded via PSR-4), use $DB for all DB access, use get_string() for user-facing text, and bump version.php for any DB or capability change.

When to Use

  • Creating new plugin under local/, mod/, blocks/, course/format/, theme/, etc.
  • Adding/modifying DB tables → db/install.xml + db/upgrade.php
  • Adding capabilities → db/access.php
  • Adding web services / external functions → db/services.php + classes/external/
  • Adding scheduled tasks → db/tasks.php + classes/task/
  • Adding events / observers → db/events.php + classes/event/
  • Adding admin settings page → settings.php
  • Translating strings → lang/<lang>/<component>.php
  • Reviewing PR for Moodle coding-style compliance
  • Bumping version.php after schema/capability change

Skip when: working purely on frontend AMD modules without backend changes, or non-Moodle PHP code.

Plugin Skeleton

Minimum files for a local_<name> plugin:

local/<name>/
  version.php                    # required: component, version, requires, maturity
  lang/en/local_<name>.php       # required: 'pluginname' string
  lib.php                        # optional: hooks (extend_navigation, pluginfile, etc.)
  settings.php                   # optional: admin settings page
  db/
    install.xml                  # DB schema (edit via /admin/tool/xmldb/)
    upgrade.php                  # versioned upgrade steps
    access.php                   # capabilities
    services.php                 # web service definitions
    tasks.php                    # scheduled tasks
    events.php                   # event observers
    caches.php                   # cache definitions
  classes/                       # PSR-4: \local_<name>\foo\bar -> classes/foo/bar.php
    external/                    # external (web service) functions
    task/                        # scheduled task classes
    event/                       # custom events
    privacy/provider.php         # GDPR provider (REQUIRED)
  templates/                     # Mustache templates
  amd/src/                       # ES modules (built via grunt -> amd/build/)
  tests/                         # PHPUnit + Behat

version.php Template

php
<?php
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'local_example';      // frankenstyle, must match dir
$plugin->version   = 2026042500;           // YYYYMMDDXX, bump on any db/capability change
$plugin->requires  = 2024100700;           // min Moodle version (4.5 LTS); use 2025041400 for 5.0+, 2025100600 for 5.1+, 2026042000 for 5.2+
$plugin->release   = '1.0.0';
$plugin->maturity  = MATURITY_STABLE;      // ALPHA | BETA | RC | STABLE
$plugin->dependencies = ['mod_quiz' => 2024100700];  // optional

db/install.xml + upgrade.php

  • Edit install.xml via Moodle XMLDB editor (Site admin -> Development -> XMLDB editor) — never hand-edit.
  • Every schema change requires:
    1. Bump $plugin->version in version.php
    2. Add upgrade step in db/upgrade.php keyed on old version:
php
function xmldb_local_example_upgrade($oldversion) {
    global $DB;
    $dbman = $DB->get_manager();

    if ($oldversion < 2026042500) {
        $table = new xmldb_table('local_example_items');
        $field = new xmldb_field('status', XMLDB_TYPE_INTEGER, '4', null,
            XMLDB_NOTNULL, null, '0', 'name');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        upgrade_plugin_savepoint(true, 2026042500, 'local', 'example');
    }
    return true;
}

db/access.php Capabilities

php
$capabilities = [
    'local/example:view' => [
        'captype'      => 'read',
        'contextlevel' => CONTEXT_SYSTEM,
        'archetypes'   => [
            'user'           => CAP_ALLOW,
            'editingteacher' => CAP_ALLOW,
        ],
    ],
];

Runtime check: require_capability('local/example:view', $context); or has_capability(...).

db/services.php (Web Services / AJAX)

php
$functions = [
    'local_example_get_items' => [
        'classname'    => 'local_example\external\get_items',
        'methodname'   => 'execute',
        'description'  => 'Return items',
        'type'         => 'read',
        'ajax'         => true,
        'capabilities' => 'local/example:view',
    ],
];

External class extends \core_external\external_api (Moodle 4.2+; older = external_api) and defines execute_parameters(), execute(), execute_returns().

Lang Strings

lang/en/local_example.php:

php
$string['pluginname']    = 'Example';
$string['example:view']  = 'View example';        // capability strings: <plugin>:<cap>
$string['greeting']      = 'Hello, {$a->name}';   // placeholders

Use: get_string('greeting', 'local_example', ['name' => $user->firstname]);

DB Access — Always $DB

php
global $DB;
$DB->get_record('local_example_items', ['id' => $id], '*', MUST_EXIST);
$DB->get_records_sql('SELECT * FROM {local_example_items} WHERE status = ?', [1]);
$DB->insert_record('local_example_items', $obj);
$DB->update_record('local_example_items', $obj);
$DB->delete_records('local_example_items', ['id' => $id]);

Never mysqli_* / PDO. Always use {tablename} placeholder (Moodle prefixes). Always bind params, never concatenate.

Hooks via lib.php

Common Moodle callbacks (function name = <component>_<hookname>):

  • local_example_extend_navigation(global_navigation $nav) — add nav nodes
  • local_example_before_http_headers() — runs before headers
  • local_example_extend_settings_navigation($settingsnav, $context)
  • local_example_pluginfile($course, $cm, $context, $filearea, $args, $forcedl, $options) — serve file area

Moodle 4.4+: prefer the new hooks API (\core\hook\manager) over magic callbacks where available.

Output — Renderers + Templates

  • HTML via $OUTPUT->render_from_template('local_example/foo', $data) (Mustache: templates/foo.mustache)
  • Custom renderer: classes/output/renderer.php extends plugin_renderer_base
  • Never echo raw HTML in business logic; always go through renderer or template

Privacy (GDPR) — Required

Every plugin must declare privacy. Minimum (no user data stored):

php
// classes/privacy/provider.php
namespace local_example\privacy;
defined('MOODLE_INTERNAL') || die();
class provider implements \core_privacy\local\metadata\null_provider {
    public static function get_reason(): string {
        return 'privacy:metadata';
    }
}

If plugin stores user data, implement \core_privacy\local\request\plugin\provider and define get_metadata, export_user_data, delete_data_for_user_in_context, delete_data_for_users, get_contexts_for_userid, get_users_in_context.

Quick Reference

TaskFileBump version?
Add DB table/fielddb/install.xml + db/upgrade.phpYes
Add capabilitydb/access.php + lang stringYes
Add web service fndb/services.php + classes/external/Yes
Add scheduled taskdb/tasks.php + classes/task/Yes
Add event observerdb/events.phpYes
Add cache definitiondb/caches.phpYes
Add stringlang/en/<component>.phpNo
Add settingssettings.phpNo
Add templatetemplates/*.mustacheNo
Add rendererclasses/output/renderer.phpNo

Coding Standards

  • 4-space indent, no tabs
  • Opening <?php on line 1, no closing ?> at end of pure PHP files
  • defined('MOODLE_INTERNAL') || die(); immediately after license block (skip in classes/ PSR-4 files)
  • snake_case for functions/vars, PascalCase for classes
  • Run vendor/bin/phpcs --standard=moodle <path> before commit (local_codechecker plugin or moodle-cs ruleset)
  • All user-facing strings via get_string(), never hard-coded English
  • GPL-3.0-or-later license header on every PHP file

Common Mistakes

MistakeFix
Hand-editing install.xmlUse XMLDB editor at /admin/tool/xmldb/
Forgetting to bump version.php after schema changeBump + add upgrade.php step + upgrade_plugin_savepoint
Using raw SQL with {} quoting wrongUse {tablename} and ? / named params, never string concat
MOODLE_INTERNAL check inside classes/ PSR-4 fileRemove — autoloaded files don't need it
Storing user data without privacy providerImplement \core_privacy\local\request\plugin\provider
Hard-coded English strings in PHP/MustacheMove to lang/en/<component>.php + get_string / {{#str}}
Forgetting require_capability() on entry pointsAlways require_login() + capability check early
Not purging caches after version.php bumpphp admin/cli/upgrade.php or Site admin -> Purge caches
Direct $_GET/$_POST accessUse required_param() / optional_param() with type
Missing sesskey() check on state-changing requestsCall require_sesskey() on POST handlers

Plugin Type Cheatsheet

TypeDirFrankenstyleExtra required files
Locallocal/<name>local_<name>none beyond skeleton
Activity modulemod/<name>mod_<name>mod_form.php, view.php, lib.php w/ <name>_add_instance etc.
Blockblocks/<name>block_<name>block_<name>.php extends block_base
Course formatcourse/format/<name>format_<name>format.php, lib.php extends core_courseformat\base
Themetheme/<name>theme_<name>config.php, scss/, layout/
Authauth/<name>auth_<name>auth.php extends auth_plugin_base
Enrolenrol/<name>enrol_<name>lib.php extends enrol_plugin
Question typequestion/type/<name>qtype_<name>questiontype.php, question.php, renderer.php
Filterfilter/<name>filter_<name>filter.php extends moodle_text_filter
Repositoryrepository/<name>repository_<name>lib.php extends repository

Security Checklist

  • require_login() (and require_capability()) at top of every entry script
  • require_sesskey() on every state-changing POST
  • required_param($name, PARAM_INT) / optional_param(...) — never raw $_REQUEST
  • Use $DB->... with placeholders — no SQL concat
  • Escape output: s(), format_string(), format_text()
  • File serving via pluginfile.php + <component>_pluginfile() callback, never direct path

CLI Helpers

bash
php admin/cli/upgrade.php --non-interactive    # apply pending upgrades
php admin/cli/purge_caches.php                  # clear all caches
php admin/tool/behat/cli/init.php               # init behat tests
vendor/bin/phpunit --testsuite local_example_testsuite
vendor/bin/phpcs --standard=moodle local/example

Testing

  • PHPUnit: tests/<thing>_test.php extending advanced_testcase, use $this->resetAfterTest(), generators via self::getDataGenerator()->get_plugin_generator('local_example')
  • Behat: tests/behat/*.feature with @local_example tag, step definitions in tests/behat/behat_local_example.php

References

Frequently asked questions

What does the Moodle Plugin Development AI skill do?

Use when creating, modifying, upgrading, or reviewing Moodle plugins (local, mod, block, format, theme, auth, enrol, report, qtype, filter, repository) - covers version.php, db/install.xml + upgrade.php, db/access.php capabilities, db/services.php web services, lang strings, classes/ PSR-4 autoloading, lib.php hooks, settings.php, privacy provider, and Moodle coding standards.

Why use Moodle Plugin Development on TypingMind?

Because you install it once and use it with any model. Moodle Plugin Development is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Moodle Plugin Development in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/SaadRahman01/claude-moodle-dev/tree/main/skills/moodle-plugin-development. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Moodle Plugin Development?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Moodle Plugin Development?

As many as you like. As long as a model supports skills, you can use Moodle Plugin Development with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Moodle Plugin Development AI skill free?

Yes. It is published on GitHub by SaadRahman01 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇