agentleFS
AnyOrgNameAnyOrgName/php-skills/skills/composer/dependency-management/SKILL.md

dependency-management

Skill4 starsChanged 4 months agoMITView on GitHub

Declare, constrain, and update PHP dependencies with Composer — require vs require-dev, semantic version constraints, install vs update, and the lock file. Use when the user wants to add, remove, or upgrade a third-party PHP package in a project managed by Composer; the user needs to pick or tighten a version constraint (caret, tilde, or exact) for a dependency; the user needs a reproducible, locked dependency set for CI or production deployment. Keywords: composer, dependencies, version-constraints, lock-file, semver.

18 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use infrastructure-as-code, release-management and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • mmondoraSkill

    infrastructure-as-code

    Infrastructure as Code with Terraform and Pulumi. State management, modularity, drift detection, secrets handling. Use when provisioning cloud resources, writing Terraform/Pulumi modules, or managing infrastructure configuration.

    Also in 4 projects that use this

  • Microsoft AzureSkill

    release-management

    Prepares and validates AI Landing Zone semantic releases. Use for changelog entries, manifest versions, release branches, tags, GitHub Releases, and post-release branch reconciliation.

    Also in 4 projects that use this

  • barisariburnuSkill

    performance-optimization

    Complete performance optimization guide for Next.js applications including frontend, backend, database, caching, and general optimization strategies. Use when improving performance, reducing bundle size, optimizing queries, or implementing caching.

    Also in 6 projects that use this

  • MicrosoftSkill

    deployment

    Also in 3 projects that use this

  • OpenAISkill

    observability

    Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.

    Also in 4 projects that use this

  • wrsmith108Skill

    docker

    Container-based development for isolated, reproducible environments. Use when running npm commands, installing packages, executing code, or managing project dependencies. Trigger phrases include "npm install", "run the build", "start the server", "install package", or any code execution request.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 17 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do not use Composer to load optional feature modules or plugins that must be enabled or disabled at runtime.

    line 62
  2. Distinctive:

    Do not use this skill to patch or hand-edit files under vendor/.

    line 63
  3. Very specific:

    Run composer require vendor/package:^2.3 to add the package and record a caret constraint in composer.json.

    line 78
  4. Very specific:

    Commit both composer.json and the regenerated composer.lock so the exact resolved versions are shared with the team.

    line 80
  5. Very specific:

    Run composer audit in CI to fail the build when a required package has a known security advisory, and keep constraints loose enough to …

    line 87
  6. Distinctive:

    Not applicable — no I/O, auth, or untrusted input.

    line 116

“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- generated: do not edit — source: knowledge/atoms/composer/dependency-management/ --><!-- schema: atomVersion=3 skillVersion=2 graphVersion=1 --><!-- compile: @php-skills/compiler v1.0.0 (deterministic build) -->

Composer Dependency Management

When to use

  • The user wants to add, remove, or upgrade a third-party PHP package in a project managed by Composer.
  • The user needs to pick or tighten a version constraint (caret, tilde, or exact) for a dependency.
  • The user needs a reproducible, locked dependency set for CI or production deployment.

When NOT to use

  • Do not use Composer to load optional feature modules or plugins that must be enabled or disabled at runtime.
  • Do not use this skill to patch or hand-edit files under vendor/; that directory is regenerated on every install.

Core guidance

  • Prefer caret constraints for semver libraries — Use a caret constraint (^2.3) for libraries that follow semantic versioning so Composer accepts compatible minor and patch releases but never a breaking major.
  • Commit the lock file for applications — Commit composer.lock for applications so every developer and every environment installs identical versions; do not commit it for a reusable library you publish.
  • Use install to reproduce, update to change versions — Run composer install to reproduce the exact versions in composer.lock, and run composer update only when you intend to resolve new versions and rewrite the lock.
  • Split runtime and development dependencies — Put packages the application needs at runtime under require, and tools only used while developing or testing (PHPUnit, PHPStan, fixtures) under require-dev.

Quick recipe

  1. Run composer require vendor/package:^2.3 to add the package and record a caret constraint in composer.json. (verify: composer.json lists vendor/package under require with a caret constraint)
  2. Commit both composer.json and the regenerated composer.lock so the exact resolved versions are shared with the team. (verify: git status shows both composer.json and composer.lock staged together)
  3. In CI and on deploy, run composer install --no-dev so the exact locked versions are restored without dev tooling. (verify: The CI install resolves the same versions as the committed lock and exits 0)

Best practices

  • Run composer audit in CI to fail the build when a required package has a known security advisory, and keep constraints loose enough to absorb patch releases
  • Declare the PHP version and required extensions in require (for example "php": ">=8.1" and "ext-json": "*") instead of relying on the developer's local environment

Anti-patterns

Anti-patternWhy it failsDo instead
Committing the vendor directory to version controlIt bloats history, causes merge conflicts, and hides the lock file as the real source of truth for dependency versions.Gitignore vendor/, commit composer.lock, and rebuild vendor with composer install in CI and on deploy.
Putting development tooling in requireThey ship to production, enlarging the deployed artifact and its attack surface, and they slow the production install.Move all development-only tools to require-dev and deploy with composer install --no-dev.
Pinning every constraint to an exact versionExact pins block patch-level security fixes and force a manual constraint edit for<br>every update; the lock file already gives reproducibility without freezing the<br>constraint.Use caret constraints in composer.json and rely on committed composer.lock for reproducible installs.

See references/anti-patterns.md.

Common mistakes

  1. Editing composer.json without updating the lock — Hand-editing a constraint in composer.json without running an update leaves the lock file out of sync. Fix: After changing a constraint, run composer update vendor/package to re-resolve just that package and refresh the lock.
  2. Running composer update during deployment — Running composer update on the deploy host re-resolves versions and can ship untested code to production. Fix: Deploy with composer install --no-dev against the committed lock, and run update only in a reviewed pull request.
  3. Using a wildcard or unbounded constraint — A wildcard constraint like "*" or ">=1.0" lets Composer pull a breaking major version without warning. Fix: Pin the major with a caret (^1.0) so patch and minor releases flow in but breaking majors are blocked.

Version notes

  • Composer 2 tightens platform checks (PHP >=7.4) — Composer 2 enforces platform requirements more strictly and resolves dependencies faster than Composer 1; some Composer 1 plugins are incompatible.

Security

  • Not applicable — no I/O, auth, or untrusted input.

Testing

  • Activation and decision behavior are verified in eval/scenarios/composer/dependency-management.yaml.

Additional resources

  • references/anti-patterns.md
  • references/core.md
  • references/examples.md
  • references/pitfalls.md
  • references/recipes.md
  • references/version-differences.md

Knowledge graph

Related: composer/autoload-psr4, composer/scripts

<!-- graph-fragment: graph/fragments/composer/dependency-management.yaml -->

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.