skills/team/php-package-scaffold/SKILL.md
Scaffolds production-ready Composer packages for Packagist with a complete composer.json, PSR-4 autoloading, a Pest/PHPUnit test harness, GitHub Actions CI (PHP version matrix, PHPStan, PHP-CS-Fixer), and a semver tag-based publish workflow. PHP analog of nuget-package-scaffold, pypi-package-scaffold, and cargo-package-scaffold. Use when creating a reusable PHP library, configuring composer.json metadata, setting up Composer/Packagist publishing, or building a PHP package CI pipeline.
npx skillsauth add michaelalber/ai-toolkit php-package-scaffoldInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
"A library is a contract. Once published, every breaking change is someone else's incident."
"Make it work, make it right, make it releasable."
This skill produces a publishable Composer library — not an application. The deliverable is a package
that a stranger can composer require vendor/package, that installs cleanly across a matrix of supported
PHP versions, that passes static analysis and style checks in CI, and that publishes to Packagist
automatically on a semver git tag. Packagist serves whatever a tag points at, so the tag is the
release — discipline lives in the tag and in CI, not in a manual upload step.
A library is a long-lived contract. Semantic versioning is mandatory: MAJOR.MINOR.PATCH, where a MAJOR
bump is the only place a breaking change is allowed. The public API surface is everything not marked
@internal; treat it as frozen within a major version.
Non-Negotiable Constraints:
composer.json — composer validate --strict passessrc/ mapped to a vendor namespace; tests in a separate autoload-devdeclare(strict_types=1) in every src/ filevX.Y.Z; breaking changes only on MAJORdev-master, no unbounded *The full domain principles, AI discipline rules, anti-pattern catalog, and error-recovery
procedures live in references/conventions.md.
Use search_knowledge (grounded-code-mcp, collection="php").
| Query | When to Call |
|-------|--------------|
| search_knowledge("composer.json schema autoload require require-dev", collection="php") | When writing composer.json |
| search_knowledge("Composer PSR-4 autoloading namespace mapping", collection="php") | When laying out src/ |
| search_knowledge("Composer library versioning semantic version constraints", collection="php") | When choosing version constraints |
| search_knowledge("Composer publishing packagist", collection="php") | When configuring the publish flow |
| search_code_examples("phpunit test class assertion", language="php") | When scaffolding the test harness |
Decide the package identity and surface before writing files.
php -v | head -1
# Pick: vendor/name (lowercase, hyphenated), namespace (StudlyCase), license, PHP range
# Confirm the name is free on packagist.org
Record: vendor/package, root namespace, license (SPDX id), supported PHP range, runtime deps.
See references/composer-json-template.md for the full manifest and references/ci-publish-workflow.md
for the GitHub Actions and Packagist setup.
composer.json
src/ # PSR-4 root; @internal on non-public classes
tests/ # Pest or PHPUnit; autoload-dev
.github/workflows/ci.yml # matrix: tests + phpstan + cs-fixer
phpstan.neon.dist # level 8
.php-cs-fixer.dist.php # PSR-12 ruleset
CHANGELOG.md # Keep a Changelog
README.md LICENSE .gitignore .gitattributes
composer validate --strict
composer install
vendor/bin/phpstan analyse src --level=8
vendor/bin/php-cs-fixer fix --dry-run --diff
vendor/bin/pest # or vendor/bin/phpunit
# After CI is green on main:
# 1. Update CHANGELOG.md with the new version
# 2. Tag with semver and push
git tag v1.0.0
git push origin v1.0.0
# Packagist auto-updates via the GitHub webhook (or `composer` API hook).
First-time only: submit the repo URL once at packagist.org and enable the GitHub service hook so future tags publish automatically.
<php-package-scaffold-state>
phase: PLAN | SCAFFOLD | VERIFY | PUBLISH | COMPLETE
package: vendor/name
namespace: [root namespace]
php_range: [e.g. ^8.2]
license: [SPDX id]
test_runner: pest | phpunit
phpstan_level: [n]
ci_created: true | false
validate_passes: true | false
packagist_registered: true | false
last_action: [description]
</php-package-scaffold-state>
Emit a ## PHP Package Scaffold: vendor/name report with Identity, Files Created, Gates, and Publish
checklists. The full report markdown lives in references/conventions.md (Output Report Template).
| Skill | Relationship |
|-------|-------------|
| php-architecture-checklist | Run before the first tag to verify the package's internal structure and boundaries. |
| php-security-review | Audit the package (and its dependencies) for OWASP and supply-chain risks before publishing. |
| supply-chain-audit | Review the dependency tree for known-vulnerable or unmaintained packages. |
| php-feature-slice | When the package provides Laravel integration, ship a service provider following slice conventions. |
| tdd | Drive the public API test-first so the released contract is the tested contract. |
development
Interviews the user relentlessly about a plan, decision, or idea — one question at a time, each with a recommended answer. Shared engine behind "grill-me" and "grill-with-docs". Use on any "grill" trigger phrase or to stress-test thinking. Do NOT use to build the plan; it ends at shared understanding, not implementation.
testing
Runs a relentless interview to sharpen a plan or design, capturing the decisions as ADRs and a glossary along the way. Use when the user wants to be grilled AND wants the session to leave durable domain documentation behind. Do NOT use for a throwaway stress-test with no artifacts; use grill-me instead.
tools
OWASP-based security review of Vue/TypeScript front-ends. Detects framework (Vite/Vue CLI/Nuxt), entry points, and data flows; scans the OWASP Top 10 (2025) mapped to Vue client-side risks (raw-HTML XSS via v-html, URL/protocol injection, bundled secrets, insecure token storage, dependency CVEs, missing CSP, open redirects, router guard bypass); emits an exec summary plus graded findings. Use to audit Vue for vulnerabilities. Not for architecture grading (vue-architecture-checklist).
tools
Analyzes legacy Vue codebases and produces actionable modernization plans. Primary migration paths include Options API to Composition API, Vue 2 to Vue 3, Vue CLI to Vite, JavaScript to TypeScript, Vue Test Utils/Karma/Mocha to Vitest + Vue Testing Library, legacy Vuex to Pinia, and removed-in-Vue-3 pattern cleanup (filters, event bus, `$listeners`). Does NOT perform the migration — assesses, quantifies risk, and plans.