From e44f549336684fd4eee1f1020f93005596870e8a Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sun, 30 Nov 2025 08:31:17 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 12 ++ README.md | 3 + plugin.lock.json | 45 ++++++++ skills/mojolicious/SKILL.md | 222 ++++++++++++++++++++++++++++++++++++ 4 files changed, 282 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 plugin.lock.json create mode 100644 skills/mojolicious/SKILL.md diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..ccb557b --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "mojolicious-skills", + "description": "Claude Code plugin", + "version": "0.0.0-2025.11.28", + "author": { + "name": "kfly8", + "email": "kentafly88@gmail.com" + }, + "skills": [ + "./skills" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3528521 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# mojolicious-skills + +Claude Code plugin diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..028602b --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,45 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:kfly8/claude-plugins:plugins/mojolicious-skills", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "ee2ffaeb4ee51076e38cf6978a437352924b2c2c", + "treeHash": "7275ad51f6f73b0c9e4b29dd2ace67bdf307b78febdf8ded81456f8792607fad", + "generatedAt": "2025-11-28T10:19:28.690917Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "mojolicious-skills", + "description": "Claude Code plugin", + "version": null + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "296eb5f3b234def93ce0cbde2ae18dd8170edd869fc7ce2d8cdb7acaf776b8b1" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "ef2f04b30ab5a8357ccd5ed840968bfef0ae4af559e3bde33bdddc0e79c5eedd" + }, + { + "path": "skills/mojolicious/SKILL.md", + "sha256": "366cc12cea6c13b656cf19bd404caa3de28b8b6b8fa0a1a54ead1cc17f1fca57" + } + ], + "dirSha256": "7275ad51f6f73b0c9e4b29dd2ace67bdf307b78febdf8ded81456f8792607fad" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/mojolicious/SKILL.md b/skills/mojolicious/SKILL.md new file mode 100644 index 0000000..4bcf6b8 --- /dev/null +++ b/skills/mojolicious/SKILL.md @@ -0,0 +1,222 @@ +--- +name: mojolicious +description: Assist with Mojolicious web framework development using documentation search, browsing, and testing requests without starting a server. +--- + +# Mojolicious Development + +Use the Mojolicious app script for efficient development and testing. + +## Core Capabilities + +- **Search documentation** - Search Mojolicious docs using Google Custom Search +- **Browse documentation** - View official docs at https://docs.mojolicious.org/ +- **Test requests** - Test app endpoints using the built-in commands +- **View routes** - List all application routes + +## Documentation Access + +### Searching Documentation + +Use WebSearch with site restriction to search Mojolicious documentation: + +``` +WebSearch: "routing guide site:docs.mojolicious.org" +WebSearch: "websocket site:docs.mojolicious.org" +``` + +Or use WebFetch with Google Custom Search: + +``` +https://www.google.com/cse?cx=014527573091551588235:pwfplkjpgbi&q= +``` + +### Browsing Documentation + +Documentation URLs follow these patterns: + +- **Mojolicious modules**: `https://docs.mojolicious.org/Mojolicious/Guides/Routing` + - Use `/` separators for Mojolicious namespace + - Example: `Mojolicious::Guides::Routing` → `/Mojolicious/Guides/Routing` + +- **CPAN modules**: `https://docs.mojolicious.org/Path::To::Module` + - Use `::` separators for other modules + - Example: `Mojo::UserAgent` → `/Mojo::UserAgent` + +## Testing Your Application + +### Quick Testing + +Quick testing is useful for rapid manual verification during development. + +#### Testing Requests + +Use the app script for GET requests only. For other HTTP methods (POST, PUT, DELETE), use curl with a running server: + +```bash +# GET request (use app.pl) +./app.pl get /api/users + +# GET request with query parameters (use app.pl) +./app.pl get /api/users?page=1 + +# GET request with custom headers (use app.pl) +./app.pl get /api/users -H 'Authorization: Bearer token123' + +# For POST, PUT, DELETE: Start server first +./app.pl daemon -l http://127.0.0.1:3000 + +# POST request with JSON data (use curl) +curl -X POST http://127.0.0.1:3000/api/users \ + -H 'Content-Type: application/json' \ + -d '{"name":"Alice","email":"alice@example.com"}' + +# PUT request (use curl) +curl -X PUT http://127.0.0.1:3000/api/users/1 \ + -H 'Content-Type: application/json' \ + -d '{"name":"Alice Updated"}' + +# DELETE request (use curl) +curl -X DELETE http://127.0.0.1:3000/api/users/1 + +# curl with custom headers +curl http://127.0.0.1:3000/api/users \ + -H 'Authorization: Bearer token123' +``` + +#### Viewing Routes + +List all application routes: + +```bash +./app.pl routes +``` + +This shows the routing table with HTTP methods, paths, and route names. + +### Unit Testing with Test::Mojo + +For proper automated testing, use Test::Mojo. It provides a comprehensive testing framework with chainable assertions. + +#### Creating Test Files + +Create test files in the `t/` directory: + +```perl +# t/api.t +use Test2::V0; +use Test::Mojo; + +# Create test instance +my $t = Test::Mojo->new('path/to/app.pl'); + +# Test GET request +$t->get_ok('/api/todos') + ->status_is(200) + ->json_is([]); + +# Test POST request +$t->post_ok('/api/todos' => json => {title => 'Buy milk', completed => 0}) + ->status_is(201) + ->json_has('/id') + ->json_is('/title' => 'Buy milk') + ->json_is('/completed' => 0); + +# Test GET specific todo +$t->get_ok('/api/todos/1') + ->status_is(200) + ->json_is('/title' => 'Buy milk'); + +# Test PUT request +$t->put_ok('/api/todos/1' => json => {completed => 1}) + ->status_is(200) + ->json_is('/completed' => 1); + +# Test DELETE request +$t->delete_ok('/api/todos/1') + ->status_is(200) + ->json_has('/message'); + +# Test error cases +$t->get_ok('/api/todos/999') + ->status_is(404) + ->json_has('/error'); + +$t->post_ok('/api/todos' => json => {}) + ->status_is(400) + ->json_is('/error' => 'Title is required'); + +done_testing(); +``` + +#### Running Tests + +```bash +# Run all tests +prove -lv t/ + +# Run specific test file +prove -lv t/api.t + +# Run with verbose output +perl t/api.t +``` + +#### Key Test::Mojo Features + +- **Chainable assertions**: Chain multiple assertions for concise tests +- **HTTP methods**: `get_ok`, `post_ok`, `put_ok`, `delete_ok`, etc. +- **Status assertions**: `status_is()`, `status_isnt()` +- **JSON assertions**: `json_is()`, `json_has()`, `json_like()` +- **Content assertions**: `content_like()`, `content_type_is()` +- **Header assertions**: `header_is()`, `header_like()` +- **Automatic session management**: Cookies are handled automatically +- **No server needed**: Tests run without starting a real server + +## Quick Examples + +```bash +# View all routes in your application +./app.pl routes + +# Test a GET endpoint (use app.pl) +./app.pl get /api/users + +# Test with authentication header (use app.pl) +./app.pl get /api/protected -H 'Authorization: Bearer mytoken' + +# Start server for testing POST/PUT/DELETE +./app.pl daemon -l http://127.0.0.1:3000 + +# Test a POST endpoint with JSON (use curl) +curl -X POST http://127.0.0.1:3000/api/users \ + -H 'Content-Type: application/json' \ + -d '{"name":"Bob","role":"admin"}' +``` + +## Workflow + +1. **Plan**: Check routes with `./app.pl routes` +2. **Search**: Find relevant documentation for the feature +3. **Read docs**: Browse official docs at https://docs.mojolicious.org/ +4. **Implement**: Write your code +5. **Test**: + - **Recommended**: Write unit tests with Test::Mojo in `t/` directory + - **Quick testing**: Use `./app.pl get` for GET requests, or curl with daemon for other methods +6. **Run tests**: Execute with `prove -lv t/` to verify all functionality + +## Guidelines + +- Always check `./app.pl routes` to understand the current routing structure +- **Prefer unit testing over quick testing:** + - Write automated tests with Test::Mojo in `t/` directory for reliable, repeatable testing + - Use quick testing (app.pl/curl) only for rapid manual verification during development +- For quick testing endpoints: + - GET requests: Use `./app.pl get ` (no server needed) + - POST/PUT/DELETE: Start server with `./app.pl daemon` and use curl +- Search documentation using site-restricted WebSearch: `site:docs.mojolicious.org ` +- For module documentation, use WebFetch with proper URL patterns: + - Mojolicious namespace: `https://docs.mojolicious.org/Mojolicious/Path` + - Other modules: `https://docs.mojolicious.org/Module::Name` +- Follow the workflow: plan → search → read docs → implement → unit test → (optional: quick test) +- Test::Mojo provides better test coverage and automation than manual curl commands