composer-packages
Use when building or maintaining a Composer library — versioning, Laravel integration, autoloading, publishing to private registries — even when the user says 'release a new version'.
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 19
- Forks
- 1
01 前言 Front Matter
- name
- composer-packages
- packs
- [ "php" ]
- trust
- { "level": "professional" }
- domain
- engineering
- install
- { "default": false, "removable": true }
- model_tier
- medium
- workspaces
- [ "engineering" ]
- description
- Use when building or maintaining a Composer library — versioning, Laravel integration, autoloading, publishing to private registries — even when the user says 'release a new version'.
02 资源文件 1
- 参考文档evals/triggers.json2.8 KB
03 SKILL.md 正文
composer-packages
When to use
Use this skill when creating, maintaining, or publishing Composer library packages — including Laravel packages with service providers, Artisan commands, and config publishing.
Procedure: Work with Composer packages
- Read the package's
composer.jsonfor structure and dependencies. - Check if it's a Laravel package (look for
extra.laravel.providers). - Read the package's
README.mdandCHANGELOG.md. - Check the
agents/directory in the package for package-specific docs.
Known packages
Check the project's composer.json for organization-specific packages.
Check agents/overrides/skills/composer-packages.md for the package registry and known packages list.
Package structure
my-package/
├── src/ # Source code
│ ├── App/
│ │ └── Providers/ # Laravel service providers
│ └── ...
├── config/ # Publishable config files
├── tests/ # Package tests
├── composer.json # Package manifest
├── README.md # Documentation
├── CHANGELOG.md # Version history
└── agents/ # Package-specific agent docs
composer.json essentials
Required fields
{
"name": "vendor/my-package",
"type": "library",
"description": "Clear, concise description",
"require": {
"php": "^8.2"
},
"autoload": {
"psr-4": {
"Vendor\\MyPackage\\": "src/"
}
}
}
Laravel package auto-discovery
{
"extra": {
"laravel": {
"providers": [
"Vendor\\MyPackage\\App\\Providers\\PackageServiceProvider"
]
}
}
}
Composer scripts / plugins
Packages can hook into Composer lifecycle events:
{
"scripts": {
"post-install-cmd": [
"MyNamespace\\ComposerScripts::onInstall"
]
}
}
Version constraints
Use wide version ranges for library packages to maximize compatibility:
{
"require": {
"php": "^8.1 || ^8.2 || ^8.3 || ^8.4",
"illuminate/support": "^10.0 || ^11.0 || ^12.0"
}
}
Libraries should use || ranges. Applications should use ^ (caret).
Advisories, abandoned packages, audit
composer audit --lockedchecks the lockfile against the Packagist advisory database; CI should run it so a known advisory is a red check, not a surprise. It exits non-zero when it finds something — that is the answer, not an error.config.auditincomposer.json(abandoned: fail,ignorewith a reason per advisory ID) makes Composer itself refuse on install; anignorewithout a reason is a silenced finding, not an accepted one.- Abandoned packages show in
composer outdated --directand incomposer audit; pick the suggested replacement before the abandonment becomes an unpatched advisory. - The Composer binary is a dependency too — it has had its own advisories;
keep it on a supported release (
composer self-update --stable). - Ongoing monitoring between changes:
agent-config audit:deps refreshreads the lockfile, the declared PHP version and the PHP release feed, and names what needs action today.
Local development
Path repositories
In the consuming project's composer.json:
{
"repositories": [
{ "type": "path", "url": "../packages/my-package" }
]
}
Then: composer require vendor/my-package:@dev
Development project
If the organization has a dedicated development sandbox for testing packages, use it for local testing.
Publishing
Private registry (GitHub Packages / Satis)
Packages are published to a private Composer registry. Check the organization's Satis or GitHub Packages setup.
Pre-publish checklist
composer validate— verifycomposer.jsonis valid.composer dump-autoload— verify autoloading works.- Run tests:
vendor/bin/phpunitorvendor/bin/pest. - Run quality tools: PHPStan, ECS, Rector.
- Update
CHANGELOG.mdwith the new version. - Tag the release:
git tag v1.2.3.
Conventions
- Follow the organization's namespace convention (check existing packages).
- Use
declare(strict_types=1)in all PHP files. - Use typed properties, parameters, and return types.
- Follow the same coding standards as the main projects (see
php-coderskill). - Include
agents/directory for package-specific documentation.
Output format
- Package files following standard Composer structure
- Updated composer.json with correct autoloading and dependencies
- Service provider and config publishing (if Laravel package)
Auto-trigger keywords
- Composer package
- library development
- package versioning
Gotcha
- Don't add
composer.lockto library packages — it should be in.gitignorefor libraries (not apps). - Minimum stability must be explicit — don't assume
stable. - The model tends to set overly restrictive version constraints — use
^(caret) not=(exact).
Do NOT
- Do NOT use
*version constraints in library packages. - Do NOT require specific patch versions — use
^or||ranges. - Do NOT include dev dependencies in
require— userequire-dev. - Do NOT forget to run
composer validatebefore publishing. - Do NOT publish without updating the changelog and tagging.
04 同仓库更多 Skills
unknown-key-fixture
Declares a key the schema does not know.
portable-fixture
Declares only semantics the MCP-lite carrier transports whole.
non-portable-fixture
Declares a runtime semantic the carrier drops.
candidate-zero-width
A candidate whose prose carries an invisible joiner.
candidate-disclosure-suppression
A candidate whose prose tells the agent to withhold from the user.
candidate-dangerous-frontmatter
A candidate claiming an unscoped tool grant and a permission bypass.