Metadata-Version: 2.5
Name: realdep
Version: 0.1.3
Summary: Stop AI coding agents from installing hallucinated, typo-squatted or brand-new malicious packages (slopsquatting). Checks pip, uv, poetry, npm, yarn, pnpm, bun, cargo, go and gem installs and manifest edits.
Project-URL: Homepage, https://github.com/shah2017/realdep
Project-URL: Documentation, https://github.com/shah2017/realdep/tree/main/docs
Project-URL: Issues, https://github.com/shah2017/realdep/issues
Project-URL: Security, https://github.com/shah2017/realdep/security/policy
Author: Prayash Bikram Shah
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: agents,ai-security,dependency-confusion,npm,pypi,slopsquatting,supply-chain,typosquatting
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security
Classifier: Typing :: Typed
Requires-Python: >=3.11
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: pip-audit>=2.7; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# Realdep

**Stop AI coding agents from installing packages that don't exist, or shouldn't.** Realdep checks every
package an agent tries to install (or add to a manifest) against the real registry before it happens,
and blocks hallucinated names, typosquats and freshly registered slopsquats, telling the agent the name
it probably meant.

[![CI](https://github.com/shah2017/realdep/actions/workflows/ci.yml/badge.svg)](https://github.com/shah2017/realdep/actions/workflows/ci.yml)
![Python](https://img.shields.io/badge/python-3.11%E2%80%933.14-blue)
![License](https://img.shields.io/badge/license-Apache%202.0-green)
[![PyPI](https://img.shields.io/pypi/v/realdep)](https://pypi.org/project/realdep/)
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/shah2017/realdep/badge)](https://scorecard.dev/viewer/?uri=github.com/shah2017/realdep)
![Dependencies](https://img.shields.io/badge/runtime%20dependencies-0-brightgreen)

---

## The problem: slopsquatting

Language models regularly invent package names that sound right but don't exist: `huggingface-cli-tools`,
`react-codeshift`, `flask-jwt-simple-auth`. Attackers watch for those names, register them on PyPI or
npm, and fill them with malware. The next agent that hallucinates the same name runs
`pip install <name>` and executes the attacker's code with your permissions. This is called
**slopsquatting**.

Classic typosquats (`reqeusts`, `expresss`) and import-name confusion (`pip install sklearn`, which
should be `scikit-learn`) hit agents the same way, because agents type fast and never double-check.

## What Realdep does

Before an install runs, Realdep:

1. **Parses** the command or manifest change: `pip`, `uv`, `poetry`, `pipenv`, `pdm`, `pipx`, `uvx`, `npm`,
   `npx`, `yarn`, `pnpm`, `bun`, `cargo`, `go`, `gem`; requirement files passed with `-r`; and edits to
   `requirements.txt`, `pyproject.toml`, `package.json`, `Cargo.toml`, `go.mod` and `Gemfile`.
2. **Skips** the thousands of packages everyone uses (bundled popularity lists, no network needed).
3. **Asks the real registry** about everything else: does it exist, when was it first published, how many
   releases, how many downloads, does it run install scripts?
4. **Decides:**

| Verdict | When |
|---|---|
| **Block** | The name does not exist (hallucinated) · it is one or two characters from a popular package and not heavily used itself (typosquat) · first published in the last 7 days · new, 1-2 releases and almost no downloads (the slopsquatting profile) · on your deny list |
| **Warn** | Import name instead of package name (`sklearn`, `cv2`, `yaml`, `bs4`…) · published in the last 30 days · very little use · install scripts · deprecated · placeholder version · git/URL/path installs · custom index or `--extra-index-url` (dependency confusion) |
| **Allow** | Everything else |

5. **Tells the agent how to fix it.** A block comes with the reason and the likely intended name, so the
   agent corrects itself instead of retrying:

```
$ realdep check -- pip install fastapi reqeusts sklearn
BLOCK pypi     reqeusts
        'reqeusts' does not exist on PyPI; it may be a hallucinated name. Did you mean 'requests'?
        suggestion: requests
WARN  pypi     sklearn
        'sklearn' is an import name; the package that provides it is 'scikit-learn'
        suggestion: scikit-learn
ok    pypi     fastapi
        widely used (top 63 on PyPI)
```

```
$ realdep pkg npm react-codeshift expresss
BLOCK npm      react-codeshift
        matches the slopsquatting profile: first published 321 day(s) ago, 1 release(s), 15 downloads last week
BLOCK npm      expresss
        name is one or two characters away from the popular package 'express' (possible typosquat)
        only release is a placeholder version (0.0.0)
        suggestion: express
```

## Install

```bash
pip install realdep
```

Python 3.11+. **Zero runtime dependencies** (standard library only), because a supply-chain guard
should not widen your supply chain.

## Use it

### Guard a coding agent (recommended)

Agents that support command hooks before tool use can run Realdep on every shell command and file
edit:

```bash
realdep hook --print-config
```

```json
{"hooks": {"PreToolUse": [{"matcher": "*", "hooks": [{"type": "command", "command": "realdep hook", "timeout": 30}]}]}}
```

Merge that into your agent's hooks settings. Blocked installs exit with code 2 and a reason the agent
reads, and warnings appear as a system message. Unrelated commands pass in milliseconds with no network.
See [docs/hooks.md](docs/hooks.md).

### Check by hand

```bash
realdep check -- npm i some-package            # exit 3 if anything is blocked
realdep pkg pypi requests reqeusts             # check names directly
realdep check --strict -- pip install x        # exit 3 on warnings too
```

### CI

```bash
realdep scan requirements.txt package.json pyproject.toml   # exit 3 on any block
```

Catch hallucinated dependencies that slipped into a pull request. See [docs/ci.md](docs/ci.md).

GitHub Action:

```yaml
- uses: shah2017/realdep@v0.1.3
  with:
    files: requirements.txt package.json
```

### pre-commit

```yaml
repos:
  - repo: https://github.com/shah2017/realdep
    rev: v0.1.3
    hooks:
      - id: realdep
```

Runs only when a manifest changes, and checks just those files.

## Coverage

| Ecosystem | Commands | Manifests | Registry checks |
|---|---|---|---|
| Python | pip, pip3, `python -m pip`, uv (pip/add/tool), uvx, poetry, pipenv, pdm, rye, pipx | requirements*.txt/.in, pyproject.toml (PEP 621, Poetry, dependency groups) | PyPI JSON API, pypistats |
| JavaScript | npm (install/exec), npx, yarn, pnpm, bun, bunx | package.json | npm registry, npm downloads API |
| Rust | cargo add/install | Cargo.toml | crates.io |
| Go | go get/install | go.mod | Go module proxy |
| Ruby | gem install | Gemfile | RubyGems |

## How it compares

| | Package auditors (npm audit, Socket, pip-audit) | Other slopsquatting CLIs | **Realdep** |
|---|---|---|---|
| Runs *before* the agent installs | no (after, or in CI) | yes | **yes** |
| Ecosystems | one or several | usually one | **5** |
| Install commands **and** manifest edits | manifests | commands | **both** |
| Tells the agent the intended name | no | rarely | **yes** |
| Import-name confusion (`sklearn`, `cv2`) | no | no | **yes** |
| Works offline for popular packages | n/a | no | **yes** |
| Runtime dependencies | many | some | **0** |

Use Realdep alongside dependency auditing: it stops bad names from getting in, and auditors find
vulnerabilities in the good ones.

## Documentation

[Getting started](docs/getting-started.md) · [Decision rules](docs/rules.md) · [Agent hooks](docs/hooks.md) ·
[CI](docs/ci.md) · [Configuration](docs/configuration.md) · [Threat model](docs/threat-model.md) · [FAQ](docs/faq.md)

## Limitations

- An old, popular, *legitimate-looking* package that turns malicious is a different problem; use a
  vulnerability and malware scanner for that.
- Decisions use public registry metadata and heuristics. Tune thresholds and keep allow/deny lists in
  `.realdep.json`.
- Private registries and custom indexes are flagged, not verified.
- If the registry is unreachable, Realdep warns and allows by default (`fail_closed` changes that).

## Reporting problems

Found a bug, or Realdep got a result wrong? [Open an issue](https://github.com/shah2017/realdep/issues/new/choose)
and include the output of:

```bash
realdep doctor
```

It prints versions, platform and configuration health with paths, your user name and secrets removed,
so it is safe to paste. Report security vulnerabilities privately instead; see [SECURITY.md](SECURITY.md).

## Security

Report vulnerabilities privately: see [SECURITY.md](SECURITY.md).

## License

[Apache License 2.0](LICENSE). Copyright 2026 Prayash Bikram Shah. Bundled popularity data is credited
in [NOTICE](NOTICE).
