getty-perl-moo

Guides writing Perl classes and roles using Moo patterns, delegation, and lifecycle hooks.

2|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/Getty/p5-api-docker --skill getty-perl-moo-getty
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: getty-perl-moo
Source: https://github.com/Getty/p5-api-docker/tree/main/.claude/skills/getty-perl-moo
Command: npx skills add https://github.com/Getty/p5-api-docker --skill getty-perl-moo-getty

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing object-oriented Perl with Moo involves many subtle conventions — role composition order, lazy builders, delegation, method modifiers, and lifecycle hooks — where small mistakes cause shared-state bugs, broken BUILD chains, or unexpected Moose inflation. This Skill encodes house conventions and thirteen concrete patterns so generated Moo code is correct and idiomatic from the start. ## Core Features & Use Cases - Thirteen Moo patterns: inheritance with attribute overrides, roles with requires, thin role-only classes, delegation via handles and Sub::HandlesVia, method modifiers, parameterized roles, and Moose interop. - House conventions: with placement, is => 'lazy' builders, Types::Standard typed attributes, init_arg aliasing, and strict constructors via MooX::StrictConstructor. - Pitfall catalog: catches common bugs like default => [] shared state, replacing extends calls, namespace::autoclean version issues, and manual SUPER::BUILD calls. - Use Case: When asked to add a new class to a Moo-based distribution, the Skill produces a role-first design with typed attributes, lazy builders, and correct lifecycle hooks instead of a deep inheritance hierarchy. ## Quick Start Write a Moo class for a Docker container resource with typed attributes, a lazy builder, and a role for shared ID handling.

Frequently Asked Questions about getty-perl-moo

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

FAQPage Schema
How do I write a Perl class with Moo?

Declare the package, call `use Moo`, then define attributes with `has` using options like `is => 'ro'`, `required => 1`, and `default => sub { ... }`. Compose reusable behavior with `with 'Some::Role'` placed directly under `use Moo`.

When should I use Moo roles instead of inheritance?

Use roles for optional or horizontal features and reserve `extends` for stable is-a relationships. Roles with `requires` fail loudly at composition time when the consuming class lacks a required method, making them safer than deep hierarchies.

Does Moo support type constraints on attributes?

Moo has no built-in type system, but `isa` accepts a coderef and Type::Tiny objects are coderefs, so Types::Standard types like Str and ArrayRef[Str] plug in directly. Typed attributes are the recommended house style.

Why does my Moo attribute share data between instances?

This happens when a reference is passed directly, such as `default => []`, which shares one arrayref across all instances. Always wrap reference defaults in a coderef, like `default => sub { [] }`, so each object gets its own copy.

Can Moo classes interoperate with Moose code?

Yes. When Moose is loaded before Moo classes are compiled, Moo inflates its metaclasses, so a Moose class can extend a Moo class and a Moo class can consume a Moose role. Avoid Any::Moose, which is deprecated.

What are the limitations of Moo method modifiers?

`before` and `after` modifiers cannot change the return value; only `around` can, and it must forward `@_` correctly. Also, `trigger` does not receive the old value, unlike Moose, and modifiers from multiple roles stack in composition order.