apm prune
Remove installed packages from apm_modules/ that are no longer declared in apm.yml, along with their deployed integration files. Updates apm.lock.yaml to match.
Synopsis
Section titled “Synopsis”apm prune [--dry-run]Description
Section titled “Description”apm prune reconciles three states:
- Packages declared in
apm.yml - Packages installed under
apm_modules/ - Packages recorded in
apm.lock.yamlwith theirdeployed_files
Anything installed but no longer declared is orphaned. apm prune removes the orphan’s directory under apm_modules/, deletes every file the orphan deployed into your harness directories (using the deployed_files manifest in the lockfile), removes the entry from apm.lock.yaml, and cleans up empty parent directories.
If apm_modules/ does not exist, the command exits cleanly with nothing to do. If apm.yml is missing, it exits with an error.
Options
Section titled “Options”| Option | Description |
|---|---|
--dry-run | List orphaned packages without removing anything. |
Examples
Section titled “Examples”Remove orphaned packages:
apm prunePreview what would be removed:
apm prune --dry-runTypical workflow after editing apm.yml:
# Remove a dependency from apm.yml, then:apm install # installs the new stateapm prune # cleans up what is no longer declaredBehavior
Section titled “Behavior”For each orphaned package, apm prune:
- Removes the package directory from
apm_modules/<owner>/<repo>using a path-traversal-safe delete. - Reads
deployed_filesfrom the lockfile entry and deletes each deployed file or directory inside the project root. - Removes the entry from
apm.lock.yaml. - Cleans up empty parent directories under both
apm_modules/and the harness deploy roots. - Deletes
apm.lock.yamlif pruning leaves it with zero dependencies.
Notes:
- Packages that share an install root with a still-declared sibling subdirectory dependency are not falsely protected by ancestor expansion. The check uses lockfile membership (with
apm.ymlfallback) to identify genuine standalone packages. - Deploy paths are validated before deletion; entries that escape the project root are skipped.
- The command does not network. It only inspects local state.
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
| 0 | Prune completed (including “nothing to prune”). |
| 1 | apm.yml missing, parse failure, or unhandled error. |
Per-package removal failures are logged but do not abort the run; remaining orphans still process.
Related
Section titled “Related”apm install— install declared dependenciesapm list— inspect what is installed- Lockfile spec —
deployed_filesschema - Package anatomy — what gets deployed where