
Moodle hooks API
Guides building and migrating Moodle 4.4+ hook classes, listeners and tests
Moodle hooks API is an open-source agent skill for developer tools. It is available on Claude Code.
- Scripts
- None
- Platforms
- Claude Code
- GitHub stars
- 44
- Last commit
- License
- MIT
- Listing updated
Similar skills
About Moodle hooks API
This skill walks an agent through Moodle's typed Hooks API, which replaces older magic callback functions such as the _extend_navigation and _before_http_headers family. It covers writing hook classes, registering listeners in db/hooks.php with priorities, dispatching hooks through the core dependency injection container, and moving legacy callbacks into listener classes.
The guidance also covers the practical steps around a change: purging caches after editing the hook registration file, writing PHPUnit-style tests that exercise both the active and no-op branches of a listener, listing registered hooks from the command line, and bumping the plugin version. It notes common pitfalls such as dispatching hooks from constructors and relying on priority order for correctness.
The skill is written for Moodle 4.4 and later and expects a Moodle plugin codebase in PHP, with access to the core hook classes in lib/classes/hook/ to find the right replacement for each legacy callback.
When your agent uses it
Use when implementing or migrating to the Moodle 4.4+ Hooks API. Covers hook class authoring (db/hooks.php), callback registration, dispatching, replacing legacy magic callbacks (extend_navigation, before_http_headers, etc.), and testing hook listeners.
From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.
What it can access
From a static check of its 1 file (7 KB) on GitHub on 3 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.
Check another skill before you install it.
Install
This skill ships in the moodle-dev plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):
/plugin marketplace add SaadRahman01/claude-moodle-dev
/plugin install moodle-dev@moodle-devOr copy only this skill to ~/.claude/skills/moodle-hooks-api:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/moodle-hooks-api &&
cp -R "$tmp/skills/moodle-hooks-api" ~/.claude/skills/moodle-hooks-api &&
rm -rf "$tmp"For one project only, put the folder in .claude/skills/moodle-hooks-api inside it instead.
Copy the skill folder to ~/.agents/skills/moodle-hooks-api to use it in every repository:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/moodle-hooks-api &&
cp -R "$tmp/skills/moodle-hooks-api" ~/.agents/skills/moodle-hooks-api &&
rm -rf "$tmp"For one repository only, put the folder in .agents/skills/moodle-hooks-api inside it instead.
Copy the skill folder to ~/.cursor/skills/moodle-hooks-api to use it in every project:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/moodle-hooks-api &&
cp -R "$tmp/skills/moodle-hooks-api" ~/.cursor/skills/moodle-hooks-api &&
rm -rf "$tmp"For one project only, put the folder in .cursor/skills/moodle-hooks-api inside it instead.
Run in a terminal (add --scope workspace to install it for the current workspace only):
gemini skills install https://github.com/SaadRahman01/claude-moodle-dev.git --path skills/moodle-hooks-apiOr copy the folder to ~/.gemini/skills/moodle-hooks-api yourself.
For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/moodle-hooks-api:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/moodle-hooks-api &&
cp -R "$tmp/skills/moodle-hooks-api" ~/.copilot/skills/moodle-hooks-api &&
rm -rf "$tmp"For one project only, put the folder in .github/skills/moodle-hooks-api inside it instead.
Get the folder:
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.gitThen copy claude-moodle-dev/skills/moodle-hooks-api into your agent's skills folder as moodle-hooks-api. Agents that support SKILL.md read one folder per skill.
What it does
- Hook class authoring
- Shows how to define a typed hook payload with optional setters and stoppable behaviour.
- Listener registration
- Explains mapping hook classes to listener methods in db/hooks.php with priorities.
- Legacy callback migration
- Lists common magic callbacks and their hook replacements, with migration steps.
- Hook listener testing
- Provides test patterns for dispatching hooks and asserting listener output.
- Hook listing command
- Documents a CLI command to list registered hooks and their listeners.
- Common pitfalls checklist
- Covers cache purging, priority caveats, DI container use and pre-4.4 backporting.
Good for
- Migrate a plugin off _extend_navigation and _before_http_headers callbacks
- Inject a banner into Moodle pages for logged-in users via a hook listener
- Write a typed hook class that other plugins can listen to
- Add PHPUnit tests covering a hook listener's active and guest branches
- List which listeners are registered for a given Moodle hook
Moodle hooks API FAQ
What Moodle version does this require?
The skill targets Moodle 4.4 and later, since the Hooks API was introduced in 4.4.
Does Moodle hooks API replace the Events API?
No. The skill says hooks are for modifying behaviour, while core events are for reacting to facts such as audit logging, and it advises using events in that case.
Where is the listener configuration stored?
Listeners are registered in a db/hooks.php file in the plugin, mapping a hook class to a callback and priority. Caches must be purged after changes.
Are scripts included with the skill?
No, the skill is a single SKILL.md file with no bundled scripts; it references existing Moodle CLI commands.
How do I install Moodle hooks API in Claude Code?
Copy the skill folder from GitHub to ~/.claude/skills/moodle-hooks-api to use it in all your projects, or to .claude/skills/moodle-hooks-api in one project. Or install the moodle-dev plugin, which includes it: /plugin marketplace add SaadRahman01/claude-moodle-dev, then /plugin install moodle-dev@moodle-dev.
Does Moodle hooks API run scripts?
No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.
Which AI agents can use Moodle hooks API?
Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.
What are the best alternatives to Moodle hooks API?
The closest alternatives to Moodle hooks API are Moodle upgrade migration, Moodle phpunit testing, Moodle plugin development, Moodle mobile app and Moodle behat testing.
Where this comes from
- Description: from the skill's own SKILL.md.
More from SaadRahman01/claude-moodle-dev

Guides building and calling Moodle web services: external functions, tokens and schemas
- Open source
- 44 GitHub stars
- Developer tools

Guides agents to build Moodle plugin UI that meets WCAG 2.1 AA accessibility rules
- Open source
- 44 GitHub stars
- Developer tools

Guides writing Moodle browser JavaScript as AMD modules with grunt builds and tests
- Open source
- 44 GitHub stars
- Developer tools

Guides writing and running Behat acceptance tests for Moodle plugins
- Open source
- 44 GitHub stars
- Developer tools

Guides building Moodle plugin UI that renders inside the Moodle Mobile app
- Open source
- 44 GitHub stars
- Developer tools

Guides an agent through performance tuning for Moodle plugins: caching, queries, tasks
- Open source
- 44 GitHub stars
- Developer tools

