{"_id":"@amulyavarshney/snip","name":"@amulyavarshney/snip","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@amulyavarshney/snip","version":"0.1.0","description":"Ruthless efficiency mode for AI coding agents. Delete first. Build last.","keywords":["yagni","minimalism","ai-coding","agent-skill","code-review","snip"],"license":"MIT","type":"commonjs","main":"./hooks/snip-instructions.js","bin":{"snip":"cli/snip.js"},"exports":{".":"./hooks/snip-instructions.js","./config":"./hooks/snip-config.js","./runtime":"./hooks/snip-runtime.js","./score":"./score/snip-score.js"},"scripts":{"test":"node --test tests/*.test.js && node scripts/check-rule-copies.js","test:instructions":"node --test tests/instructions.test.js","test:config":"node --test tests/config.test.js","test:hooks":"node --test tests/hooks.test.js","test:score":"node --test tests/score.test.js","test:cli":"node --test tests/cli.test.js","sync":"node scripts/check-rule-copies.js --fix","bench":"npx promptfoo@latest eval -c benchmarks/promptfooconfig.yaml","bench:view":"npx promptfoo@latest view","bench:share":"npx promptfoo@latest share","prepublishOnly":"npm test"},"engines":{"node":">=18"},"repository":{"type":"git","url":"git+https://github.com/amulyavarshney/snip.git"},"homepage":"https://github.com/amulyavarshney/snip","_id":"@amulyavarshney/snip@0.1.0","gitHead":"2fda19ee70e72816ca445430ced2b6c2e0ffc625","bugs":{"url":"https://github.com/amulyavarshney/snip/issues"},"_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-i/gZkpXaXP1nUedBhmRUZPw2N45M866UWkuzAq84760jDShVoZBbQwo90jdUdETCV/RlZpHXUiVI/FbiUl9qyg==","shasum":"200bc43a1ebe03feb11379b9d436a3ebad9f0007","tarball":"https://registry.npmjs.org/@amulyavarshney/snip/-/snip-0.1.0.tgz","fileCount":32,"unpackedSize":95986,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCgSW+cLJhmKc8B9wgdL8qDh4NMG54BHOOzcGFjvrhkbgIgH+vehZJWV0ApActzjB3J0gAzWSN5Hg5xn5A28C6xA4o="}]},"_npmUser":{"name":"amulyavarshney","email":"amulyavarshney7@gmail.com"},"directories":{},"maintainers":[{"name":"amulyavarshney","email":"amulyavarshney7@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/snip_0.1.0_1781684109743_0.13316359374464137"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-17T08:15:09.521Z","0.1.0":"2026-06-17T08:15:09.887Z","modified":"2026-06-17T08:15:10.106Z"},"maintainers":[{"name":"amulyavarshney","email":"amulyavarshney7@gmail.com"}],"description":"Ruthless efficiency mode for AI coding agents. Delete first. Build last.","homepage":"https://github.com/amulyavarshney/snip","keywords":["yagni","minimalism","ai-coding","agent-skill","code-review","snip"],"repository":{"type":"git","url":"git+https://github.com/amulyavarshney/snip.git"},"bugs":{"url":"https://github.com/amulyavarshney/snip/issues"},"license":"MIT","readme":"# ✂ snip\n\n**Ruthless efficiency mode for AI coding agents. Delete first. Build last.**\n\nSnip enforces a 7-rung deletion ladder on AI agents — starting with \"can this be deleted entirely?\" — and protects production paths from over-simplification with `snip:prod` annotations.\n\n---\n\n## The problem snip solves\n\nAI agents have a strong bias toward completeness. Ask for email validation, get a 27-line `EmailValidator` class with a regex that still rejects valid addresses. Ask for a cache, get a 120-line `TTLCache` with a lock, hit counter, and eviction policy — for a function that's called twice.\n\nSnip shifts the default the other way.\n\n---\n\n## snip: vs snip:prod — why this matters\n\nNo other tool in this space makes this distinction:\n\n```js\n// snip: plain object dispatch; upgrade to class registry if handlers exceed 10\nconst handlers = { 'order.created': handleOrder, 'user.signup': handleSignup };\n(handlers[event.type] ?? noop)(event);\n\n// snip:prod — HMAC verification is a timing-attack boundary; do not simplify\nconst sig = Buffer.from(req.headers['x-signature'], 'hex');\nconst expected = createHmac('sha256', secret).update(req.rawBody).digest();\nif (!timingSafeEqual(sig, expected)) return res.status(401).end();\n```\n\nBoth are minimal. One is safe to shrink further. One is not. `snip` tells you which is which.\n\n`// snip:prod` lines are excluded from the snip score — they are correctly complex by definition.\n\n---\n\n## Install\n\n### Claude Code\n```\n/plugin install snip\n```\n\n### Cursor\n```bash\ncurl -o .cursor/rules/snip.mdc \\\n  https://raw.githubusercontent.com/amulyavarshney/snip/main/.cursor/rules/snip.mdc\n```\n\n### Windsurf\n```bash\ncurl -o .windsurf/rules/snip.md \\\n  https://raw.githubusercontent.com/amulyavarshney/snip/main/.windsurf/rules/snip.md\n```\n\n### GitHub Copilot\n```bash\ncurl -o .github/copilot-instructions.md \\\n  https://raw.githubusercontent.com/amulyavarshney/snip/main/.github/copilot-instructions.md\n```\n\n### VS Code Extension\nSearch **\"Snip\"** in the VS Code Extension Marketplace, or:\n```bash\ncode --install-extension amulyavarshney.snip\n```\n\n### npm CLI\n```bash\nnpm install -g @amulyavarshney/snip\nsnip init       # create .snip.json in current project\nsnip score src/ # score your codebase\n```\n\n---\n\n## Benchmark results\n\nMeasured across 6 production-realistic tasks (JWT auth middleware, Go rate limiter, webhook HMAC validation, config loader, retry logic, query builder). Median of 10 runs per cell.\n\n| | baseline | snip full | snip ultra |\n|--|--|--|--|\n| LOC (median) | 68 | 14 | 8 |\n| Reduction | — | **~80%** | **~88%** |\n\nRun yourself: `npm run bench` (requires `ANTHROPIC_API_KEY`)\n\n---\n\n## Modes\n\n| Mode | Behavior |\n|------|----------|\n| `lite` | Builds what's asked; names the leaner option in one line |\n| `full` | Full 7-rung ladder + language overlays (default) |\n| `ultra` | Deletion-first; challenges requirements before writing |\n| `prod` | Full ladder + `// snip:prod` protection for trust boundaries |\n| `off` | Deactivated |\n\n```\n/snip             activate at default\n/snip ultra       switch to ultra\n/snip prod        switch to prod (recommended for financial/auth codebases)\n/snip lang go     switch language overlay\n/snip-review      review current code for over-engineering\n```\n\n---\n\n## The 7-rung ladder\n\nBefore any code is written, snip stops at the first rung that holds:\n\n```\n0. Can this be deleted entirely?\n1. Does this need to exist at all? (YAGNI)\n2. Does the standard library do this? Use it.\n3. Does a native platform feature cover it? Use it.\n4. Does an already-installed dependency solve it? Use it.\n5. Can it be one line? Make it one line.\n6. Only then: write the minimum code that works.\n```\n\nRung 0 is what makes snip different from other minimal-code tools — it fires on existing code, not just code being written.\n\n---\n\n## Language overlays\n\nSnip auto-detects your project's dominant language and adds idiomatic shortcuts.\n\n**Python** — list comprehensions over loops, `@dataclass`, `functools.lru_cache`, `pathlib.Path`, `contextlib.suppress`\n\n**TypeScript** — discriminated unions over class hierarchies, `as const` over enums, `crypto.randomUUID()` (Node 19+), `fetch` (Node 18+)\n\n**Go** — `errors.New` + `fmt.Errorf(\"%w\")` over custom error structs, table-driven tests, `sync.Once`, `io.Reader`/`io.Writer`\n\nDisable per-language in `.snip.json`:\n```json\n{ \"overlays\": { \"python\": false } }\n```\n\n---\n\n## Team config\n\nCommit `.snip.json` to your repo. Every developer and CI run picks it up automatically.\n\n```json\n{\n  \"mode\": \"full\",\n  \"language\": \"auto\",\n  \"prod\": { \"protect\": [\"auth\", \"payments\", \"billing\"] },\n  \"score\": { \"minScore\": 60, \"failBelow\": true }\n}\n```\n\n### CI gate\n\n```yaml\n# .github/workflows/snip.yml\n- name: Check snip score\n  run: npx @amulyavarshney/snip score src/ --min-score 60 --fail-below\n```\n\nThe snip score (0–100) measures how much of your codebase could be deleted or replaced with stdlib. `snip:prod` lines are excluded — they're correctly complex.\n\n---\n\n## Before/after examples\n\n| Example | Without | With |\n|---------|---------|------|\n| [JWT auth middleware](examples/auth-middleware.md) | 5 files, ~60 lines | 10 lines + `snip:prod` tag |\n| [Retry with backoff](examples/retry-logic.md) | 3-class hierarchy, 120 lines | 12-line async loop |\n| [Config loading](examples/config-merging.md) | ConfigManager + 4 sources, 70 lines | 10 lines |\n| [Webhook HMAC](examples/webhook-validation.md) | 5 classes, 80 lines | 8 lines + `snip:prod` tag |\n| [Go error types](examples/go-error-handling.md) | 7 types, 50 lines | 4 sentinel vars |\n\n---\n\n## Development\n\n```bash\n# Run all tests\nnpm test\n\n# Sync IDE rule copies from rules/base.md\nnpm run sync\n\n# Run benchmarks\nnpm run bench\n```\n\nTests use Node.js built-in `node:test`. Zero test dependencies.\n\n---\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-f9343aef5ba159f6ef7a3a67dd7c68cc"}