d112ded3da feat: Merge template config into existing user config during setup install (#189)
* docs: Add config merging design spec for #114

Defines the merge-during-setup-install approach for keeping user
configs up to date with new template keys while preserving all
existing values, comments, and formatting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: Add implementation plan for config merging

TDD-based plan with 6 tasks: dependency setup, failing tests,
core merge implementation, integration test, WriteTemplateConfig
integration, and full verification.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: Merge template config into existing user config during setup install

Instead of skipping when a config file exists, WriteTemplateConfig() now
merges missing keys from the embedded template into the user's config
using YAML AST manipulation. Preserves all user values, comments, and
formatting. Only adds keys present in the template but absent in the
user's config.

Closes #114

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: Graceful error handling for config loading and setup commands

Replace panics in loadViperConfig with error returns so the app falls
back to defaults instead of crashing on malformed config files. Add
SilenceUsage to setup install/remove commands so runtime errors don't
dump the full usage text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* add test cmd in readme

* update copy text

* refactor: Address review feedback on config merging

- Rename existing/template to dest/source for generic util naming
- Remove unnecessary code comments (Rule N references, obvious comments)
- Add AGENTS.md with dev guide and code style rules, symlink CLAUDE.md
- Add BenchmarkMergeYAML (~46μs/op on M4 Pro)
- Remove stale design spec

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* update `MergeYAML` to use from dry/utils

* update AGENTS.md

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-31 19:21:01 +05:30
2025-12-03 20:28:45 +05:30
2026-02-16 13:35:58 +05:30
2025-03-20 07:59:48 +05:30
2025-08-21 23:01:30 +05:30

PMG GitHub Banner

Package Manager Guard (PMG)

Docs Website Discord

Go Report Card License Release OpenSSF Scorecard CodeQL


pmg in action

Why PMG?

AI coding agents install packages you didn't choose. Claude Code, Cursor, Copilot, Windsurf all run npm install and pip install autonomously, and you have no idea what they just put on your machine.

PMG ensures every package is checked for malware before it executes, whether you picked it or an AI agent did.

  1. Analyze packages for malware before they are installed.
  2. Sandbox the installation process to prevent system modification.
  3. Audit every package installation event.

Install PMG once, and every npm install, pip install, and poetry add is protected automatically.

Featured in tl;dr sec and used by engineering teams worldwide to secure their software supply chain.

How PMG is Different

Most security tools scan after installation and report vulnerabilities. By then, malicious code has already executed on your machine.

PMG intercepts package managers before code executes, blocking malicious packages at install time, not flagging them after the damage is done. Detection is powered by SafeDep's malicious package analysis engine. For defense in depth, PMG sandboxes the installation process using OS-native isolation, so even zero-day malware that evades detection cannot modify your system.

Quick Start

Get protected in seconds.

1. Install

MacOS / Linux (Homebrew)

brew install safedep/tap/pmg

NPM

npm install -g @safedep/pmg

See Installation for additional methods.

2. Setup

Configure your shell to use PMG automatically.

pmg setup install
# Restart your terminal to apply changes

3. Use

Use your package managers as usual — or let your AI coding agent use them. PMG works silently in the background.

npm install express
# or
pip install requests

Verify PMG is working by installing a test package. This is a harmless package flagged as malicious in the SafeDep database, specifically meant for testing:

npm i safedep-test-pkg@0.1.3
Expected output
✗ Malicious package blocked

  - safedep-test-pkg@0.1.3
    Reference: https://app.safedep.io/community/malysis/01KF5JYDND9XR94WNEJ2G74KY2

✗ PMG: 1 packages analyzed, 1 blocked

Features

Feature Description
AI Agent Safety Net Protects against malicious packages installed by AI coding agents (Claude Code, Cursor, Copilot, Windsurf).
Malicious Package Protection Real-time protection against malicious packages using SafeDep.
Sandboxing Enforces least privilege using OS native sandboxing to contain installation scripts.
Dependency Analysis Deep scans of direct and transitive dependencies before they hit your disk.
Event Logging Keeps a verifiable audit trail of all installed packages.
Zero Config Works out of the box with sensible security defaults.
Cross-Shell Seamlessly integrates with Zsh, Bash, Fish, and more.

Supported Package Managers

PMG supports the tools you already use:

Ecosystem Tools Status Command Example
Node.js npm Yes npm install <pkg>
pnpm Yes pnpm add <pkg>
yarn Yes yarn add <pkg>
bun Yes bun add <pkg>
npx Yes npx <pkg>
pnpx Yes pnpx <pkg>
Python pip Yes pip install <pkg>
poetry Yes poetry add <pkg>
uv Yes uv add <pkg>

Installation

Homebrew (MacOS/Linux)
brew tap safedep/tap
brew install safedep/tap/pmg
NPM (Cross-Platform)
npm install -g @safedep/pmg
Go (Build from Source)
# Ensure $(go env GOPATH)/bin is in your $PATH
go install github.com/safedep/pmg@latest
Binary Download

Download the latest binary for your platform from the Releases Page.

Trust and Security

Security is our first class requirement. PMG builds are reproducible and signed.

  • Attestations: GitHub and npm attestations are used to guarantee artifact integrity.
  • Verification: Users can cryptographically prove the binary matches the source code.
  • See Trusting PMG for verification steps.

User Guide

Support

If PMG saved you from a bad package, star this repo — it helps others find it.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines on how to build and test PMG locally.

Telemetry

PMG collects anonymous usage data to improve project stability and reliability. To disable: export PMG_DISABLE_TELEMETRY=true.

Languages
Go 98.1%
JavaScript 1%
Shell 0.8%