moodle-capability-audit

moodle-capability-audit is a command for Claude Code from SaadRahman01/claude-moodle-dev. It costs 0 tokens per session (873 once invoked), scanned A, original, MIT.

A command that audits a Moodle plugin’s permissions, called capabilities, against the places where the code checks or uses them.

In plain words
What is it for?
Use it to inspect a Moodle plugin path, compare db/access.php with runtime checks, and report errors and warnings.
Why use it?
It finds missing permission declarations, unused permissions, risky settings, and language entries that could cause access or security problems.

Command for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the moodle-dev plugin — 13 skills, 8 commands, 2 agents shipped together

Good fit Use it to inspect a Moodle plugin path, compare db/access.php with runtime checks, and report errors and warnings.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/saadrahman01/claude-moodle-dev/moodle-capability-audit
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: Claude Code.

Or install moodle-dev, the plugin that ships this one along with the rest of its 13 skills, 8 commands, 2 agents.

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-capability-audit

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

Your own site · 80×15
<a href="https://agentmods.dev/commands/saadrahman01/claude-moodle-dev/moodle-capability-audit"><img src="https://agentmods.dev/badge/commands/saadrahman01/claude-moodle-dev/moodle-capability-audit.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 873 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.00873
Opus 5 $0.00000 $0.00436
Sonnet 5 $0.00000 $0.00175
Haiku 4.5 $0.00000 $0.00087

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

Security

Grade A, and why

moodle-capability-audit 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 8d 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/aider/commands/moodle-capability-audit.md · 67 lines

How it starts

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

/moodle-capability-audit

Audit a plugin's capabilities — verifies db/access.php declarations match runtime require_capability/has_capability calls, checks risk bitmasks, default archetypes, and lang strings.

Audit capability declarations vs. usage for the plugin at the given path.

User's input:

Procedure

  1. Resolve plugin path (default: cwd). Read version.php to get the frankenstyle $plugin->component.
  2. Activate moodle-security-audit and moodle-plugin-development skills.
  3. Parse db/access.php — extract declared capabilities into a set.
  4. Grep the plugin for runtime capability use:
    • require_capability\(['"]([^'"]+)['"]
    • has_capability\(['"]([^'"]+)['"]
    • require_all_capabilities\(\[(.*?)\]
    • require_any_capability\(\[(.*?)\]
    • In db/services.php: 'capabilities' => '...'
    • In external function execute_parameters files: same as above
  5. Cross-reference:
    • Used but not declared -> ERROR (call will always deny).
    • Declared but never used -> WARNING (dead capability, or used via JS/dynamic — flag for human check).
    • Declared with risk bitmask but riskBitmask=0 for caps that grant write/admin -> WARNING.
  6. For each declared capability, verify:
    • captype is one of read/write.
    • contextlevel is a valid CONTEXT_* constant.
    • archetypes includes a sensible default (most caps should have 'manager' => CAP_ALLOW at minimum).
    • riskbitmask uses correct combination: RISK_SPAM | RISK_XSS | RISK_PERSONAL | RISK_CONFIG | RISK_DATALOSS | RISK_MANAGETRUST.
    • A lang string exists in lang/en/<component>.php as $string['<component>:<capname-suffix>'] = '...' AND a <capname-suffix>_help if non-trivial.
  7. Check for clone or extends of risky caps (e.g., cloning moodle/site:config) — flag.
  8. If any cap uses CONTEXT_SYSTEM and grants write/admin, ensure RISK_CONFIG or RISK_DATALOSS is set.

Output

# Capability audit: <component>

## Summary
- Declared: N | Used: N | Orphan declarations: N | Undeclared usages: N
- Risk-bitmask issues: N | Missing lang strings: N

## Errors
- foo.php:88 — `has_capability('<component>:doit', ...)` but `<component>:doit` not in db/access.php

## Warnings
- db/access.php:42 — `<component>:legacy` declared but no runtime usage (dead?)
- db/access.php:60 — `<component>:writeall` is write/CONTEXT_SYSTEM but no RISK_CONFIG flag

## Missing lang strings
- `<component>:doit` — add `$string['<component>:doit'] = '...';` to lang/en/<component>.php
- `<component>:doit_help` — add `_help` for non-trivial caps

## Suggested next steps
1. Add missing declarations to db/access.php, bump version.php
2. Remove dead caps or document why kept (e.g., used by sibling plugin)
3. Add risk bitmasks
4. Run `php admin/cli/upgrade.php` after version bump to apply changes

Read the full file on GitHub · 67 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. 8d ago First seen · 67 lines · 0 tokens per session scan A ac4bef11dc10

Subscribe to this mod's changes

moodle-capability-audit is a command published in the GitHub repository SaadRahman01/claude-moodle-dev (36 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 873 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.