-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
feat: add Perl language rules, skills, and update documentation #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
095f317
5e50d8d
c8f06e8
c3f9160
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| --- | ||
| paths: | ||
| - "**/*.pl" | ||
| - "**/*.pm" | ||
| - "**/*.t" | ||
| - "**/*.psgi" | ||
| - "**/*.cgi" | ||
| --- | ||
| # Perl Coding Style | ||
|
|
||
| > This file extends [common/coding-style.md](../common/coding-style.md) with Perl-specific content. | ||
|
|
||
| ## Standards | ||
|
|
||
| - Always `use v5.36` (enables `strict`, `warnings`, `say`, subroutine signatures) | ||
| - Use subroutine signatures — never unpack `@_` manually | ||
| - Prefer `say` over `print` with explicit newlines | ||
|
|
||
| ## Immutability | ||
|
|
||
| - Use **Moo** with `is => 'ro'` and `Types::Standard` for all attributes | ||
| - Never use blessed hashrefs directly — always use Moo/Moose accessors | ||
| - **OO override note**: Moo `has` attributes with `builder` or `default` are acceptable for computed read-only values | ||
|
|
||
| ## Formatting | ||
|
|
||
| Use **perltidy** with these settings: | ||
|
|
||
| ``` | ||
| -i=4 # 4-space indent | ||
| -l=100 # 100 char line length | ||
| -ce # cuddled else | ||
| -bar # opening brace always right | ||
| ``` | ||
|
|
||
| ## Linting | ||
|
|
||
| Use **perlcritic** at severity 3 with themes: `core`, `pbp`, `security`. | ||
|
|
||
| ```bash | ||
| perlcritic --severity 3 --theme 'core || pbp || security' lib/ | ||
| ``` | ||
|
|
||
| ## Reference | ||
|
|
||
| See skill: `perl-patterns` for comprehensive modern Perl idioms and best practices. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| paths: | ||
| - "**/*.pl" | ||
| - "**/*.pm" | ||
| - "**/*.t" | ||
| - "**/*.psgi" | ||
| - "**/*.cgi" | ||
| --- | ||
| # Perl Hooks | ||
|
|
||
| > This file extends [common/hooks.md](../common/hooks.md) with Perl-specific content. | ||
|
|
||
| ## PostToolUse Hooks | ||
|
|
||
| Configure in `~/.claude/settings.json`: | ||
|
|
||
| - **perltidy**: Auto-format `.pl` and `.pm` files after edit | ||
| - **perlcritic**: Run lint check after editing `.pm` files | ||
|
|
||
| ## Warnings | ||
|
|
||
| - Warn about `print` in non-script `.pm` files — use `say` or a logging module (e.g., `Log::Any`) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| --- | ||
| paths: | ||
| - "**/*.pl" | ||
| - "**/*.pm" | ||
| - "**/*.t" | ||
| - "**/*.psgi" | ||
| - "**/*.cgi" | ||
| --- | ||
| # Perl Patterns | ||
|
|
||
| > This file extends [common/patterns.md](../common/patterns.md) with Perl-specific content. | ||
|
|
||
| ## Repository Pattern | ||
|
|
||
| Use **DBI** or **DBIx::Class** behind an interface: | ||
|
|
||
| ```perl | ||
| package MyApp::Repo::User; | ||
| use Moo; | ||
|
|
||
| has dbh => (is => 'ro', required => 1); | ||
|
|
||
| sub find_by_id ($self, $id) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Verify Perl version/feature declarations in rule files
# Check for version or feature declarations in Perl rule files
rg -n "use v5\\.36|use feature.*signatures" rules/perl/
# Also check the coding-style rule for version guidance
rg -n -A 3 "signature|v5\\.36|modern.*perl" rules/perl/coding-style.mdRepository: affaan-m/everything-claude-code Length of output: 408 🏁 Script executed: head -30 rules/perl/patterns.mdRepository: affaan-m/everything-claude-code Length of output: 626 Add The code example uses subroutine signatures ( Updated code examplepackage MyApp::Repo::User;
use v5.36;
use Moo;
has dbh => (is => 'ro', required => 1);
sub find_by_id ($self, $id) {
my $sth = $self->dbh->prepare('SELECT * FROM users WHERE id = ?');
$sth->execute($id);
return $sth->fetchrow_hashref;
}🤖 Prompt for AI Agents |
||
| my $sth = $self->dbh->prepare('SELECT * FROM users WHERE id = ?'); | ||
| $sth->execute($id); | ||
| return $sth->fetchrow_hashref; | ||
| } | ||
| ``` | ||
|
|
||
| ## DTOs / Value Objects | ||
|
|
||
| Use **Moo** classes with **Types::Standard** (equivalent to Python dataclasses): | ||
|
|
||
| ```perl | ||
| package MyApp::DTO::User; | ||
| use Moo; | ||
| use Types::Standard qw(Str Int); | ||
|
|
||
| has name => (is => 'ro', isa => Str, required => 1); | ||
| has email => (is => 'ro', isa => Str, required => 1); | ||
| has age => (is => 'ro', isa => Int); | ||
| ``` | ||
|
|
||
| ## Resource Management | ||
|
|
||
| - Always use **three-arg open** with `autodie` | ||
| - Use **Path::Tiny** for file operations | ||
|
|
||
| ```perl | ||
| use autodie; | ||
| use Path::Tiny; | ||
|
|
||
| my $content = path('config.json')->slurp_utf8; | ||
| ``` | ||
|
|
||
| ## Module Interface | ||
|
|
||
| Use `Exporter 'import'` with `@EXPORT_OK` — never `@EXPORT`: | ||
|
|
||
| ```perl | ||
| use Exporter 'import'; | ||
| our @EXPORT_OK = qw(parse_config validate_input); | ||
| ``` | ||
|
|
||
| ## Dependency Management | ||
|
|
||
| Use **cpanfile** + **carton** for reproducible installs: | ||
|
|
||
| ```bash | ||
| carton install | ||
| carton exec prove -lr t/ | ||
| ``` | ||
|
|
||
| ## Reference | ||
|
|
||
| See skill: `perl-patterns` for comprehensive modern Perl patterns and idioms. | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Moving Java to the "needs contributions" list contradicts the Java badge still displayed in the badges section above. Either remove the Java badge or keep Java in the "already included" list (it has a
skills/java-coding-standards/skill, though norules/java/directory).Prompt for AI agents