ワンクリックで
perl-file-sharedir
File::ShareDir — packaging and accessing non-code data files (templates, schemas, configs, skills) in Perl distributions.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
File::ShareDir — packaging and accessing non-code data files (templates, schemas, configs, skills) in Perl distributions.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when managing Git-native kanban tasks or shared helper refs with the karr CLI in agent workflows.
Use when managing karr-foundation — periodic agent execution across multiple karr boards, drain loops, and auto-block logic.
Getty's house rules for all Perl code — module loading, Moose patterns, cpanfile versioning for Getty-authored CPAN distributions, stylistic choices that differ from defaults. Load on any Perl edit in a Getty project.
Moo Perl object system - roles, attributes, inheritance patterns, and best practices
| name | perl-file-sharedir |
| description | File::ShareDir — packaging and accessing non-code data files (templates, schemas, configs, skills) in Perl distributions. |
| user-invocable | true |
Share files are non-code data files (templates, schemas, configs, word lists, skill definitions) shipped with a Perl distribution and accessible at runtime.
my-dist/
lib/
share/ ← convention, configurable
templates/
schema.json
claude-skill.md
dist.ini
[ShareDir] is part of @Basic, which is included in [@Author::GETTY]. So no extra config needed — just put files in share/ and they get packaged automatically.
To override the directory name (default is share/):
[ShareDir]
dir = data
use File::ShareDir 'dist_dir';
use Path::Tiny;
my $share = path( dist_dir('My-Dist') );
my $template = $share->child('templates/main.html')->slurp_utf8;
Key functions:
| Function | Returns |
|---|---|
dist_dir('Dist-Name') | Share directory path for a distribution |
dist_file('Dist-Name', 'file.txt') | Full path to a specific file |
module_dir('Module::Name') | Per-module share dir (rarely used) |
module_file('Module::Name', 'f.txt') | Per-module file (rarely used) |
Important: Dist name uses hyphens (App-karr), not colons.
dist_dir() only works after install. For development, fall back via %INC:
sub _find_share_dir {
# Installed?
eval {
require File::ShareDir;
my $dir = File::ShareDir::dist_dir('My-Dist');
return path($dir) if path($dir)->is_dir;
};
# Development: navigate from module location to share/
my $module_path = $INC{'My/Dist/Module.pm'};
if ($module_path) {
# parent() count = depth of module under lib/ + 1 for lib/ itself
# e.g. lib/My/Dist/Module.pm → parent(4) = project root
my $share = path($module_path)->parent(4)->child('share');
return $share if $share->is_dir;
}
die "Could not find share directory. Is My-Dist properly installed?\n";
}
Parent count: count the path components in lib/My/Dist/Module.pm (that's 4).
Zero-config development access (works without install):
use File::ShareDir::ProjectDistDir;
# Now dist_dir() works in development too
Trade-off: extra dependency, magic. The %INC fallback is more explicit.
Use Test::File::ShareDir to set up share dirs in tests:
use Test::File::ShareDir -share => {
-dist => { 'My-Dist' => 'share/' },
};
use File::ShareDir 'dist_dir';
# Now dist_dir('My-Dist') returns the local share/ path
my $dir = dist_dir('My-Dist');
requires 'File::ShareDir';
on test => sub {
requires 'Test::File::ShareDir'; # if testing share access
};
sub default_config_path {
return path(dist_dir('My-Dist'))->child('default-config.yml');
}
share/
claude-skill.md
# In init/install command:
my $share = find_share_dir(); # with fallback
my $skill = $share->child('claude-skill.md')->slurp_utf8;
path('.claude/skills/myapp/SKILL.md')->spew_utf8($skill);
my $share_dir = dist_dir('OpenAPI-Modern');
foreach my $file (path($share_dir)->children(qr/\.json$/)) {
register_schema($file);
}
App-karr not App::karr — hyphens, not colons[ShareDir] via @Basic — no extra dist.ini config neededdzil build snapshots share/ into the tarball