# Agent Committed Node Modules By Accide 6bcfdac198c5f290

> Shrinks an upgrade PR that accidentally committed node_modules. Use it when a dependency PR shows tens of thousands of files. Key trigger: the PR diff is dominated by node_modules paths. Not for: a legitimately large but coherent change, like a lockfile regeneration plus vendored assets.

- Skill: `vectle/agent-committed-node-modules-by-accide-6bcfdac198c5f290` (Agent Skill)
- Install (CLI): `npx get-skill add vectle/agent-committed-node-modules-by-accide-6bcfdac198c5f290`
- Raw SKILL.md: https://api.skillmd.com/api/skills/vectle/agent-committed-node-modules-by-accide-6bcfdac198c5f290/raw
- Safety review: pending (external: skill-scanner PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: Vectle (https://skillmd.com/u/vectle)
- Updated: 2026-11-19
- Page: https://skillmd.com/skills/vectle/agent-committed-node-modules-by-accide-6bcfdac198c5f290

---


## TL;DR
node_modules got committed, turning a one-line bump into a 40,000-file PR. Remove the directory from git tracking, add it to .gitignore, and rewrite the PR so it only carries the lockfile and manifest changes.

## Error
```text
agent committed node_modules by accident  -  the upgrade PR was 40,000 files
```

## Steps
1. Confirm the scope: check the PR file list for node_modules paths.
   Expected output: The bulk of the diff is node_modules content.
2. Remove it from tracking with git rm -r --cached node_modules (keep the files on disk) and add node_modules/ to .gitignore.
   Expected output: git status no longer lists the directory.
3. If the PR is already open, force-push the cleaned branch, or close it and open a fresh PR with only the manifest and lockfile changes.
   Expected output: The PR shows the bump and its lockfile diff, nothing else.
4. Add a pre-commit hook or CI check that fails when node_modules paths appear in a commit.
   Expected output: The accident cannot repeat silently.
5. Have the agent verify PR size before requesting review; anything over your threshold gets inspected first.
   Expected output: Oversized PRs are caught by the author, not the reviewer.

## When to use
- A PR suddenly contains thousands of unexpected files
- The diff is dominated by node_modules
- You are setting up guardrails for agent-committed changes

## When not to use
- A large diff from a lockfile regeneration; that is expected churn
- Vendored dependencies committed on purpose; that is a policy choice
- Binary asset PRs with legitimately many files

### Variant phrasings
#### upgrade PR has 40000 files all in node_modules
#### node_modules committed to git by accident
#### remove node_modules from a pull request

## Why it happens
The agent ran npm install in a repo without a .gitignore (or with a stale one), then committed everything. Install output is local build state, not source, and committing it multiplies the diff by every transitive file.

## Edge cases
- If node_modules was committed on main long ago, removing it rewrites history for everyone; coordinate the cleanup.
- Some legacy deploys package node_modules; move that step to the build pipeline instead of the repo.
- git rm --cached leaves the directory on disk, so local dev keeps working.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_TsN7P4Y-PejCDZ6-kGLtUA


---

Source: [Vectle](https://vectle.com/skills/skl_QsU_OTqUJ4A-n53KxXUyvQ). Version: `skv_qpEFnYiA9upPgaDpnDKGSA`. Original contributor attribution is preserved in the frontmatter. Content remains subject to [Vectle’s terms](https://vectle.com/terms) and its contributors’ rights; this mirror does not grant a new content license.

