lpm remove
Remove tracked source files, restore overwritten originals, and preserve your edits.
lpm remove removes source files that lpm add copied into the current project.
lpm remove [OPTIONS] <PACKAGE>
lpm rm [OPTIONS] <PACKAGE>Use it for source packages from npm, LPM.dev Registry, or a private registry.
For dependencies in node_modules, use lpm uninstall.
Quickstart
From the project directory, remove a source package:
lpm remove @lpm.dev/owner.ui-kitLPM CLI reads the lpm-sources.json record that lpm add wrote and checks each tracked file before removal.
It preserves your edits and restores originals that the add operation overwrote.
The command works without a registry connection or confirmation prompts.
| Goal | Command |
|---|---|
| Remove a source package | lpm remove source-pkg |
| Remove a scoped source package | lpm remove @scope/components |
| Use the short LPM.dev Registry name | lpm rm owner.ui-kit |
| Return a machine-readable result | lpm remove source-pkg --json |
lpm.json has no remove configuration block.
Removal uses the tracked paths, including custom destinations from lpm add --path.
Examples
Remove source from a custom directory
lpm add source-pkg --path ./src/vendor --yes
lpm remove source-pkgThe remove command finds the recorded paths under src/vendor. It needs no destination flag.
Reconcile dependencies after removal
lpm remove source-pkg
lpm installRemoval can delete dependency declarations that the source package introduced.
It leaves dependency lockfiles and node_modules unchanged.
lpm install reconciles them with the updated package.json.
Remove source in automation
lpm remove source-pkg --json > remove-result.jsonAn untracked package returns success with an empty removed list.
This permits repeated cleanup, but success alone does not show that the name matched a tracked package.
Files and ownership
LPM CLI removes an unchanged file that the add operation created. For an unchanged overwritten file, it restores the saved original, including its recorded Unix permissions. If the copied replacement is already missing, LPM CLI still restores the original.
Removal preserves:
- Files that you edited after the add operation.
- Preexisting files that the add operation left unchanged.
- Files whose tracking record lacks enough information for safe removal.
- Files and dependency declarations that another source package still owns.
LPM CLI keeps ownership records and backups for preserved managed files. For shared files, it transfers the required ownership and backup information to the remaining package. The last owner can then remove the managed file or restore the original.
Only empty directories created by source delivery are eligible for cleanup. Preexisting directories and directories with other content remain.
The source record
lpm-sources.json at the project root records what lpm add delivered. Commit it with the copied files, so lpm remove works in every checkout.
For each source package, it records the delivered version, each created or overwritten file with a project-relative / path and digest, created directories, inserted dependency declarations, and installed package skills.
For an overwritten file, it records the original's digest and Unix permissions. The original's backup copy stays in .lpm/added-source-backups/ on the machine that ran lpm add.
Overwritten file, unchanged since lpm add | Removal |
|---|---|
| Backup copy on this machine | Restores the original. |
| No backup copy on this machine | Keeps the file and warns. Restore the original from version control if you need it. JSON lists the path in originalsElsewhere. |
LPM CLI deletes lpm-sources.json after the last tracked package is removed.
A .lpm/added-sources.json record from an earlier release is still read. LPM CLI replaces it with lpm-sources.json the next time the record changes.
Without a tracking record, the command cannot identify source files for removal. See Files LPM CLI creates.
Dependency declarations
For a dependency declaration, removal requires all these conditions:
- The source package introduced the declaration.
- Its dependency section and version requirement still match the recorded values.
- No remaining source package needs it.
Existing or edited declarations remain in package.json.
See lpm add --no-install-deps to skip consumer dependency changes during source delivery.
Package skills
Removal cleans up unchanged package skills under .lpm/skills/.
It rejects modified skill files or unexpected content in the package skill directory.
If the package is still a dependency in package.json, including through an npm: alias, removal keeps its skills, because installs maintain them. JSON reports the kept directory in keptSkills.
For editor links from older CLI versions, cleanup removes only links to that package's materialized skill files. User files, directories, and links to other targets remain. See AI agent skills.
Workspaces
Run the command from the member that received the source files:
cd packages/web
lpm remove @lpm.dev/owner.ui-kitRemoval uses the nearest directory with a package.json, as lpm install does. From a subdirectory, it prints the directory it chose. It does not select other workspace members.
Workspace members share the root project lock, which prevents conflicting package operations.
Recovery
After an interrupted removal, run the same command again:
lpm remove source-pkgBefore the new operation, LPM CLI recovers unfinished source changes, source tracking, and staged manifests. Recovery also restores original directory objects and overwrite backups. If removal already committed, the next command finishes archive cleanup.
If recovery finds later edits, it stops and preserves them.
Save those edits separately before you reconcile the paths named in the error.
Recovery records and original copies remain under .lpm/install-recovery/ and the reported .lpm/.source-remove-* archive.
In a workspace, the recovery records belong to the workspace root. A removal archive stays with its member.
Keep those recovery files until recovery succeeds.
If dependency state needs reconciliation, run lpm install after source recovery.
JSON output
lpm remove source-pkg --json{
"success": true,
"package": "source-pkg",
"removed": ["src/vendor/Source.ts"],
"preserved": ["src/vendor/Edited.ts"],
"originalsElsewhere": ["src/vendor/index.ts"],
"dependenciesRemoved": ["source-helper"],
"keptSkills": ".lpm/skills/owner.ui-kit/"
}removed includes tracked files that LPM CLI deleted or restored, plus removed skill paths and editor links.
preserved lists source files that remain after ownership and content checks.
originalsElsewhere lists overwritten files kept because their original's backup is in another checkout, such as a clone on another machine.
dependenciesRemoved lists deleted dependency declarations.
keptSkills names the skill directory kept because the package is still a dependency.
Empty preserved, originalsElsewhere, and dependenciesRemoved fields and an absent keptSkills are omitted.
Flags
| Flag | Effect |
|---|---|
--json | Return the removal result as JSON. |
-h, --help | Show command help. |
The command has no dedicated --dry-run, --force, or --yes flag.
See global flags for shared output controls.
See also
lpm add— copy and track source packageslpm uninstall— remove installed dependencieslpm install— reconcile dependencies after source removal- Workspaces — manage projects with shared dependencies