php-package-scaffold
Skill3 starsChanged 3 months agoMITView on GitHub
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.
- Commits and pushes
In this repository86 other files it gives its agents.
- AGENTS.mdAGENTS.md
- project-templates/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- project-templates/CLAUDE.mdCLAUDE.md
- alembic-migration-managerSkill
- architecture-journalSkill
- architecture-reviewSkill
- automated-code-reviewSkill
- axum-scaffolderSkill
- capture-consolidateSkill
- cargo-package-scaffoldSkill
- code-review-coachSkill
- confluence-guide-writerSkill
- dependency-mapperSkill
- doc-syncSkill
- dotnet-architecture-checklistSkill
- dotnet-controller-api-scaffolderSkill
- dotnet-security-reviewSkill
- dotnet-vertical-sliceSkill
- ef-migration-managerSkill
- email-captureSkill
- environment-healthSkill
- evaluate-testsSkill
- fastapi-scaffolderSkill
- fitness-functionsSkill
- jira-comment-writerSkill
- legacy-migration-analyzerSkill
- minimal-api-scaffolderSkill
- nuget-package-scaffoldSkill
- oss-vettingSkill
- pattern-tradeoff-analyzerSkill
- php-api-scaffolderSkill
- php-architecture-checklistSkill
- php-feature-sliceSkill
- php-migration-managerSkill
- php-security-reviewSkill
- pr-feedback-writerSkill
- pypi-package-scaffoldSkill
- python-architecture-checklistSkill
- python-feature-sliceSkill
- python-modernization-analyzerSkill
- python-security-reviewSkill
- qraspi-architectureSkill
- qraspi-graduateSkill
- qraspi-implementSkill
- qraspi-planSkill
- qraspi-questionsSkill
- qraspi-researchSkill
- qraspi-skeletonSkill
- qrspi-implementSkill
- qrspi-planSkill
- qrspi-questionsSkill
- qrspi-researchSkill
- qrspi-specSkill
- react-app-scaffolderSkill
- react-architecture-checklistSkill
- react-component-scaffolderSkill
- react-feature-sliceSkill
- react-modernization-analyzerSkill
- react-security-reviewSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 44
Use search_knowledge (grounded-code-mcp, collection="php").
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PHP Package Scaffold (Composer / Packagist)
"A library is a contract. Once published, every breaking change is someone else's incident."
"Make it work, make it right, make it releasable."
Core Philosophy
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:
- Valid
composer.json—composer validate --strictpasses - PSR-4 autoloading —
src/mapped to a vendor namespace; tests in a separateautoload-dev declare(strict_types=1)in everysrc/file- Semver discipline — tags are
vX.Y.Z; breaking changes only on MAJOR - CI gate before publish — tests + PHPStan + style must pass on the tag
- Declared, bounded dependency constraints — caret ranges, no
dev-master, no unbounded*
The full domain principles, AI discipline rules, anti-pattern catalog, and error-recovery
procedures live in references/conventions.md.
Knowledge Base Lookups
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 |
Workflow
Phase 1: PLAN
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.orgRecord: vendor/package, root namespace, license (SPDX id), supported PHP range, runtime deps.
Phase 2: SCAFFOLD
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 .gitattributesPhase 3: VERIFY LOCALLY
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/phpunitPhase 4: PUBLISH
# 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.
State Block
<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>Output Template
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).
Integration with Other Skills
| 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-loop | Drive the public API test-first so the released contract is the tested contract. |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

