Automatically validate and fix Moodle PHP code for PSR-12 compliance with Moodle-specific exceptions (lowercase_with_underscores naming, frankenstyle prefixes). Activates when working with Moodle plugin PHP files or when code standards issues are detected.
/plugin marketplace add astoeffer/plugin-marketplace/plugin install moodle-dev-pro@astoeffer-dev-pluginsThis skill is limited to using the following tools:
This skill activates automatically when:
Moodle follows PSR-12 with specific exceptions for legacy compatibility.
// ❌ PSR-12 Standard (PascalCase)
class FolderBrowser {}
// ✅ Moodle Standard (lowercase_with_underscores)
class folder_browser {}
// ❌ PSR-12 Standard (camelCase)
public function getUserData() {}
// ✅ Moodle Standard (lowercase_with_underscores)
public function get_user_data() {}
// ❌ PSR-12 Standard (camelCase)
$userData = [];
// ✅ Moodle Standard (lowercase_with_underscores)
$user_data = [];
All functions, classes, and namespaces must include component prefix:
// ❌ Missing component prefix
function get_folder_contents() {}
class folder_browser {}
// ✅ With frankenstyle prefix
function mod_nextcloudfolder_get_folder_contents() {}
class mod_nextcloudfolder_folder_browser {}
// ✅ Correct
function example() {
if ($condition) {
do_something();
}
}
// ⚠️ Moodle allows up to 180 characters per line
$result = $DB->get_record_sql('SELECT * FROM {table} WHERE field1 = ? AND field2 = ? AND field3 = ?', [$param1, $param2, $param3]);
// ✅ Correct
if ($condition) {
// code
}
// ✅ New line for functions/classes
function my_function()
{
// code
}
// ✅ Correct namespace with frankenstyle
namespace mod_nextcloudfolder\local;
class helper {
// ...
}
// ✅ One per line, alphabetically sorted
use mod_nextcloudfolder\local\api;
use mod_nextcloudfolder\local\helper;
# Use Read tool to examine PHP file
Check for:
# Moodle code checker
vendor/bin/phpcs --standard=moodle path/to/plugin/
# Or use dev helper if available
./dev.sh check
Automatic fixes:
vendor/bin/phpcbf --standard=moodle path/to/plugin/
Manual fixes: Use Edit tool for:
# Rerun phpcs to confirm clean
vendor/bin/phpcs --standard=moodle path/to/plugin/
// ❌ Before
function getUserFolders($userid) {
return $DB->get_records('folders', ['userid' => $userid]);
}
// ✅ After
function mod_nextcloudfolder_get_user_folders($userid) {
return $DB->get_records('nextcloudfolder', ['userid' => $userid]);
}
// ❌ Before
function get_folders() {
// ...
}
// ✅ After
/**
* Get all folders for current user.
*
* @return array Array of folder objects
*/
function mod_nextcloudfolder_get_folders() {
// ...
}
// ❌ Before
class FolderApi {
// ...
}
// ✅ After
namespace mod_nextcloudfolder\local;
/**
* Folder API helper class.
*
* @package mod_nextcloudfolder
* @copyright 2024 Your Name
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class folder_api {
// ...
}
// ❌ Before (2 spaces or tabs)
function example() {
if ($condition) {
do_something();
}
}
// ✅ After (4 spaces)
function example() {
if ($condition) {
do_something();
}
}
// ❌ Before (>180 chars)
$result = $DB->get_record_sql('SELECT * FROM {table} WHERE field1 = ? AND field2 = ? AND field3 = ? AND field4 = ? AND field5 = ?', [$param1, $param2, $param3, $param4, $param5]);
// ✅ After (split logically)
$sql = 'SELECT * FROM {table}
WHERE field1 = ? AND field2 = ?
AND field3 = ? AND field4 = ?
AND field5 = ?';
$params = [$param1, $param2, $param3, $param4, $param5];
$result = $DB->get_record_sql($sql, $params);
After validation and fixes:
✅ PSR-12 Moodle Compliance Check
File: mod/nextcloudfolder/lib.php
Status: ✅ PASSED (or ❌ FAILED)
Issues Fixed:
- ✓ Renamed getUserData() → get_user_data()
- ✓ Added frankenstyle prefix to class folder_browser
- ✓ Fixed indentation (27 lines)
- ✓ Added missing PHPDoc blocks (5 functions)
- ✓ Split 3 lines exceeding 180 characters
Remaining Issues: 0
Next: Run `vendor/bin/phpcs --standard=moodle mod/nextcloudfolder/` to verify.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.