cmd-moodle-capability-audit

cmd-moodle-capability-audit is a cursor rule for Cursor from SaadRahman01/claude-moodle-dev. It costs 49 tokens per session (886 once invoked), scanned A, original, MIT.

A permission audit for Moodle plugins. Moodle permissions, called capabilities, control which users can perform actions in particular parts of a site.

In plain words
What is it for?
Use it to review capability declarations, runtime permission checks, risk settings, context levels, and default roles in a Moodle plugin.
Why use it?
It finds mismatches between permissions declared by a plugin and permissions checked by its code, which can cause access failures or unsafe defaults.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

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.

agentmods
npx agentmods add rules/saadrahman01/claude-moodle-dev/cmd-moodle-capability-audit
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 cmd-moodle-capability-audit

README.md
[![agentmods](https://agentmods.dev/badge/rules/saadrahman01/claude-moodle-dev/cmd-moodle-capability-audit.svg)](https://agentmods.dev/rules/saadrahman01/claude-moodle-dev/cmd-moodle-capability-audit)
Your own site
<a href="https://agentmods.dev/rules/saadrahman01/claude-moodle-dev/cmd-moodle-capability-audit"><img src="https://agentmods.dev/badge/rules/saadrahman01/claude-moodle-dev/cmd-moodle-capability-audit.svg" alt="Measured on agentmods" height="20"></a>
Per session 49 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 886 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00049 $0.00886
Opus 5 $0.00024 $0.00443
Sonnet 5 $0.00010 $0.00177
Haiku 4.5 $0.00005 $0.00089

Measured 6d ago against content hash 468b9fc2c5b3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

cmd-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 6d 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/cmd-moodle-capability-audit.mdc · 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.

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

User's input: {user_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. 6d ago First seen · 67 lines · 886 tokens per session scan A 468b9fc2c5b3

Subscribe to this mod's changes

cmd-moodle-capability-audit is a cursor rule published in the GitHub repository SaadRahman01/claude-moodle-dev (35 stars, last pushed 2mo ago), licensed MIT. It adds 49 tokens to every session and 886 once invoked, about $0.0002 per session on Opus 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.