What it does
Stops AI agents installing npm packages that don't exist, typosquats, or risky install scripts.
- Connects パソコンで動く
- Account or key No key needed
- Category 開発者ツール
一緒に使える
この種の作業を AI に教える Skill。これと一緒に使えます
andrej-karpathy-skills
A single CLAUDE.md file to improve Claude Code behavior, derived from Andrej Karpathy's observations on LLM coding pitfalls.
graphify
Turn any codebase, with its docs, SQL schemas, configs, and PDFs, into a queryable knowledge graph. A /graphify skill for Claude Code, Cursor, Codex, and Gemini CLI: local deterministic AST parsing, every edge explained, no vector store.
この順位の理由
一覧は利用スコア(100 点満点)で並びます。内訳は次のとおり
| 人気 | 7/80 | GitHub スターか週間ダウンロード数。大きい方を 60、小さい方を 20 で数えます |
|---|---|---|
| 新しさ | 12/12 | 30 日以内のリリースかコード更新で満点 |
| 応答中 | 0/8 | 前回の確認でクラウドのエンドポイントが応答 |
| 利用スコア | 19/100 |
品質: 基本チェック 2/3 項目に合格(表示のみ、並び順には不使用) · 勢い: データなし (「急上昇」タブでのみ使用)
インストール
使っているAIアプリを選んで、設定をコピーしてください。
ひとことで AI にインストールしてもらう
ghostimport をインストールして。https://mcp.popnx.com/i/fguerreir0-ghostimport.md に従い、コマンドを見せて、私が OK するまで実行しないで。パソコンで作業できる AI(Claude Code や Cursor など)に貼り付けます。手順を読み、コマンドを見せて、あなたの OK を待ちます。キー不要・登録不要。 · AI が読む全文を見る
チェック 2/3 合格 · あなたのパソコンで動きます · ✓ コマンド確認済み 2026年11月18日
まず:どの AI を使っていますか?
使っているアプリを選ぶと、下に手順が表示されます。
Claude につなげますが、先に準備が必要です
先にパソコンへ Node.js を入れてください(1 回だけ) · パソコン版 Claude アプリ(Windows または Mac)のみ。Web やスマホでは使えません
AI にインストールしてもらう
このメッセージを Claude のチャットに貼り付けます。AI がパソコンを確認し、変更するファイルを伝え、毎回あなたの了承を待ちます。
このパソコンの Claude に MCP server ghostimport を入れてください。順番に:1) node -v で Node.js があるか確認。なければ https://nodejs.org/en/download から入れるよう私に伝え、自分では入れない。2) この設定だけを使う(PopNx MCP の確認済み):{ "mcpServers": { "ghostimport": { "command": "npx", "args": [ "-y", "ghostimport", "mcp" ] } } } 3) 変更するファイルのフルパスか実行するコマンドを伝えて、私の了承を待つ。4) キーは不要。5) 了承した内容を実行し、ghostimport のツールが本当に表示されるか確認する。このメッセージにあなたのキーは含まれません。キーが必要な場合は、AI がファイルやアプリの入力欄にご自身で貼るよう案内します。
Node.js を入れる(まだなければ)
もう入っていますか?先に確認 · ターミナルを開き、このコマンドを入力して Enter
node -v- バージョン番号(例 v26.13.1)が出る = 入っています。この手順は飛ばせます
- "command not found"(Windows では "is not recognized")が出る = まだ入っていないか、入れた直後でターミナルを開き直す必要があります
ターミナルの開き方
Mac:⌘ + Space を押し、Terminal と入力して Enter
Windows:スタートメニューを開き、Windows PowerShell と入力して「開く」
まだ入っていない場合: 公式ダウンロードページで LTS 版と、クリックで進むインストーラーを選びます:Mac は .pkg、Windows は .msi。ダブルクリックして最後まで進めるだけで、curl コマンドは不要です
入れ終わったらターミナルを閉じて開き直し、同じコマンドをもう一度実行します。バージョン番号が出れば完了です:
node -v一度入れれば、Node.js を使うすべてのツールで使えます
パソコン版 Claude アプリの設定ファイルを開く
SettingsDeveloperEdit Config
この設定を貼り付けて保存
{ "mcpServers": { "ghostimport": { "command": "npx", "args": [ "-y", "ghostimport", "mcp" ] } } }Claude を終了してもう一度開く
試してみる
ghostimport を使って、私に何ができるか教えて、1 つやってみせて✓ Claude が ghostimport を使っていると言うか、回答に ghostimport のツール名が出れば接続成功です
メニュー名は 2026年11月11日 に Anthropic のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります
ChatGPT はまだ ghostimport につなげません
ghostimport はパソコンに入れて使うものですが、ChatGPT は Web 上で動くサーバーにしかつなげません
代わりにできること
A · ghostimport につなげるアプリを使う
- 先にパソコンへ Node.js を入れてください(1 回だけ) · パソコン版 Claude アプリ(Windows または Mac)のみ。Web やスマホでは使えません
- 先にパソコンへ Node.js を入れてください(1 回だけ)
- 先にパソコンへ Node.js を入れてください(1 回だけ)
- 先にパソコンへ Node.js を入れてください(1 回だけ)
B · 開発者ツール の中で ChatGPT につなげる別のサーバー
同じカテゴリでよく使われているものから、キーなしでアドレスだけでつなげるものを選びました
- Sentry✓ ChatGPT
- Compiler Explorer✓ ChatGPT
- GitDiagram✓ ChatGPT
Claude Code につなげますが、先に準備が必要です
先にパソコンへ Node.js を入れてください(1 回だけ)
AI にインストールしてもらう
このメッセージを Claude Code のチャットに貼り付けます。AI がパソコンを確認し、変更するファイルを伝え、毎回あなたの了承を待ちます。
このパソコンの Claude Code に MCP server ghostimport を入れてください。順番に:1) node -v で Node.js があるか確認。なければ https://nodejs.org/en/download から入れるよう私に伝え、自分では入れない。2) この設定だけを使う(PopNx MCP の確認済み):claude mcp add --scope user ghostimport -- npx -y ghostimport mcp 3) 変更するファイルのフルパスか実行するコマンドを伝えて、私の了承を待つ。4) キーは不要。5) 了承した内容を実行し、ghostimport のツールが本当に表示されるか確認する。このメッセージにあなたのキーは含まれません。キーが必要な場合は、AI がファイルやアプリの入力欄にご自身で貼るよう案内します。
Node.js を入れる(まだなければ)
もう入っていますか?先に確認 · ターミナルを開き、このコマンドを入力して Enter
node -v- バージョン番号(例 v26.13.1)が出る = 入っています。この手順は飛ばせます
- "command not found"(Windows では "is not recognized")が出る = まだ入っていないか、入れた直後でターミナルを開き直す必要があります
ターミナルの開き方
Mac:⌘ + Space を押し、Terminal と入力して Enter
Windows:スタートメニューを開き、Windows PowerShell と入力して「開く」
まだ入っていない場合: 公式ダウンロードページで LTS 版と、クリックで進むインストーラーを選びます:Mac は .pkg、Windows は .msi。ダブルクリックして最後まで進めるだけで、curl コマンドは不要です
入れ終わったらターミナルを閉じて開き直し、同じコマンドをもう一度実行します。バージョン番号が出れば完了です:
node -v一度入れれば、Node.js を使うすべてのツールで使えます
ターミナルを開く
Mac:Command+スペースで Terminal と入力 · Windows:PowerShell を開く
このコマンドを貼り付けて Enter
claude mcp add --scope user ghostimport -- npx -y ghostimport mcpClaude Code で /mcp と入力
ghostimport が一覧にあり、接続済みと表示されれば OK です
試してみる
ghostimport を使って、私に何ができるか教えて、1 つやってみせて✓ Claude Code が ghostimport を使っていると言うか、回答に ghostimport のツール名が出れば接続成功です
メニュー名は 2026年11月11日 に Anthropic のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります
Cursor につなげますが、先に準備が必要です
先にパソコンへ Node.js を入れてください(1 回だけ)
AI にインストールしてもらう
このメッセージを Cursor のチャットに貼り付けます。AI がパソコンを確認し、変更するファイルを伝え、毎回あなたの了承を待ちます。
このパソコンの Cursor に MCP server ghostimport を入れてください。順番に:1) node -v で Node.js があるか確認。なければ https://nodejs.org/en/download から入れるよう私に伝え、自分では入れない。2) この設定だけを使う(PopNx MCP の確認済み):{ "mcpServers": { "ghostimport": { "command": "npx", "args": [ "-y", "ghostimport", "mcp" ] } } } 3) 変更するファイルのフルパスか実行するコマンドを伝えて、私の了承を待つ。4) キーは不要。5) 了承した内容を実行し、ghostimport のツールが本当に表示されるか確認する。このメッセージにあなたのキーは含まれません。キーが必要な場合は、AI がファイルやアプリの入力欄にご自身で貼るよう案内します。
Node.js を入れる(まだなければ)
もう入っていますか?先に確認 · ターミナルを開き、このコマンドを入力して Enter
node -v- バージョン番号(例 v26.13.1)が出る = 入っています。この手順は飛ばせます
- "command not found"(Windows では "is not recognized")が出る = まだ入っていないか、入れた直後でターミナルを開き直す必要があります
ターミナルの開き方
Mac:⌘ + Space を押し、Terminal と入力して Enter
Windows:スタートメニューを開き、Windows PowerShell と入力して「開く」
まだ入っていない場合: 公式ダウンロードページで LTS 版と、クリックで進むインストーラーを選びます:Mac は .pkg、Windows は .msi。ダブルクリックして最後まで進めるだけで、curl コマンドは不要です
入れ終わったらターミナルを閉じて開き直し、同じコマンドをもう一度実行します。バージョン番号が出れば完了です:
node -v一度入れれば、Node.js を使うすべてのツールで使えます
Cursor の AI チャットを Agent モードで開く
試してみる
ghostimport を使って、私に何ができるか教えて、1 つやってみせて✓ Cursor が ghostimport を使っていると言うか、回答に ghostimport のツール名が出れば接続成功です
メニュー名は 2026年11月11日 に Cursor のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります
VS Code につなげますが、先に準備が必要です
先にパソコンへ Node.js を入れてください(1 回だけ)
AI にインストールしてもらう
このメッセージを VS Code のチャットに貼り付けます。AI がパソコンを確認し、変更するファイルを伝え、毎回あなたの了承を待ちます。
このパソコンの VS Code に MCP server ghostimport を入れてください。順番に:1) node -v で Node.js があるか確認。なければ https://nodejs.org/en/download から入れるよう私に伝え、自分では入れない。2) この設定だけを使う(PopNx MCP の確認済み):{ "servers": { "ghostimport": { "type": "stdio", "command": "npx", "args": [ "-y", "ghostimport", "mcp" ] } } } 3) 変更するファイルのフルパスか実行するコマンドを伝えて、私の了承を待つ。4) キーは不要。5) 了承した内容を実行し、ghostimport のツールが本当に表示されるか確認する。このメッセージにあなたのキーは含まれません。キーが必要な場合は、AI がファイルやアプリの入力欄にご自身で貼るよう案内します。
Node.js を入れる(まだなければ)
もう入っていますか?先に確認 · ターミナルを開き、このコマンドを入力して Enter
node -v- バージョン番号(例 v26.13.1)が出る = 入っています。この手順は飛ばせます
- "command not found"(Windows では "is not recognized")が出る = まだ入っていないか、入れた直後でターミナルを開き直す必要があります
ターミナルの開き方
Mac:⌘ + Space を押し、Terminal と入力して Enter
Windows:スタートメニューを開き、Windows PowerShell と入力して「開く」
まだ入っていない場合: 公式ダウンロードページで LTS 版と、クリックで進むインストーラーを選びます:Mac は .pkg、Windows は .msi。ダブルクリックして最後まで進めるだけで、curl コマンドは不要です
入れ終わったらターミナルを閉じて開き直し、同じコマンドをもう一度実行します。バージョン番号が出れば完了です:
node -v一度入れれば、Node.js を使うすべてのツールで使えます
VS Code の AI チャットを Agent モードで開く
試してみる
ghostimport を使って、私に何ができるか教えて、1 つやってみせて✓ VS Code が ghostimport を使っていると言うか、回答に ghostimport のツール名が出れば接続成功です
メニュー名は 2026年11月11日 に VS Code のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります
開発者向け:ターミナルのコマンドと JSON 設定
パソコンにインストール
Claude Code
claude mcp add --scope user ghostimport -- npx -y ghostimport mcpClaude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"ghostimport": {
"command": "npx",
"args": [
"-y",
"ghostimport",
"mcp"
]
}
}
}Cursor (~/.cursor/mcp.json)
{
"mcpServers": {
"ghostimport": {
"command": "npx",
"args": [
"-y",
"ghostimport",
"mcp"
]
}
}
}VS Code (mcp.json)
{
"servers": {
"ghostimport": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"ghostimport",
"mcp"
]
}
}
}この設定は、作者のレジストリ登録情報から作成しています。READMEと違う場合は、READMEに従ってください。
ひと目でわかる
- 週あたりのダウンロードi
- 206/週
- 接続方法
- パソコンで動く
- 最新バージョンi
- 0.7.4
- レジストリ公開日i
- 2026年11月18日
- コードの最終更新i
- 2026年11月18日
- 作者
- FGuerreir0
- パッケージ
npm: ghostimport- ウェブサイト
- fguerreir0.github.io
- レジストリでの状態
- 有効
使えるアプリ
このサーバーのつなぎ方と、各アプリの公式ドキュメントに基づきます。2026年11月10日に確認。
パソコン上で動かせるアプリ
ClaudeGooseLM StudioMsty StudioCherry StudioCursorVS Code + GitHub CopilotVisual StudioWindsurf (Devin Desktop)ZedKiroClineContinueJetBrains AI AssistantClaude CodeCodex CLIGemini CLIOpenCodenodecodeWarpLibreChatRaycast
できること
パソコンで動くサーバーです。インストールすると、ツール一覧がAIアプリに表示されます。
基本チェックi
誰でも見られる情報をチェックしており、コードは読んでいません。当てはまらない項目は数に入れていません。 · 2026年11月19日にチェック
- ✓ 合格
作者とリポジトリが一致
レジストリ名は、リポジトリを所有するGitHubアカウント FGuerreir0 で確認済みです
- ✓ 合格
今もメンテナンスされている
コードの最終更新:昨日
- ✕ 不合格
ライセンスがある
リポジトリにライセンスファイルが見つかりません
- – 対象外
エンドポイントが応答する
これはパソコンで動くため、インターネット上のエンドポイントはありません
- – 対象外
OAuthでサインイン
パソコンで動き、代わりにローカルの設定を使います
- … 未チェック
ツールの説明に隠れた指示がない
パソコンで動くサーバーです。ツール一覧を読み取れるのは、インターネット上のエンドポイントがある場合だけです
公開済みの脆弱性(OSV.dev)
まだ確認していません
作者の方へ:再確認の依頼・情報の誤りの報告
作者向け:README にバッジを付ける
作者の方は、このコードを README に貼れます。バッジはこのページにリンクします。
[](https://mcp.popnx.com/en/servers/fguerreir0-ghostimport)話し合い
質問、コツの共有、使えないことの報告ができます。「役に立った」の多い順です。
ユーザーレビュー
まだレビューはありません
開発者ツールのほかのサーバーとの比較i
- このカテゴリのほかの6182件のうち81%よりスターが多い
- このカテゴリのほかの6182件のうち94%より最近レジストリに公開
- 基本チェックの結果が、このカテゴリのほかの6182件のうち45%と同じかそれ以上
レジストリでこのカテゴリにある有効なすべてのサーバーと比較しています。スターは、公開者がリポジトリの所有者である場合だけ数えます。
よくある質問
ghostimportは安全ですか?
当てはまる基本チェック3項目のうち2項目に合格しました。コードは読んでいません。キーやトークンを追加する前に、サーバーがどんなアクセスを求めているかを確認し、必要な権限だけを持つキーを使ってください。
どんなキーやコードが必要ですか?
レジストリには必須のキーは載っていません。ただし、最初に使うときにサインインを求めるサーバーもあります。
パソコンで動きますか、それともクラウドですか?
あなたのパソコンで動きます。必要なときにAIアプリが起動し、データは作者のサーバーを通りません(サーバー自体がオンラインサービスを呼び出す場合を除きます)。
今もメンテナンスされていますか?
GitHubリポジトリの最終更新は昨日、最新バージョン(0.7.4)がレジストリに届いたのは昨日です。
どのアプリで使えますか?
Claude Desktop、Claude Code、Cursor、VS CodeなどのMCP対応アプリで使えます。パソコンにNode.jsも必要です。
代わりに使えるものは?
同じカテゴリには:GitDiagram, Appllama, Cloudflare MCP, Omnara, Repowise
似た働きのほかの候補
同じカテゴリでほかの作者のもの。コマンドは確認済み。公式を先に、次にスター順。
カードの見方:↓ 週あたりのダウンロードi★ GitHubスターi3つの柱:レビュー · チェック · 利用状況i更新=最新バージョンをレジストリに公開した日i
GitDiagram
Architecture diagrams, explanations and Mermaid source for public GitHub repositories.
Appllama
Study screens, flows and paywalls from top-earning iOS apps, then build from what wins.
Omnara
Deploy durable AI agents with Omnara, an open-source managed-agent platform.
Repowise
Codebase intelligence for AI coding agents: graph, git history, docs, decisions, code health.
| これ ghostimport | GitDiagram | Appllama | Cloudflare MCP | Omnara | Repowise | |
|---|---|---|---|---|---|---|
| 動く場所 | パソコンにインストールが必要 | クラウドで動き、インストール不要 | クラウドで動き、インストール不要 | クラウドで動き、インストール不要 | クラウドで動き、インストール不要 | クラウドでもパソコンにインストールでも使える |
| キーが必要 | いいえ | いいえ | いいえ | いいえ | いいえ | いいえ |
| Claude で + から追加 | いいえ | いいえ | いいえ | はい | いいえ | いいえ |
| 基本チェック | 2/3 | 4/4 | 4/4 | 4/4 | 4/4 | 5/5 |
| ライセンス | – | MIT | MIT | Apache-2.0 | Apache-2.0 | AGPL-3.0 |
| 料金 | 登録情報に費用の記載なし | 登録情報に費用の記載なし | 登録情報に費用の記載なし | 登録情報に費用の記載なし | 登録情報に費用の記載なし | 登録情報に費用の記載なし |
作者のREADME
READMEを開く
作者のリポジトリから書かれたとおりにコピーしたものです。PopNx MCPは内容を確認・推奨していません。HTML、画像、スクリプトは取り除いています。リンクはこのサイトの外へ移動します。
ghostimport
Stops your AI coding agent from installing npm packages that don't exist.
How the attack works →
Your agent invents a package name. It doesn't exist on npm *yet*. Someone is watching for exactly that, and the moment they register it, npm install runs their postinstall script on your machine.
This is slopsquatting. Most dependency scanners inspect packages after they are installed; ghostimport checks names before they are — against the live registry, at the moment your agent writes or installs them.
$ ghostimport
Scanned 142 files · 38 packages
✗ react-server-fetch does not exist on npm ↳ src/data/loader.ts ↳ unregistered — anyone could claim this name with a malicious postinstall
✗ axois high risk ↳ src/api/client.ts ↳ 1-2 chars from 'axios' — likely a typo ↳ has postinstall script — runs code on npm install created 2019-08-29 · 1245/week · 1 version
2 problems found.
Install in Claude Code
One command installs the blocking hooks and the MCP server together:
/plugin install ghostimport --marketplace FGuerreir0/ghostimport
On Claude Code older than 2.1.275, add the marketplace first: /plugin marketplace add FGuerreir0/ghostimport, then /plugin install ghostimport@ghostimport.
The plugin runs the CLI bundled in the npm package — no global install, no npx on every edit. If you already wired the hooks into .claude/settings.json by hand, remove them when you install the plugin, or every command is checked twice. Node.js 22+. Zero runtime dependencies: the published package uses only Node built-ins.
For the CLI, CI, or another agent:
npm install -g ghostimport # or: npx ghostimport
What it does in the agent loop
This is the part that matters. A CI check tells you about a bad package *after* it's in your repo; these stop it at the moment it's written.
Hooks — the enforcing one
The plugin installs these. To set them up by hand instead, install ghostimport globally (npm install -g ghostimport, since the hook runs ghostimport directly) and add to .claude/settings.json:
{
"hooks": { "PreToolUse": [ { "matcher": "Bash|PowerShell", "hooks": [{ "type": "command", "command": "ghostimport hook" }] } ], "PostToolUse": [ { "matcher": "Edit|Write|MultiEdit", "hooks": [{ "type": "command", "command": "ghostimport hook" }] } ] } }
- `PreToolUse` on Bash and PowerShell (PowerShell is Claude Code's shell on Windows) — reads any install command, and any command that downloads and runs a package on the spot (
npx,npm exec,npm create,pnpm dlx,yarn dlx,bunx), and denies the tool call if it would fetch a package that doesn't exist, is a typosquat, or runs an install script with no track record behind it. Established packages that ship one (esbuild,puppeteer) go through. This is the one that stops a real attack. - `PostToolUse` on edits — checks imports the agent just wrote, or dependencies it just added to a
package.json, and tells it to fix them.
npx deserves the attention: it runs the package's code immediately, no postinstall needed, and agents copy npx commands out of READMEs and skill files without checking them. An npx of a bin your project already has installed (npx tsc) runs the local copy and isn't checked.
The agent sees why it was stopped:
ghostimport blocked this: the install command below would fetch packages that
are unsafe or do not exist.
• 'axois' exists but is high risk: name is 1-2 chars from 'axios'; single version published.
Do not retry this command as written.
It fails open. Registry unreachable, malformed payload, or a check exceeding its 20-second budget → exits 0 and stays out of the way. A security tool that wedges your agent when you're offline gets uninstalled by Friday.
MCP — the self-service one
Lets the model verify a name *before* it writes the import. Hooks are mandatory; MCP tools are offered — use both.
claude mcp add ghostimport -- npx -y ghostimport mcp # included in the plugin
Cursor, Windsurf, and other MCP clients
Add to .cursor/mcp.json or your client's config:
{
"mcpServers": { "ghostimport": { "command": "npx", "args": ["-y", "ghostimport", "mcp"] } } }
| Tool | What it does |
|---|---|
check_packages | Verify package names exist on npm. deep adds risk heuristics. |
check_install_command | Vet a full npm/pnpm/yarn/bun command — installs, and npx/dlx/create runs. |
scan_project | Audit a whole directory. |
CLI
ghostimport # scan the current directory
ghostimport ./src # scan a folder ghostimport --json # machine-readable ghostimport --watch # re-scan on change
Exits 1 if any imported package doesn't exist, so it works as a CI gate as-is.
All options
| Flag | Effect |
|---|---|
--quiet, -q | Only show problems |
--json | Output results as JSON |
--watch, -w | Re-scan on file changes |
--badge | Print a README badge after scanning |
--fast | Skip the deep supply-chain check on undeclared packages |
--no-undeclared | Hide "imported but not in package.json" warnings |
--no-cache | Bypass the 24h registry cache |
--version, -v · --help, -h |
Optional .ghostimportrc.json in your project root:
{ "ignore": ["@company/*", "internal-lib"], "includeUndeclared": true }
CI: GitHub Actions and pre-commit
- uses: FGuerreir0/ghostimport@v0.6.1
with: path: '.'
Or just run: npx ghostimport --quiet.
For pre-commit, in .pre-commit-config.yaml:
repos:
- repo: https://github.com/FGuerreir0/ghostimport rev: v0.6.1 hooks:
- id: ghostimport
API
import { verifyPackages, scan } from 'ghostimport'
await verifyPackages(['axios', 'axois'], { deep: true }) // [ { pkg: 'axios', status: 'ok', typosquatOf: null }, // { pkg: 'axois', status: 'suspicious', risk: 'high', typosquatOf: 'axios', ... } ]
const { missing, undeclared, risks } = await scan('./src')
status is 'ok' | 'missing' | 'suspicious' | 'unknown'. 'unknown' means the registry was unreachable — never treat it as a failure.
Full API and TypeScript types
| Export | Purpose | |
|---|---|---|
scan(dir, opts?) | Scan a directory. Returns ScanResult. | |
verifyPackages(names, opts?) | Check a list of names. Returns PackageVerdict[]. | |
checkNpm(name) | Does this one package exist? | |
checkPackageRisk(name) | Full supply-chain check for one package. | |
detectTyposquat(name) | Returns the popular package it's 1-2 chars from, or null. | |
extractImports(code) | Package names from a source string. | |
extractInstallTargets(cmd) | Packages a shell command would install. | |
extractCommandTargets(cmd, { cwd?, dialect? }) | Packages a command would install or run (npx, dlx, create), with `action: 'install' | 'exec'. dialect: 'powershell'` reads PowerShell quoting. |
interface ScanResult {
scanned: number packages: number missing: { pkg: string; files: string[]; claimable: boolean | null }[] // don't exist on npm; claimable is false // inside a scope someone already owns undeclared: { pkg: string; files: string[] }[] // exist, but not in package.json risks: RiskEntry[] // supply-chain findings errors: { pkg: string; error: string; files: string[] }[] cacheHits: number }
type RiskEntry = | { pkg: string; files: string[]; type: 'unregistered'; typosquatOf: string | null } | { pkg: string; files: string[]; type: 'suspicious' risk: 'medium' | 'high'; flags: string[]; installScripts: string[] typosquatOf: string | null; maintainers: number created: string; downloads: number | null; versions: number }
Types are shipped with the package: ScanResult, ScanOptions, MissingRef, RiskEntry, PackageVerdict, VerdictStatus, PackageRiskResult, NpmCheckResult, Config.
What gets scanned, and what raises a risk
Detects: import, require(), dynamic import(), export … from, scoped packages, subpath imports (pkg/utils → pkg), and blocks in .vue, .svelte and .astro (markup is ignored, so a package name in template text is never flagged). Also every registry dependency declared in any package.json, whether or not anything imports it — workspace:, file:, link:, git and URL specs are skipped, and npm: aliases are followed to the real name.
Extensions: .js .jsx .ts .tsx .mjs .cjs .vue .svelte .astro
Ignores: Node built-ins, relative imports, path aliases (@/, ~/, $lib/, tsconfig paths), URL/protocol imports, virtual modules, workspace packages, and node_modules/ dist/ build/ .git/.
Risk signals:
| Signal | Weight | Why |
|---|---|---|
| Name 1-2 chars from a popular package, < 10k weekly downloads | critical | Classic typosquat. Established near names (preact, redis, cypress) aren't flagged |
postinstall / preinstall / install script | amplifier | Runs arbitrary code on npm install. Critical alongside any medium signal; normal on its own (esbuild, puppeteer) |
| Created < 30 days ago | medium | No track record |
| < 50 weekly downloads | medium | Near-zero adoption |
| Single version published | medium | Abandoned or one-shot |
| Single maintainer | amplifier | Only counts alongside another signal |
high if any critical signal fires, or 2+ medium ones (a single maintainer counts as a second). Only medium and high are reported.
A name that doesn't exist on npm is reported as squattable unless it sits in a scope someone already owns — only a scope's owner can publish under it, so @babel/made-up is a broken import but not a squatting target. That check costs at most one request per scope, so --fast doesn't disable it.
Contributing
Development setup, the source layout, and how the site in docs/ is built and deployed all live in CONTRIBUTING.md.
Support
ghostimport is free, MIT licensed and has no runtime dependencies — and it stays that way. If it caught something for you, you can buy me a coffee.
License
MIT