Guide for creating PHP and Laravel packages using Spatie's package-skeleton-laravel and package-skeleton-php templates. Use when the user wants to create a new PHP or Laravel package, scaffold a package. Also use when building customizable packages — covers proven patterns for extensibility (events, configurable models/jobs, action classes) instead of config option creep.
72
90%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Low
Low-risk findings worth noting
gh CLI installed and authenticatedphp available in PATHcomposer available in PATHAsk the user for:
spatie) — the GitHub org or usernamelaravel-cool-feature) — the repo/package nameUse defaults where sensible:
git config user.namegit config user.emailgh auth statusSpatie)laravel- prefix (e.g. CoolFeature)gh repo create <vendor>/<package-name> --template spatie/package-skeleton-laravel --public --clone
cd <package-name>If the user wants a private repo, use --private instead of --public.
WARNING: Do NOT pipe stdin to configure.php. The script's child processes (gh auth status, git log, git config) consume lines from the piped stdin, causing inputs to shift and produce garbled results. Instead, do the replacements manually:
sed to replace all placeholder strings across the repo:find . -type f -not -path './.git/*' -not -path './vendor/*' -not -name 'configure.php' -exec sed -i '' \
-e 's/:author_name/Author Name/g' \
-e 's/:author_username/authorusername/g' \
-e 's/author@domain\.com/author@email.com/g' \
-e 's/:vendor_name/Vendor Name/g' \
-e 's/:vendor_slug/vendorslug/g' \
-e 's/VendorName/VendorNamespace/g' \
-e 's/:package_slug_without_prefix/package-without-prefix/g' \
-e 's/:package_slug/package-name/g' \
-e 's/:package_name/package-name/g' \
-e 's/:package_description/Package description here/g' \
-e 's/Skeleton/ClassName/g' \
-e 's/skeleton/package-name/g' \
-e 's/migration_table_name/package_without_prefix/g' \
-e 's/variable/variableName/g' \
{} +Important: The order of -e flags matters. Replace :package_slug_without_prefix before :package_slug to avoid partial matches. Replace Skeleton (PascalCase) before skeleton (lowercase).
mv src/Skeleton.php src/ClassName.php
mv src/SkeletonServiceProvider.php src/ClassNameServiceProvider.php
mv src/Facades/Skeleton.php src/Facades/ClassName.php
mv src/Commands/SkeletonCommand.php src/Commands/ClassNameCommand.php
mv config/skeleton.php config/package-without-prefix.php
mv database/migrations/create_skeleton_table.php.stub database/migrations/create_package_without_prefix_table.php.stubconfigure.php and run composer install:rm configure.php
composer installUse a longer timeout (5 minutes) for composer install.
After the script completes:
# Check the directory structure
ls -la src/
# Verify composer.json looks correct
cat composer.json | head -20
# Check tests passed during setupThe configure script modifies all files but doesn't commit. Create the initial commit:
git add -A
git commit -m "Configure package skeleton"
git push -u origin mainTell the user:
https://github.com/<vendor>/<package-name>)VendorNamespace\ClassName)src/<ClassName>.php — main package classsrc/<ClassName>ServiceProvider.php — service providerconfig/<package-slug>.php — configurationtests/ — test directoryLoad these as needed:
references/post-setup.md. What the skeleton generated and what to do with it.references/package-patterns.md. API design principles, and proven extensibility patterns (events, configurable models and jobs, action classes) instead of config option creep.09219e0
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.