[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CB83BK5V6GW7YZP4Y4BKTY":3,"skill-same:01M7CB83BK5V6GW7YZP4Y4BKTY":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":6,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M7CB83BK5V6GW7YZP4Y4BKTY","moodle-external-api-development",null,"This skill guides you through creating custom external web service APIs for Moodle LMS, following Moodle's external API framework and coding standards.","YYC-Cube\u002FYYC3-Knowledge-Base","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79J2PHVK3F6ZBYT8K2SCZCW",1,"MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Skills-技能包\u002FYYC3-Skills-技能包-antigravity-awesome-skills\u002Fplugins\u002Fantigravity-awesome-skills\u002Fskills\u002Fmoodle-external-api-development\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: moodle-external-api-development\ndescription: \"This skill guides you through creating custom external web service APIs for Moodle LMS, following Moodle's external API framework and coding standards.\"\nrisk: unknown\nsource: community\ndate_added: \"2026-02-27\"\n---\n\n# Moodle External API Development\n\nThis skill guides you through creating custom external web service APIs for Moodle LMS, following Moodle's external API framework and coding standards.\n\n## When to Use This Skill\n\n- Creating custom web services for Moodle plugins\n- Implementing REST\u002FAJAX endpoints for course management\n- Building APIs for quiz operations, user tracking, or reporting\n- Exposing Moodle functionality to external applications\n- Developing mobile app backends using Moodle\n\n## Core Architecture Pattern\n\nMoodle external APIs follow a strict three-method pattern:\n\n1. **`execute_parameters()`** - Defines input parameter structure\n2. **`execute()`** - Contains business logic\n3. **`execute_returns()`** - Defines return structure\n\n## Step-by-Step Implementation\n\n### Step 1: Create the External API Class File\n\n**Location**: `\u002Flocal\u002Fyourplugin\u002Fclasses\u002Fexternal\u002Fyour_api_name.php`\n\n```php\n\u003C?php\nnamespace local_yourplugin\\external;\n\ndefined('MOODLE_INTERNAL') || die();\nrequire_once(\"$CFG->libdir\u002Fexternallib.php\");\n\nuse external_api;\nuse external_function_parameters;\nuse external_single_structure;\nuse external_value;\n\nclass your_api_name extends external_api {\n    \n    \u002F\u002F Three required methods will go here\n    \n}\n```\n\n**Key Points**:\n- Class must extend `external_api`\n- Namespace follows: `local_pluginname\\external` or `mod_modname\\external`\n- Include the security check: `defined('MOODLE_INTERNAL') || die();`\n- Require externallib.php for base classes\n\n### Step 2: Define Input Parameters\n\n```php\npublic static function execute_parameters() {\n    return new external_function_parameters([\n        'userid' => new external_value(PARAM_INT, 'User ID', VALUE_REQUIRED),\n        'courseid' => new external_value(PARAM_INT, 'Course ID', VALUE_REQUIRED),\n        'options' => new external_single_structure([\n            'includedetails' => new external_value(PARAM_BOOL, 'Include details', VALUE_DEFAULT, false),\n            'limit' => new external_value(PARAM_INT, 'Result limit', VALUE_DEFAULT, 10)\n        ], 'Options', VALUE_OPTIONAL)\n    ]);\n}\n```\n\n**Common Parameter Types**:\n- `PARAM_INT` - Integers\n- `PARAM_TEXT` - Plain text (HTML stripped)\n- `PARAM_RAW` - Raw text (no cleaning)\n- `PARAM_BOOL` - Boolean values\n- `PARAM_FLOAT` - Floating point numbers\n- `PARAM_ALPHANUMEXT` - Alphanumeric with extended chars\n\n**Structures**:\n- `external_value` - Single value\n- `external_single_structure` - Object with named fields\n- `external_multiple_structure` - Array of items\n\n**Value Flags**:\n- `VALUE_REQUIRED` - Parameter must be provided\n- `VALUE_OPTIONAL` - Parameter is optional\n- `VALUE_DEFAULT, defaultvalue` - Optional with default\n\n### Step 3: Implement Business Logic\n\n```php\npublic static function execute($userid, $courseid, $options = []) {\n    global $DB, $USER;\n\n    \u002F\u002F 1. Validate parameters\n    $params = self::validate_parameters(self::execute_parameters(), [\n        'userid' => $userid,\n        'courseid' => $courseid,\n        'options' => $options\n    ]);\n\n    \u002F\u002F 2. Check permissions\u002Fcapabilities\n    $context = \\context_course::instance($params['courseid']);\n    self::validate_context($context);\n    require_capability('moodle\u002Fcourse:view', $context);\n\n    \u002F\u002F 3. Verify user access\n    if ($params['userid'] != $USER->id) {\n        require_capability('moodle\u002Fcourse:viewhiddenactivities', $context);\n    }\n\n    \u002F\u002F 4. Database operations\n    $sql = \"SELECT id, name, timecreated\n            FROM {your_table}\n            WHERE userid = :userid\n              AND courseid = :courseid\n            LIMIT :limit\";\n    \n    $records = $DB->get_records_sql($sql, [\n        'userid' => $params['userid'],\n        'courseid' => $params['courseid'],\n        'limit' => $params['options']['limit']\n    ]);\n\n    \u002F\u002F 5. Process and return data\n    $results = [];\n    foreach ($records as $record) {\n        $results[] = [\n            'id' => $record->id,\n            'name' => $record->name,\n            'timestamp' => $record->timecreated\n        ];\n    }\n\n    return [\n        'items' => $results,\n        'count' => count($results)\n    ];\n}\n```\n\n**Critical Steps**:\n1. **Always validate parameters** using `validate_parameters()`\n2. **Check context** using `validate_context()`\n3. **Verify capabilities** using `require_capability()`\n4. **Use parameterized queries** to prevent SQL injection\n5. **Return structured data** matching return definition\n\n### Step 4: Define Return Structure\n\n```php\npublic static function execute_returns() {\n    return new external_single_structure([\n        'items' => new external_multiple_structure(\n            new external_single_structure([\n                'id' => new external_value(PARAM_INT, 'Item ID'),\n                'name' => new external_value(PARAM_TEXT, 'Item name'),\n                'timestamp' => new external_value(PARAM_INT, 'Creation time')\n            ])\n        ),\n        'count' => new external_value(PARAM_INT, 'Total items')\n    ]);\n}\n```\n\n**Return Structure Rules**:\n- Must match exactly what `execute()` returns\n- Use appropriate parameter types\n- Document each field with description\n- Nested structures allowed\n\n### Step 5: Register the Service\n\n**Location**: `\u002Flocal\u002Fyourplugin\u002Fdb\u002Fservices.php`\n\n```php\n\u003C?php\ndefined('MOODLE_INTERNAL') || die();\n\n$functions = [\n    'local_yourplugin_your_api_name' => [\n        'classname'   => 'local_yourplugin\\external\\your_api_name',\n        'methodname'  => 'execute',\n        'classpath'   => 'local\u002Fyourplugin\u002Fclasses\u002Fexternal\u002Fyour_api_name.php',\n        'description' => 'Brief description of what this API does',\n        'type'        => 'read',  \u002F\u002F or 'write'\n        'ajax'        => true,\n        'capabilities'=> 'moodle\u002Fcourse:view', \u002F\u002F comma-separated if multiple\n        'services'    => [MOODLE_OFFICIAL_MOBILE_SERVICE] \u002F\u002F Optional\n    ],\n];\n\n$services = [\n    'Your Plugin Web Service' => [\n        'functions' => [\n            'local_yourplugin_your_api_name'\n        ],\n        'restrictedusers' => 0,\n        'enabled' => 1\n    ]\n];\n```\n\n**Service Registration Keys**:\n- `classname` - Full namespaced class name\n- `methodname` - Always 'execute'\n- `type` - 'read' (SELECT) or 'write' (INSERT\u002FUPDATE\u002FDELETE)\n- `ajax` - Set true for AJAX\u002FREST access\n- `capabilities` - Required Moodle capabilities\n- `services` - Optional service bundles\n\n### Step 6: Implement Error Handling & Logging\n\n```php\nprivate static function log_debug($message) {\n    global $CFG;\n    $logdir = $CFG->dataroot . '\u002Flocal_yourplugin';\n    if (!file_exists($logdir)) {\n        mkdir($logdir, 0777, true);\n    }\n    $debuglog = $logdir . '\u002Fapi_debug.log';\n    $timestamp = date('Y-m-d H:i:s');\n    file_put_contents($debuglog, \"[$timestamp] $message\\n\", FILE_APPEND | LOCK_EX);\n}\n\npublic static function execute($userid, $courseid) {\n    global $DB;\n\n    try {\n        self::log_debug(\"API called: userid=$userid, courseid=$courseid\");\n        \n        \u002F\u002F Validate parameters\n        $params = self::validate_parameters(self::execute_parameters(), [\n            'userid' => $userid,\n            'courseid' => $courseid\n        ]);\n\n        \u002F\u002F Your logic here\n        \n        self::log_debug(\"API completed successfully\");\n        return $result;\n\n    } catch (\\invalid_parameter_exception $e) {\n        self::log_debug(\"Parameter validation failed: \" . $e->getMessage());\n        throw $e;\n    } catch (\\moodle_exception $e) {\n        self::log_debug(\"Moodle exception: \" . $e->getMessage());\n        throw $e;\n    } catch (\\Exception $e) {\n        \u002F\u002F Log detailed error info\n        $lastsql = method_exists($DB, 'get_last_sql') ? $DB->get_last_sql() : '[N\u002FA]';\n        self::log_debug(\"Fatal error: \" . $e->getMessage());\n        self::log_debug(\"Last SQL: \" . $lastsql);\n        self::log_debug(\"Stack trace: \" . $e->getTraceAsString());\n        throw $e;\n    }\n}\n```\n\n**Error Handling Best Practices**:\n- Wrap logic in try-catch blocks\n- Log errors with timestamps and context\n- Capture SQL queries on database errors\n- Preserve stack traces for debugging\n- Re-throw exceptions after logging\n\n## Advanced Patterns\n\n### Complex Database Operations\n\n```php\n\u002F\u002F Transaction example\n$transaction = $DB->start_delegated_transaction();\n\ntry {\n    \u002F\u002F Insert record\n    $recordid = $DB->insert_record('your_table', $dataobject);\n    \n    \u002F\u002F Update related records\n    $DB->set_field('another_table', 'status', 1, ['recordid' => $recordid]);\n    \n    \u002F\u002F Commit transaction\n    $transaction->allow_commit();\n} catch (\\Exception $e) {\n    $transaction->rollback($e);\n    throw $e;\n}\n```\n\n### Working with Course Modules\n\n```php\n\u002F\u002F Create course module\n$moduleid = $DB->get_field('modules', 'id', ['name' => 'quiz'], MUST_EXIST);\n\n$cm = new \\stdClass();\n$cm->course = $courseid;\n$cm->module = $moduleid;\n$cm->instance = 0; \u002F\u002F Will be updated after activity creation\n$cm->visible = 1;\n$cm->groupmode = 0;\n$cmid = add_course_module($cm);\n\n\u002F\u002F Create activity instance (e.g., quiz)\n$quiz = new \\stdClass();\n$quiz->course = $courseid;\n$quiz->name = 'My Quiz';\n$quiz->coursemodule = $cmid;\n\u002F\u002F ... other quiz fields ...\n\n$quizid = quiz_add_instance($quiz, null);\n\n\u002F\u002F Update course module with instance ID\n$DB->set_field('course_modules', 'instance', $quizid, ['id' => $cmid]);\ncourse_add_cm_to_section($courseid, $cmid, 0);\n```\n\n### Access Restrictions (Groups\u002FAvailability)\n\n```php\n\u002F\u002F Restrict activity to specific user via group\n$groupname = 'activity_' . $activityid . '_user_' . $userid;\n\n\u002F\u002F Create or get group\nif (!$groupid = $DB->get_field('groups', 'id', ['courseid' => $courseid, 'name' => $groupname])) {\n    $groupdata = (object)[\n        'courseid' => $courseid,\n        'name' => $groupname,\n        'timecreated' => time(),\n        'timemodified' => time()\n    ];\n    $groupid = $DB->insert_record('groups', $groupdata);\n}\n\n\u002F\u002F Add user to group\nif (!$DB->record_exists('groups_members', ['groupid' => $groupid, 'userid' => $userid])) {\n    $DB->insert_record('groups_members', (object)[\n        'groupid' => $groupid,\n        'userid' => $userid,\n        'timeadded' => time()\n    ]);\n}\n\n\u002F\u002F Set availability condition\n$restriction = [\n    'op' => '&',\n    'show' => false,\n    'c' => [\n        [\n            'type' => 'group',\n            'id' => $groupid\n        ]\n    ],\n    'showc' => [false]\n];\n\n$DB->set_field('course_modules', 'availability', json_encode($restriction), ['id' => $cmid]);\n```\n\n### Random Question Selection with Tags\n\n```php\nprivate static function get_random_questions($categoryid, $tagname, $limit) {\n    global $DB;\n    \n    $sql = \"SELECT q.id\n            FROM {question} q\n            INNER JOIN {question_versions} qv ON qv.questionid = q.id\n            INNER JOIN {question_bank_entries} qbe ON qbe.id = qv.questionbankentryid\n            INNER JOIN {question_categories} qc ON qc.id = qbe.questioncategoryid\n            JOIN {tag_instance} ti ON ti.itemid = q.id\n            JOIN {tag} t ON t.id = ti.tagid\n            WHERE LOWER(t.name) = :tagname\n              AND qc.id = :categoryid\n              AND ti.itemtype = 'question'\n              AND q.qtype = 'multichoice'\";\n    \n    $qids = $DB->get_fieldset_sql($sql, [\n        'categoryid' => $categoryid,\n        'tagname' => strtolower($tagname)\n    ]);\n    \n    shuffle($qids);\n    return array_slice($qids, 0, $limit);\n}\n```\n\n## Testing Your API\n\n### 1. Via Moodle Web Services Test Client\n\n1. Enable web services: **Site administration > Advanced features**\n2. Enable REST protocol: **Site administration > Plugins > Web services > Manage protocols**\n3. Create service: **Site administration > Server > Web services > External services**\n4. Test function: **Site administration > Development > Web service test client**\n\n### 2. Via curl\n\n```bash\n# Get token first\ncurl -X POST \"https:\u002F\u002Fyourmoodle.com\u002Flogin\u002Ftoken.php\" \\\n  -d \"username=admin\" \\\n  -d \"password=yourpassword\" \\\n  -d \"service=moodle_mobile_app\"\n\n# Call your API\ncurl -X POST \"https:\u002F\u002Fyourmoodle.com\u002Fwebservice\u002Frest\u002Fserver.php\" \\\n  -d \"wstoken=YOUR_TOKEN\" \\\n  -d \"wsfunction=local_yourplugin_your_api_name\" \\\n  -d \"moodlewsrestformat=json\" \\\n  -d \"userid=2\" \\\n  -d \"courseid=3\"\n```\n\n### 3. Via JavaScript (AJAX)\n\n```javascript\nrequire(['core\u002Fajax'], function(ajax) {\n    var promises = ajax.call([{\n        methodname: 'local_yourplugin_your_api_name',\n        args: {\n            userid: 2,\n            courseid: 3\n        }\n    }]);\n\n    promises[0].done(function(response) {\n        console.log('Success:', response);\n    }).fail(function(error) {\n        console.error('Error:', error);\n    });\n});\n```\n\n## Common Pitfalls & Solutions\n\n### 1. \"Function not found\" Error\n**Solution**: \n- Purge caches: **Site administration > Development > Purge all caches**\n- Verify function name in services.php matches exactly\n- Check namespace and class name are correct\n\n### 2. \"Invalid parameter value detected\"\n**Solution**:\n- Ensure parameter types match between definition and usage\n- Check required vs optional parameters\n- Validate nested structure definitions\n\n### 3. SQL Injection Vulnerabilities\n**Solution**:\n- Always use placeholder parameters (`:paramname`)\n- Never concatenate user input into SQL strings\n- Use Moodle's database methods: `get_record()`, `get_records()`, etc.\n\n### 4. Permission Denied Errors\n**Solution**:\n- Call `self::validate_context($context)` early in execute()\n- Check required capabilities match user's permissions\n- Verify user has role assignments in the context\n\n### 5. Transaction Deadlocks\n**Solution**:\n- Keep transactions short\n- Always commit or rollback in finally blocks\n- Avoid nested transactions\n\n## Debugging Checklist\n\n- [ ] Check Moodle debug mode: **Site administration > Development > Debugging**\n- [ ] Review web services logs: **Site administration > Reports > Logs**\n- [ ] Check custom log files in `$CFG->dataroot\u002Flocal_yourplugin\u002F`\n- [ ] Verify database queries using `$DB->set_debug(true)`\n- [ ] Test with admin user to rule out permission issues\n- [ ] Clear browser cache and Moodle caches\n- [ ] Check PHP error logs on server\n\n## Plugin Structure Checklist\n\n```\nlocal\u002Fyourplugin\u002F\n├── version.php                 # Plugin version and metadata\n├── db\u002F\n│   ├── services.php           # External service definitions\n│   └── access.php             # Capability definitions (optional)\n├── classes\u002F\n│   └── external\u002F\n│       ├── your_api_name.php  # External API implementation\n│       └── another_api.php    # Additional APIs\n├── lang\u002F\n│   └── en\u002F\n│       └── local_yourplugin.php  # Language strings\n└── tests\u002F\n    └── external_test.php      # Unit tests (optional but recommended)\n```\n\n## Examples from Real Implementation\n\n### Simple Read API (Get Quiz Attempts)\n\n```php\n\u003C?php\nnamespace local_userlog\\external;\n\ndefined('MOODLE_INTERNAL') || die();\nrequire_once(\"$CFG->libdir\u002Fexternallib.php\");\n\nuse external_api;\nuse external_function_parameters;\nuse external_single_structure;\nuse external_value;\n\nclass get_quiz_attempts extends external_api {\n    public static function execute_parameters() {\n        return new external_function_parameters([\n            'userid' => new external_value(PARAM_INT, 'User ID'),\n            'courseid' => new external_value(PARAM_INT, 'Course ID')\n        ]);\n    }\n\n    public static function execute($userid, $courseid) {\n        global $DB;\n\n        self::validate_parameters(self::execute_parameters(), [\n            'userid' => $userid,\n            'courseid' => $courseid\n        ]);\n\n        $sql = \"SELECT COUNT(*) AS quiz_attempts\n                FROM {quiz_attempts} qa\n                JOIN {quiz} q ON qa.quiz = q.id\n                WHERE qa.userid = :userid AND q.course = :courseid\";\n\n        $attempts = $DB->get_field_sql($sql, [\n            'userid' => $userid,\n            'courseid' => $courseid\n        ]);\n\n        return ['quiz_attempts' => (int)$attempts];\n    }\n\n    public static function execute_returns() {\n        return new external_single_structure([\n            'quiz_attempts' => new external_value(PARAM_INT, 'Total number of quiz attempts')\n        ]);\n    }\n}\n```\n\n### Complex Write API (Create Quiz from Categories)\n\nSee attached `create_quiz_from_categories.php` for a comprehensive example including:\n- Multiple database insertions\n- Course module creation\n- Quiz instance configuration\n- Random question selection with tags\n- Group-based access restrictions\n- Extensive error logging\n- Transaction management\n\n## Quick Reference: Common Moodle Tables\n\n| Table | Purpose |\n|-------|---------|\n| `{user}` | User accounts |\n| `{course}` | Courses |\n| `{course_modules}` | Activity instances in courses |\n| `{modules}` | Available activity types (quiz, forum, etc.) |\n| `{quiz}` | Quiz configurations |\n| `{quiz_attempts}` | Quiz attempt records |\n| `{question}` | Question bank |\n| `{question_categories}` | Question categories |\n| `{grade_items}` | Gradebook items |\n| `{grade_grades}` | Student grades |\n| `{groups}` | Course groups |\n| `{groups_members}` | Group memberships |\n| `{logstore_standard_log}` | Activity logs |\n\n## Additional Resources\n\n- [Moodle External API Documentation](https:\u002F\u002Fmoodledev.io\u002Fdocs\u002F5.2\u002Fapis\u002Fsubsystems\u002Fexternal\u002Ffunctions)\n- [Moodle Coding Style](https:\u002F\u002Fmoodledev.io\u002Fgeneral\u002Fdevelopment\u002Fpolicies\u002Fcodingstyle)\n- [Moodle Database API](https:\u002F\u002Fmoodledev.io\u002Fdocs\u002F5.2\u002Fapis\u002Fcore\u002Fdml)\n- [Web Services API Documentation](https:\u002F\u002Fmoodledev.io\u002Fdocs\u002F5.2\u002Fapis\u002Fsubsystems\u002Fexternal)\n\n## Guidelines\n\n- Always validate input parameters using `validate_parameters()`\n- Check user context and capabilities before operations\n- Use parameterized SQL queries (never string concatenation)\n- Implement comprehensive error handling and logging\n- Follow Moodle naming conventions (lowercase, underscores)\n- Document all parameters and return values clearly\n- Test with different user roles and permissions\n- Consider transaction safety for write operations\n- Purge caches after service registration changes\n- Keep API methods focused and single-purpose\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","# Moodle External API Development\n\nThis skill guides you through creating custom external web service APIs for Moodle LMS, following Moodle's external API framework and coding standards.\n\n## When to Use This Skill\n\n- Creating custom web services for Moodle plugins\n- Implementing REST\u002FAJAX endpoints for course management\n- Building APIs for quiz operations, user tracking, or reporting\n- Exposing Moodle functionality to external applications\n- Developing mobile app backends using Moodle\n\n## Core Architecture Pattern\n\nMoodle external APIs follow a strict three-method pattern:\n\n1. **`execute_parameters()`** - Defines input parameter structure\n2. **`execute()`** - Contains business logic\n3. **`execute_returns()`** - Defines return structure\n\n## Step-by-Step Implementation\n\n### Step 1: Create the External API Class File\n\n**Location**: `\u002Flocal\u002Fyourplugin\u002Fclasses\u002Fexternal\u002Fyour_api_name.php`\n\n```php\n\u003C?php\nnamespace local_yourplugin\\external;\n\ndefined('MOODLE_INTERNAL') || die();\nrequire_once(\"$CFG->libdir\u002Fexternallib.php\");\n\nuse external_api;\nuse external_function_parameters;\nuse external_single_structure;\nuse external_value;\n\nclass your_api_name extends external_api {\n    \n    \u002F\u002F Three required methods will go here\n    \n}\n```\n\n**Key Points**:\n- Class must extend `external_api`\n- Namespace follows: `local_pluginname\\external` or `mod_modname\\external`\n- Include the security check: `defined('MOODLE_INTERNAL') || die();`\n- Require externallib.php for base classes\n\n### Step 2: Define Input Parameters\n\n```php\npublic static function execute_parameters() {\n    return new external_function_parameters([\n        'userid' => new external_value(PARAM_INT, 'User ID', VALUE_REQUIRED),\n        'courseid' => new external_value(PARAM_INT, 'Course ID', VALUE_REQUIRED),\n        'options' => new external_single_structure([\n            'includedetails' => new external_value(PARAM_BOOL, 'Include details', VALUE_DEFAULT, false),\n            'limit' => new external_value(PARAM_INT, 'Result limit', VALUE_DEFAULT, 10)\n        ], 'Options', VALUE_OPTIONAL)\n    ]);\n}\n```\n\n**Common Parameter Types**:\n- `PARAM_INT` - Integers\n- `PARAM_TEXT` - Plain text (HTML stripped)\n- `PARAM_RAW` - Raw text (no cleaning)\n- `PARAM_BOOL` - Boolean values\n- `PARAM_FLOAT` - Floating point numbers\n- `PARAM_ALPHANUMEXT` - Alphanumeric with extended chars\n\n**Structures**:\n- `external_value` - Single value\n- `external_single_structure` - Object with named fields\n- `external_multiple_structure` - Array of items\n\n**Value Flags**:\n- `VALUE_REQUIRED` - Parameter must be provided\n- `VALUE_OPTIONAL` - Parameter is optional\n- `VALUE_DEFAULT, defaultvalue` - Optional with default\n\n### Step 3: Implement Business Logic\n\n```php\npublic static function execute($userid, $courseid, $options = []) {\n    global $DB, $USER;\n\n    \u002F\u002F 1. Validate parameters\n    $params = self::validate_parameters(self::execute_parameters(), [\n        'userid' => $userid,\n        'courseid' => $courseid,\n        'options' => $options\n    ]);\n\n    \u002F\u002F 2. Check permissions\u002Fcapabilities\n    $context = \\context_course::instance($params['courseid']);\n    self::validate_context($context);\n    require_capability('moodle\u002Fcourse:view', $context);\n\n    \u002F\u002F 3. Verify user access\n    if ($params['userid'] != $USER->id) {\n        require_capability('moodle\u002Fcourse:viewhiddenactivities', $context);\n    }\n\n    \u002F\u002F 4. Database operations\n    $sql = \"SELECT id, name, timecreated\n            FROM {your_table}\n            WHERE userid = :userid\n              AND courseid = :courseid\n            LIMIT :limit\";\n    \n    $records = $DB->get_records_sql($sql, [\n        'userid' => $params['userid'],\n        'courseid' => $params['courseid'],\n        'limit' => $params['options']['limit']\n    ]);\n\n    \u002F\u002F 5. Process and return data\n    $results = [];\n    foreach ($records as $record) {\n        $results[] = [\n            'id' => $record->id,\n            'name' => $record->name,\n            'timestamp' => $record->timecreated\n        ];\n    }\n\n    return [\n        'items' => $results,\n        'count' => count($results)\n    ];\n}\n```\n\n**Critical Steps**:\n1. **Always validate parameters** using `validate_parameters()`\n2. **Check context** using `validate_context()`\n3. **Verify capabilities** using `require_capability()`\n4. **Use parameterized queries** to prevent SQL injection\n5. **Return structured data** matching return definition\n\n### Step 4: Define Return Structure\n\n```php\npublic static function execute_returns() {\n    return new external_single_structure([\n        'items' => new external_multiple_structure(\n            new external_single_structure([\n                'id' => new external_value(PARAM_INT, 'Item ID'),\n                'name' => new external_value(PARAM_TEXT, 'Item name'),\n                'timestamp' => new external_value(PARAM_INT, 'Creation time')\n            ])\n        ),\n        'count' => new external_value(PARAM_INT, 'Total items')\n    ]);\n}\n```\n\n**Return Structure Rules**:\n- Must match exactly what `execute()` returns\n- Use appropriate parameter types\n- Document each field with description\n- Nested structures allowed\n\n### Step 5: Register the Service\n\n**Location**: `\u002Flocal\u002Fyourplugin\u002Fdb\u002Fservices.php`\n\n```php\n\u003C?php\ndefined('MOODLE_INTERNAL') || die();\n\n$functions = [\n    'local_yourplugin_your_api_name' => [\n        'classname'   => 'local_yourplugin\\external\\your_api_name',\n        'methodname'  => 'execute',\n        'classpath'   => 'local\u002Fyourplugin\u002Fclasses\u002Fexternal\u002Fyour_api_name.php',\n        'description' => 'Brief description of what this API does',\n        'type'        => 'read',  \u002F\u002F or 'write'\n        'ajax'        => true,\n        'capabilities'=> 'moodle\u002Fcourse:view', \u002F\u002F comma-separated if multiple\n        'services'    => [MOODLE_OFFICIAL_MOBILE_SERVICE] \u002F\u002F Optional\n    ],\n];\n\n$services = [\n    'Your Plugin Web Service' => [\n        'functions' => [\n            'local_yourplugin_your_api_name'\n        ],\n        'restrictedusers' => 0,\n        'enabled' => 1\n    ]\n];\n```\n\n**Service Registration Keys**:\n- `classname` - Full namespaced class name\n- `methodname` - Always 'execute'\n- `type` - 'read' (SELECT) or 'write' (INSERT\u002FUPDATE\u002FDELETE)\n- `ajax` - Set true for AJAX\u002FREST access\n- `capabilities` - Required Moodle capabilities\n- `services` - Optional service bundles\n\n### Step 6: Implement Error Handling & Logging\n\n```php\nprivate static function log_debug($message) {\n    global $CFG;\n    $logdir = $CFG->dataroot . '\u002Flocal_yourplugin';\n    if (!file_exists($logdir)) {\n        mkdir($logdir, 0777, true);\n    }\n    $debuglog = $logdir . '\u002Fapi_debug.log';\n    $timestamp = date('Y-m-d H:i:s');\n    file_put_contents($debuglog, \"[$timestamp] $message\\n\", FILE_APPEND | LOCK_EX);\n}\n\npublic static function execute($userid, $courseid) {\n    global $DB;\n\n    try {\n        self::log_debug(\"API called: userid=$userid, courseid=$courseid\");\n        \n        \u002F\u002F Validate parameters\n        $params = self::validate_parameters(self::execute_parameters(), [\n            'userid' => $userid,\n            'courseid' => $courseid\n        ]);\n\n        \u002F\u002F Your logic here\n        \n        self::log_debug(\"API completed successfully\");\n        return $result;\n\n    } catch (\\invalid_parameter_exception $e) {\n        self::log_debug(\"Parameter validation failed: \" . $e->getMessage());\n        throw $e;\n    } catch (\\moodle_exception $e) {\n        self::log_debug(\"Moodle exception: \" . $e->getMessage());\n        throw $e;\n    } catch (\\Exception $e) {\n        \u002F\u002F Log detailed error info\n        $lastsql = method_exists($DB, 'get_last_sql') ? $DB->get_last_sql() : '[N\u002FA]';\n        self::log_debug(\"Fatal error: \" . $e->getMessage());\n        self::log_debug(\"Last SQL: \" . $lastsql);\n        self::log_debug(\"Stack trace: \" . $e->getTraceAsString());\n        throw $e;\n    }\n}\n```\n\n**Error Handling Best Practices**:\n- Wrap logic in try-catch blocks\n- Log errors with timestamps and context\n- Capture SQL queries on database errors\n- Preserve stack traces for debugging\n- Re-throw exceptions after logging\n\n## Advanced Patterns\n\n### Complex Database Operations\n\n```php\n\u002F\u002F Transaction example\n$transaction = $DB->start_delegated_transaction();\n\ntry {\n    \u002F\u002F Insert record\n    $recordid = $DB->insert_record('your_table', $dataobject);\n    \n    \u002F\u002F Update related records\n    $DB->set_field('another_table', 'status', 1, ['recordid' => $recordid]);\n    \n    \u002F\u002F Commit transaction\n    $transaction->allow_commit();\n} catch (\\Exception $e) {\n    $transaction->rollback($e);\n    throw $e;\n}\n```\n\n### Working with Course Modules\n\n```php\n\u002F\u002F Create course module\n$moduleid = $DB->get_field('modules', 'id', ['name' => 'quiz'], MUST_EXIST);\n\n$cm = new \\stdClass();\n$cm->course = $courseid;\n$cm->module = $moduleid;\n$cm->instance = 0; \u002F\u002F Will be updated after activity creation\n$cm->visible = 1;\n$cm->groupmode = 0;\n$cmid = add_course_module($cm);\n\n\u002F\u002F Create activity instance (e.g., quiz)\n$quiz = new \\stdClass();\n$quiz->course = $courseid;\n$quiz->name = 'My Quiz';\n$quiz->coursemodule = $cmid;\n\u002F\u002F ... other quiz fields ...\n\n$quizid = quiz_add_instance($quiz, null);\n\n\u002F\u002F Update course module with instance ID\n$DB->set_field('course_modules', 'instance', $quizid, ['id' => $cmid]);\ncourse_add_cm_to_section($courseid, $cmid, 0);\n```\n\n### Access Restrictions (Groups\u002FAvailability)\n\n```php\n\u002F\u002F Restrict activity to specific user via group\n$groupname = 'activity_' . $activityid . '_user_' . $userid;\n\n\u002F\u002F Create or get group\nif (!$groupid = $DB->get_field('groups', 'id', ['courseid' => $courseid, 'name' => $groupname])) {\n    $groupdata = (object)[\n        'courseid' => $courseid,\n        'name' => $groupname,\n        'timecreated' => time(),\n        'timemodified' => time()\n    ];\n    $groupid = $DB->insert_record('groups', $groupdata);\n}\n\n\u002F\u002F Add user to group\nif (!$DB->record_exists('groups_members', ['groupid' => $groupid, 'userid' => $userid])) {\n    $DB->insert_record('groups_members', (object)[\n        'groupid' => $groupid,\n        'userid' => $userid,\n        'timeadded' => time()\n    ]);\n}\n\n\u002F\u002F Set availability condition\n$restriction = [\n    'op' => '&',\n    'show' => false,\n    'c' => [\n        [\n            'type' => 'group',\n            'id' => $groupid\n        ]\n    ],\n    'showc' => [false]\n];\n\n$DB->set_field('course_modules', 'availability', json_encode($restriction), ['id' => $cmid]);\n```\n\n### Random Question Selection with Tags\n\n```php\nprivate static function get_random_questions($categoryid, $tagname, $limit) {\n    global $DB;\n    \n    $sql = \"SELECT q.id\n            FROM {question} q\n            INNER JOIN {question_versions} qv ON qv.questionid = q.id\n            INNER JOIN {question_bank_entries} qbe ON qbe.id = qv.questionbankentryid\n            INNER JOIN {question_categories} qc ON qc.id = qbe.questioncategoryid\n            JOIN {tag_instance} ti ON ti.itemid = q.id\n            JOIN {tag} t ON t.id = ti.tagid\n            WHERE LOWER(t.name) = :tagname\n              AND qc.id = :categoryid\n              AND ti.itemtype = 'question'\n              AND q.qtype = 'multichoice'\";\n    \n    $qids = $DB->get_fieldset_sql($sql, [\n        'categoryid' => $categoryid,\n        'tagname' => strtolower($tagname)\n    ]);\n    \n    shuffle($qids);\n    return array_slice($qids, 0, $limit);\n}\n```\n\n## Testing Your API\n\n### 1. Via Moodle Web Services Test Client\n\n1. Enable web services: **Site administration > Advanced features**\n2. Enable REST protocol: **Site administration > Plugins > Web services > Manage protocols**\n3. Create service: **Site administration > Server > Web services > External services**\n4. Test function: **Site administration > Development > Web service test client**\n\n### 2. Via curl\n\n```bash\n# Get token first\ncurl -X POST \"https:\u002F\u002Fyourmoodle.com\u002Flogin\u002Ftoken.php\" \\\n  -d \"username=admin\" \\\n  -d \"password=yourpassword\" \\\n  -d \"service=moodle_mobile_app\"\n\n# Call your API\ncurl -X POST \"https:\u002F\u002Fyourmoodle.com\u002Fwebservice\u002Frest\u002Fserver.php\" \\\n  -d \"wstoken=YOUR_TOKEN\" \\\n  -d \"wsfunction=local_yourplugin_your_api_name\" \\\n  -d \"moodlewsrestformat=json\" \\\n  -d \"userid=2\" \\\n  -d \"courseid=3\"\n```\n\n### 3. Via JavaScript (AJAX)\n\n```javascript\nrequire(['core\u002Fajax'], function(ajax) {\n    var promises = ajax.call([{\n        methodname: 'local_yourplugin_your_api_name',\n        args: {\n            userid: 2,\n            courseid: 3\n        }\n    }]);\n\n    promises[0].done(function(response) {\n        console.log('Success:', response);\n    }).fail(function(error) {\n        console.error('Error:', error);\n    });\n});\n```\n\n## Common Pitfalls & Solutions\n\n### 1. \"Function not found\" Error\n**Solution**: \n- Purge caches: **Site administration > Development > Purge all caches**\n- Verify function name in services.php matches exactly\n- Check namespace and class name are correct\n\n### 2. \"Invalid parameter value detected\"\n**Solution**:\n- Ensure parameter types match between definition and usage\n- Check required vs optional parameters\n- Validate nested structure definitions\n\n### 3. SQL Injection Vulnerabilities\n**Solution**:\n- Always use placeholder parameters (`:paramname`)\n- Never concatenate user input into SQL strings\n- Use Moodle's database methods: `get_record()`, `get_records()`, etc.\n\n### 4. Permission Denied Errors\n**Solution**:\n- Call `self::validate_context($context)` early in execute()\n- Check required capabilities match user's permissions\n- Verify user has role assignments in the context\n\n### 5. Transaction Deadlocks\n**Solution**:\n- Keep transactions short\n- Always commit or rollback in finally blocks\n- Avoid nested transactions\n\n## Debugging Checklist\n\n- [ ] Check Moodle debug mode: **Site administration > Development > Debugging**\n- [ ] Review web services logs: **Site administration > Reports > Logs**\n- [ ] Check custom log files in `$CFG->dataroot\u002Flocal_yourplugin\u002F`\n- [ ] Verify database queries using `$DB->set_debug(true)`\n- [ ] Test with admin user to rule out permission issues\n- [ ] Clear browser cache and Moodle caches\n- [ ] Check PHP error logs on server\n\n## Plugin Structure Checklist\n\n```\nlocal\u002Fyourplugin\u002F\n├── version.php                 # Plugin version and metadata\n├── db\u002F\n│   ├── services.php           # External service definitions\n│   └── access.php             # Capability definitions (optional)\n├── classes\u002F\n│   └── external\u002F\n│       ├── your_api_name.php  # External API implementation\n│       └── another_api.php    # Additional APIs\n├── lang\u002F\n│   └── en\u002F\n│       └── local_yourplugin.php  # Language strings\n└── tests\u002F\n    └── external_test.php      # Unit tests (optional but recommended)\n```\n\n## Examples from Real Implementation\n\n### Simple Read API (Get Quiz Attempts)\n\n```php\n\u003C?php\nnamespace local_userlog\\external;\n\ndefined('MOODLE_INTERNAL') || die();\nrequire_once(\"$CFG->libdir\u002Fexternallib.php\");\n\nuse external_api;\nuse external_function_parameters;\nuse external_single_structure;\nuse external_value;\n\nclass get_quiz_attempts extends external_api {\n    public static function execute_parameters() {\n        return new external_function_parameters([\n            'userid' => new external_value(PARAM_INT, 'User ID'),\n            'courseid' => new external_value(PARAM_INT, 'Course ID')\n        ]);\n    }\n\n    public static function execute($userid, $courseid) {\n        global $DB;\n\n        self::validate_parameters(self::execute_parameters(), [\n            'userid' => $userid,\n            'courseid' => $courseid\n        ]);\n\n        $sql = \"SELECT COUNT(*) AS quiz_attempts\n                FROM {quiz_attempts} qa\n                JOIN {quiz} q ON qa.quiz = q.id\n                WHERE qa.userid = :userid AND q.course = :courseid\";\n\n        $attempts = $DB->get_field_sql($sql, [\n            'userid' => $userid,\n            'courseid' => $courseid\n        ]);\n\n        return ['quiz_attempts' => (int)$attempts];\n    }\n\n    public static function execute_returns() {\n        return new external_single_structure([\n            'quiz_attempts' => new external_value(PARAM_INT, 'Total number of quiz attempts')\n        ]);\n    }\n}\n```\n\n### Complex Write API (Create Quiz from Categories)\n\nSee attached `create_quiz_from_categories.php` for a comprehensive example including:\n- Multiple database insertions\n- Course module creation\n- Quiz instance configuration\n- Random question selection with tags\n- Group-based access restrictions\n- Extensive error logging\n- Transaction management\n\n## Quick Reference: Common Moodle Tables\n\n| Table | Purpose |\n|-------|---------|\n| `{user}` | User accounts |\n| `{course}` | Courses |\n| `{course_modules}` | Activity instances in courses |\n| `{modules}` | Available activity types (quiz, forum, etc.) |\n| `{quiz}` | Quiz configurations |\n| `{quiz_attempts}` | Quiz attempt records |\n| `{question}` | Question bank |\n| `{question_categories}` | Question categories |\n| `{grade_items}` | Gradebook items |\n| `{grade_grades}` | Student grades |\n| `{groups}` | Course groups |\n| `{groups_members}` | Group memberships |\n| `{logstore_standard_log}` | Activity logs |\n\n## Additional Resources\n\n- [Moodle External API Documentation](https:\u002F\u002Fmoodledev.io\u002Fdocs\u002F5.2\u002Fapis\u002Fsubsystems\u002Fexternal\u002Ffunctions)\n- [Moodle Coding Style](https:\u002F\u002Fmoodledev.io\u002Fgeneral\u002Fdevelopment\u002Fpolicies\u002Fcodingstyle)\n- [Moodle Database API](https:\u002F\u002Fmoodledev.io\u002Fdocs\u002F5.2\u002Fapis\u002Fcore\u002Fdml)\n- [Web Services API Documentation](https:\u002F\u002Fmoodledev.io\u002Fdocs\u002F5.2\u002Fapis\u002Fsubsystems\u002Fexternal)\n\n## Guidelines\n\n- Always validate input parameters using `validate_parameters()`\n- Check user context and capabilities before operations\n- Use parameterized SQL queries (never string concatenation)\n- Implement comprehensive error handling and logging\n- Follow Moodle naming conventions (lowercase, underscores)\n- Document all parameters and return values clearly\n- Test with different user roles and permissions\n- Consider transaction safety for write operations\n- Purge caches after service registration changes\n- Keep API methods focused and single-purpose\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n",{"name":5,"risk":24,"source":25,"date_added":26,"description":7},"unknown","community","2026-02-27","main","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-Skills-技能包\u002FYYC3-Skills-技能包-antigravity-awesome-skills\u002Fplugins\u002Fantigravity-awesome-skills\u002Fskills\u002Fmoodle-external-api-development",0,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base","https:\u002F\u002Fkb.yyc3.top\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-10 10:37:32",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill moodle-external-api-development",{"tool":42,"command":43},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill moodle-external-api-development",{"tool":45,"command":46},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill moodle-external-api-development","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Skills-技能包\u002FYYC3-Skills-技能包-antigravity-awesome-skills\u002Fplugins\u002Fantigravity-awesome-skills\u002Fskills\u002Fmoodle-external-api-development\u002FSKILL.md",true,[],[51,58,65,72,79,86],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M7CTDWHERCXPQCP0K03A86AS","vercel-sandbox","Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include \"Vercel Sandbox browser\", \"microVM Chrome\", \"agent-browser in sandbox\", \"browser automation on Vercel\", or any task requiring Chrome in a Vercel Sandbox.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M7CTD8D2BNJY54S65M47HEJA","slack","Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include \"check my Slack\", \"what channels have unreads\", \"send a message to\", \"search Slack for\", \"extract from Slack\", \"find who said\", or any task requiring programmatic Slack interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M7CTCSSB8ZP3Q58C3YZDZK1W","electron","Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include \"automate Slack app\", \"control VS Code\", \"interact with Discord app\", \"test this Electron app\", \"connect to desktop app\", or any task requiring automation of a native Electron application.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Felectron\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M7CTCBJY76688V4DCZGWFHGQ","dogfood","Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to \"dogfood\", \"QA\", \"exploratory test\", \"find issues\", \"bug hunt\", \"test this app\u002Fsite\u002Fplatform\", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fdogfood\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M7CTC4H0FFGVEAQR9PA4GA1A","agent-browser","Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to \"open a website\", \"fill out a form\", \"click a button\", \"take a screenshot\", \"scrape data from a page\", \"test this web app\", \"login to a site\", \"automate browser actions\", or any task requiring programmatic web interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fagent-browser\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M7CTBKVFYBG78FDSABSDJTTQ","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", \"switch to --preset\", and for building a design system or applying a DESIGN.md or brand spec to shadcn\u002Fui.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-UI-界面组件\u002FYYC3-UI-界面组件-ui\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[]]