perl-mojo

Guides writing Mojolicious and Mojo::Base code covering attributes, roles, async, and core Mojo helpers.

3|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/Getty/p5-mcp-run --skill perl-mojo-getty
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: perl-mojo
Source: https://github.com/Getty/p5-mcp-run/tree/main/.claude/skills/perl-mojo
Command: npx skills add https://github.com/Getty/p5-mcp-run --skill perl-mojo-getty

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing correct Mojolicious code requires knowing Mojo::Base's specific conventions — lazy coderef defaults, role composition order, async/await flag combinations — and getting them wrong produces subtle bugs like shared mutable state or event loops that never run. This Skill encodes verified patterns so generated Perl code follows the framework's actual behavior. ## Core Features & Use Cases - Mojo::Base object system patterns: Class, subclass, and role declarations with correct flag usage (-base, -role, -strict, -signatures, -async_await), attribute defaults, and chainable accessors. - Role composition and lazy construction: with_roles composition rules, + namespace expansion, and coderef defaults that defer expensive member construction per instance. - Mojo toolkit and async guidance: Mojo::JSON booleans, Mojo::File, Mojo::Collection, Mojo::Util, and Mojo::Promise/Mojo::IOLoop patterns including the rule that ->wait belongs only at the top level. - Use Case: When asked to write a Perl MCP server class with a name attribute, version default, and async HTTP fetching via Mojo::UserAgent, the Skill ensures the subclass redeclares has correctly, uses coderef defaults for the user agent, and combines -signatures with -async_await properly. ## Quick Start Write a Mojolicious class using Mojo::Base with attributes, a role, and an async method that fetches a URL with Mojo::UserAgent.

Frequently Asked Questions about perl-mojo

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define attributes with defaults in Mojo::Base?

Declare attributes with has name => 'default' for static values, or has attr => sub { ... } for a coderef default evaluated lazily on first read per instance. Mutable values like arrayrefs or objects must use coderefs, otherwise every instance shares one value.

How do I use async/await in Mojolicious?

Import Mojo::Base with both -signatures and -async_await flags, then write async sub and await promise-returning methods like $ua->get_p($url). Drive the event loop with ->wait at the top level only, never inside a running loop.

How do roles work with Mojo::Base?

Declare a role with use Mojo::Base -role and apply it via Class->with_roles('Role::Name'), which builds and caches a new composed class. A leading + expands to the invocant's namespace, and requires declarations are checked at composition time.

Does Mojo::JSON handle boolean values correctly?

Yes, Mojo::JSON exports true and false constants that survive a decode/encode roundtrip as real JSON booleans. Plain 1 and 0 do not roundtrip as booleans, so use the exported constants when boolean semantics matter.

Why does my Mojo::Base attribute share state between instances?

This happens when a mutable default like an arrayref or object is passed directly to has instead of inside a coderef. Static defaults are shared across all instances; wrap mutable values in sub { ... } so each instance gets a fresh copy.