• Projects
  • Service
  • About
  • branding.bz
  • Podcast
  • Tips
  • FAQ
  • Recruit
  • Download
  • Contact
  • branding.bz(ブランド構築SaaS)
  • DESIGN NOW(デザインメディア)
  • X
  • LinkedIn
  • Spotify
  • Facebook

213-0011 神奈川県川崎市高津区久本3-6-7-303

© 2026 ID INC. All rights reserved

claude-skills/スキル
SKILLOfficialsecurity

install-mfw

プラグイン
semgrep
ソース
GitHub で見る ↗
説明

Semgrep Malware Firewall(セキュリティ脅威検出ツール)の CLI をインストーラー経由でセットアップし、ユーザーを初期設定の過程でサポートします。信頼されたストア(認証済みファイルの保管庫)、PATH設定、シェル統合(コマンドラインツールとの連携)、バックグラウンドデーモン(常時稼働するプログラム)など、重要な決定ポイントで適切に質問します。 ユーザーのシェル設定ファイルが外部ツール(Nix、Home Manager、Chezmoi、GNU Stow、dotfiles リポジトリ)によって管理されていることを検出し、既存設定を上書きするのではなく、mfw の設定行を適切な管理元に追加します。 **次のような場合に使用:** ユーザーがこのマシン上で mfw のインストール、セットアップ、または初期導入(オンボーディング)を希望している。

原文を表示

Install the mfw (Semgrep Malware Firewall) CLI via the curl|sh installer and walk the user through setup — trust store, PATH shims, shell integration, and the background daemon — asking questions at real decision points. Detects when the user's shell rc files are *managed* (symlinked into nix / home-manager / chezmoi / GNU stow / a dotfiles git repo) and, instead of clobbering them, adds mfw's source line to the right source-of-truth. Use when the user wants to install, set up, or onboard mfw on this machine.

ユースケース
  • Semgrep Malware Firewallをインストールするとき
  • CLIツールの初期設定を行うとき
  • シェル統合やPATH設定を構成するとき
  • 外部ツールで管理されたシェル設定を検出するとき
本文(日本語訳)

mfw のインストール

mfw(Semgrepのマルウェアファイアウォール)クライアントをインストールおよび設定します。mfw はローカル環境で動作する中間接続プロキシ(パッケージ管理ツールを通じたダウンロード — pip / npm / pnpm / uv / cargo / maven / gem / nuget / composer / go)であり、Semgrep のバックエンド機能によって、パッケージをディスクに保存する前に検査します。

$ARGUMENTS にはバックエンド/配布 URL のオーバーライド(例:https://example.semgrep.dev)または --store system が含まれることがあります。デフォルトのバックエンドは https://semgrep.dev です(mfw は本番環境から配布されます)。空の場合はデフォルトを使用します。

あなたの役割:インストール全体を進める際に、重要な選択が必要な場合にのみユーザーに確認する(AskUserQuestion を使用)こと。そして重要な点として、管理対象(シンボリックリンク)のシェル設定ファイルを直接編集しないことです。以下の手順を順番に実行してください。

修正処理が行うこと(ユーザーに事前に説明)

インストーラーはバイナリを ~/.local/bin/mfw にダウンロードしてチェックサムで検証した後、mfw fixup を実行します。その際に以下を行います:

① ローカル CA(認証局)を生成し、OS の信頼ストアに追加します(加えて、macOS で Homebrew が存在する場合は Homebrew の openssl 信頼ディレクトリにも追加)

② パッケージマネージャーの置き換えプログラム(シムシンボリックリンク)を ~/.semgrep/mfw/shims に配置します

③ ~/.semgrep/mfw/rc-setup.sh(PATH 設定とプロキシ/CA 環境変数)を作成し、シェルに読み込ませます

④ バックグラウンドデーモン(launchd/systemd/openrc — サービスマネージャーなしのコンテナ内ではスキップ)をインストールします。これはプロキシを実行し、mfw supervise 経由で mfw をスケジュール通りに自動更新します(デフォルトで有効)

ユーザーは mfw uninstall(mfw バイナリも削除します)でいつでも取り消せます。これはシステムを実際に変更するインストールです。実行する前にユーザーが同意していることを確認してください(このスキルを呼び出したので、簡潔な説明と進行で問題ありません。以下の選択が必要な場合のみ確認してください)。

ステップ 1 — 前提条件の確認

  1. uname -s と uname -m を実行します。対応環境:Linux x86_64/aarch64、macOS arm64(Apple シリコン)。Windows または Intel macOS の場合はここで中止し、公開ビルドがないことをユーザーに明確に伝えてください。

  2. command -v curl(または wget)を確認します。どちらもない場合は中止してその旨を伝えます。

  3. command -v mfw で確認します。既にインストールされている場合は、このスキルは再実行/アップグレードであり、冪等的(べき等的)です。進行してください(fixup は自己修復します)。

ステップ 2 — インストール前にシェル設定を検査

インスペクターを実行して解析します(結果をユーザーにダンプしないこと):

sh ${CLAUDE_SKILL_DIR}/scripts/inspect-shell-config.sh

ユーザーの login_shell について、その rc ファイルを確認します:zsh → ~/.zshrc、bash → ~/.bashrc 加えて ~/.bash_profile または ~/.profile。管理対象か通常ファイルかを判断します:

  • 管理対象 = symlink=yes(どの class でも:nix、chezmoi、git-dotfiles、unknown)または class=nix-generated(「Home Manager/Nix で生成」というヘッダーを持つ実ファイル)。これらはツールによって管理されています。デプロイされたファイルを編集することは間違いです。読み取り専用(nix)または次のリビルド/適用時に元に戻されます。

  • 通常ファイル = 普通の書き込み可能なファイル(または存在しない)。直接編集しても安全です。

このゲート機構が存在する理由: mfw fixup は rc ファイルに対してアトミックな rename() で 1 行のフックを書き込みます。これはシンボリックリンクを通常ファイルで置き換えるため — nix/home-manager 管理の rc を破壊します。そのため管理対象の rc ファイルは直接編集してはいけません。mfw の 1 行フックはユーザーの情報源に入ります。

この結果を記録してください。ステップ 3 とステップ 4 を決定します。

ステップ 3 — インストール

シェル設定が通常ファイルの場合(かつ別途管理対象パスが不要な場合)、標準インストーラーを使用します — これはダウンロード、検証、および mfw fixup の実行を行い、実の rc ファイルを正しく編集します:

curl -fsSL https://semgrep.dev/dist/mfw/install.sh | sh

($ARGUMENTS/環境でオーバーライドが与えられた場合はホストを置き換えてください:…/<host>/dist/mfw/install.sh)

install.sh は TTY(ターミナルの入出力接続)を再接続します(mfw fixup </dev/tty)。そのため、ターミナルでこれを実行する人間は対話的なプロンプトを受け取ります。制御用ターミナルがない場合は mfw fixup --yes にフォールバックします。Bash ツール経由でこの行を実行する場合、TTY がないため --yes パスが実行されます:fixup は自動承認し、mfw の推定パスにある実の rc ファイルを編集します — これは通常設定の場合まさに必要な動作です。

シェル設定が管理対象の場合、バンドルされた fixup を実行しないでください(シンボリックリンクを破壊します)。バイナリのみをインストールし、シェル編集を無効にして fixup を実行します:

sh ${CLAUDE_SKILL_DIR}/scripts/install-binary.sh
~/.local/bin/mfw fixup --skip-login

ここで mfw fixup は非対話的に実行されます(TTY なし)。そのため ~/.semgrep/mfw/rc-setup.sh を書き込み、証明書/シム/デーモンをインストールし、シェル行を出力します(rc を編集しません)— これは管理対象設定の場合まさに必要な動作です。ステップ 6 とステップ 4 でログインとシェルフックを処理します。(オーバーライド URL が与えられた場合は --backend-url <url> で渡してください)

このセッションで ~/.local/bin が PATH になくても対応できるよう、後続の呼び出しで ~/.local/bin/mfw を使用してください。

ステップ 4 — 管理対象設定向けシェル統合

通常設定の場合はこの全ステップをスキップしてください(インストーラーが既に処理しています)。管理対象設定の場合、ユーザーのシェルが必要とするのはこの正確なフックのみです。これは mfw が自ら管理する環境ファイルを読み込みます:

[ -r "$HOME/.semgrep/mfw/rc-setup.sh" ] && . "$HOME/.semgrep/mfw/rc-setup.sh"

この 1 行は mfw doctor が探すもの(トリミングされた行マッチ — コメントマーカーなし)と全く同じです。これがどこに属するのか見つけ、AskUserQuestion でユーザーに確認してください。インスペクターが見つけた candidate= パスに加えて「その他」オプションを提示します:

  • nix / home-manager(class=nix または nix-generated):シェル初期化属性にフックを追加します。例えば programs.zsh.initContent(新版)または initExtra/programs.bash.initExtra/bashrcExtra;NixOS では programs.zsh.interactiveShellInit。それでもファイル全体を管理している場合(home.file.".zshrc".text = ''…'')、その文字列内にフックを付け加えます。nix 文字列内では $HOME はリテラルです(補間は ${…})。そのため行は安全に逐語的に使用できます。''…'' ブロック内にいて linter が ${ について文句をいう場合、ここには何もないため escaping は不要です。編集後、ユーザーにリビルドを促します:home-manager switch / darwin-rebuild switch / sudo nixos-rebuild switch。

  • chezmoi(class=chezmoi):デプロイされたファイルではなくソースを編集します — chezmoi edit ~/.zshrc がこれを開きます。あるいは ~/.local/share/chezmoi 内の対応する dot_zshrc を編集します。フックを付け加えてから chezmoi apply を実行します。

  • GNU stow / dotfiles git リポジトリ(class=git-dotfiles):resolved= パスは実在するリポジトリ内のファイルです(シンボリックリンクはそれを直接指しています)。Edit を使用して、そこにフックを付け加えます。その後、ユーザーにコミットするよう促します。リンク張替えは不要です。

  • unknown:link_target/resolved パスを表示し、情報源がどこにあるのかユーザーに問い、そこを編集します。

ターゲットファイルを最初に読み込み、最小限の Edit を実行します。これは正しい場所(正しい nix 属性内または rc ソースの末尾)にフックを挿入します。曖昧な点がある場合は、書き込む前に目的地をユーザーに確認してください。

ステップ 5 — 信頼ストアの最終処理

  • Linux: ユーザーごとのパスは通常、信頼を確立できません(ユーザーごとのストアがない)。AskUserQuestion で CA をシステムストアにインストールするかどうかを確認します(sudo が必要):sudo mfw install-certs --store system。ユーザーが断った場合、ゲートされたダウンロードが信頼されるまで TLS 検証に失敗することに注意します。

  • macOS: ログインキーチェーンに CA を追加すると、GUI の「許可」またはパスワードプロンプトが表示される可能性があり、あなたはクリックできません。証明書ステップが完了しなかった場合、ユーザーに自分で mfw install-certs を実行してプロンプトを承認するよう伝えます。(Homebrew の openssl 信頼は、brew が存在する場合、fixup によって自動的に処理されます)

ステップ 6 — ログイン(オプション、ブラウザ)

mfw はログインなしで実行されます — 認証されていないリクエストは設定されたフェイルオープン/クローズ方針に従うだけです — しかし認証されるまで実際にはスキャンできません。mfw doctor のログイン行を確認します(ステップ 7)。認証されていない場合、今すぐログインするかどうかを確認します。mfw login はブラウザ OAuth フロー(あなたは完了できません)を開くため、このセッションでユーザー自身に実行させてください:! mfw login を入力するか SEMGREP_APP_TOKEN を設定するよう提案します。fixup の残りをこれでブロックしないでください。

ステップ 7 — 検証と引き継ぎ

  1. mfw doctor を実行します(必要に応じて ~/.local/bin/mfw doctor を使用)。まだ ✗ である項目についてユーザーと一緒に確認します。管理対象設定の場合、シェル行はユーザーがシェルを再起動するまで(および nix の場合はリビルドするまで)✗ のままです。Doctor は「バージョン/アップデート確認」(up to date / update available … run mfw upgrade)、自動更新が無効かどうか、スーパーバイザーが実行しているかどうかなど、いくつかの情報提供目的の行も出力します — これらを ✗ として扱わないでください。

  2. ユーザーにシェルを再起動するよう伝えます — exec "$SHELL" -l または新しいターミナル — その後 mfw doctor を再実行してください。「Semgrep mfw is protecting this machine.」(「Semgrep mfw

原文(English)を表示

Install mfw

Install and set up the mfw client — Semgrep's Malware Firewall, a local MITM proxy that gates package-manager downloads (pip / npm / pnpm / uv / cargo / maven / gem / nuget / composer / go) on Semgrep's backend before bytes hit disk.

$ARGUMENTS may carry a backend/dist URL override (e.g. https://example.semgrep.dev) or --store system. Default backend is https://semgrep.dev (mfw is distributed off prod). If empty, use the defaults.

Your job: drive the install end to end, ask the user only at genuine decision points (via AskUserQuestion), and — the part that needs care — never edit a managed (symlinked) shell rc file in place. Work through the steps in order.

What fixup will do (state this to the user up front)

The installer downloads + checksum-verifies the binary to ~/.local/bin/mfw, then mfw fixup: ① generates a local CA and adds it to the OS trust store (plus, on macOS with Homebrew present, into Homebrew's openssl trust dir), ② drops package-manager shim symlinks in ~/.semgrep/mfw/shims, ③ writes ~/.semgrep/mfw/rc-setup.sh (PATH + proxy/CA env) and makes your shell source it, ④ installs a background daemon (launchd/systemd/openrc — skipped inside containers with no service manager) that runs the proxy and, via mfw supervise, auto-updates mfw on a schedule (on by default). Undo anytime with mfw uninstall (which also deletes the mfw binary). It is a real, system-modifying install — make sure the user is on board before you run it (they invoked this skill, so a brief summary + proceeding is fine; only stop for the choices below).

Step 1 — Preconditions

  1. uname -s and uname -m. Supported: Linux x86_64/aarch64, macOS arm64 (Apple silicon). If it's Windows, or Intel macOS, stop: there is no published build — tell the user plainly.
  2. command -v curl (or wget). If neither, stop and say so.
  3. command -v mfw — if already installed, this is an idempotent re-run / upgrade; carry on (fixup self-heals).

Step 2 — Inspect the shell config BEFORE installing

Run the inspector and parse it (do not dump it on the user):

sh ${CLAUDE_SKILL_DIR}/scripts/inspect-shell-config.sh

For the user's login_shell, look at its rc file(s): zsh → ~/.zshrc; bash → ~/.bashrc plus ~/.bash_profile or ~/.profile. Decide managed vs plain:

  • Managed = symlink=yes (any class: nix, chezmoi, git-dotfiles, unknown) or class=nix-generated (a real file with a "Generated by Home Manager/Nix" header). These are owned by a tool; editing the deployed file is wrong — it's read-only (nix) or gets reverted on the next rebuild/apply.
  • Plain = a regular, writable file (or absent). Safe to edit directly.

Why this gate exists: mfw fixup writes its one-line hook with an atomic rename() over the rc file, which replaces a symlink with a regular file — clobbering a nix/home-manager-managed rc. So managed rc files must never be edited in place; mfw's one-line hook goes into the user's source-of-truth instead.

Remember the result; it decides Step 3 and Step 4.

Step 3 — Install

If the shell config is PLAIN (and you don't otherwise need the managed path), use the standard installer — it downloads, verifies, and runs mfw fixup, correctly editing the real rc file:

curl -fsSL https://semgrep.dev/dist/mfw/install.sh | sh

(Swap the host if $ARGUMENTS/env gave an override: …/<host>/dist/mfw/install.sh.)

install.sh reconnects a TTY (mfw fixup </dev/tty) so a human running it in a terminal gets the interactive prompts, and falls back to mfw fixup --yes when there's no controlling terminal. When you run this line through the Bash tool there's no TTY, so it takes the --yes path: fixup auto-accepts and edits the real rc file at mfw's best-guess paths — exactly what we want for a plain config.

If the shell config is MANAGED, do not run the bundled fixup (it would clobber the symlink). Install the binary only, then drive fixup with shell edits turned off:

sh ${CLAUDE_SKILL_DIR}/scripts/install-binary.sh
~/.local/bin/mfw fixup --skip-login

mfw fixup here runs non-interactively (no TTY), so it writes ~/.semgrep/mfw/rc-setup.sh, installs certs/shims/daemon, and prints the shell lines instead of editing your rc — exactly what we want. We handle login in Step 6 and the shell hook in Step 4. (Pass an override URL with --backend-url <url> if one was given.)

Use ~/.local/bin/mfw for subsequent calls in case ~/.local/bin isn't on PATH in this session yet.

Step 4 — Shell integration for managed configs

Skip this whole step for plain configs (the installer already did it). For managed configs, the only thing the user's shell needs is this exact hook, which sources mfw's self-managed env file:

[ -r "$HOME/.semgrep/mfw/rc-setup.sh" ] && . "$HOME/.semgrep/mfw/rc-setup.sh"

This single line is exactly what mfw doctor looks for (a trimmed line match — no comment markers). Now find where it belongs and ask the user with AskUserQuestion, offering the candidate= paths the inspector found plus an "Other" path:

  • nix / home-manager (class=nix or nix-generated): add the hook to the shell-init attribute, e.g. programs.zsh.initContent (newer) or initExtra/programs.bash.initExtra/bashrcExtra; on NixOS programs.zsh.interactiveShellInit. If they instead manage the file wholesale (home.file.".zshrc".text = ''…''), append the hook inside that string. A bare $HOME is literal in nix strings (interpolation is ${…}), so the line is safe verbatim; if you're inside a ''…'' block and the linter complains about ${, there is none here, so no escaping is needed. After editing, tell the user to rebuild: home-manager switch / darwin-rebuild switch / sudo nixos-rebuild switch.
  • chezmoi (class=chezmoi): edit the source, not the deployed file — chezmoi edit ~/.zshrc opens it, or edit the matching dot_zshrc in ~/.local/share/chezmoi; append the hook, then chezmoi apply.
  • GNU stow / dotfiles git repo (class=git-dotfiles): the resolved= path IS the real file in the repo (the symlink points straight at it). Append the hook there with Edit, then remind the user to commit. No relink needed.
  • unknown: show the link_target/resolved path, ask the user where the source-of-truth is, and edit that.

Read the target file first, then make a minimal Edit that inserts the hook in the right place (inside the right nix attribute / at the end of the rc source). Confirm the destination with the user before writing if there's any ambiguity.

Step 5 — Finish the trust store

  • Linux: the per-user pass usually can't establish trust (no per-user store). Ask with AskUserQuestion whether to install the CA into the system store (needs sudo): sudo mfw install-certs --store system. If they decline, note that gated downloads will fail TLS verification until it's trusted.
  • macOS: adding the CA to the login keychain can pop a GUI "allow" / password prompt that you can't click. If the certs step didn't complete, tell the user to run mfw install-certs themselves and approve the prompt. (Homebrew's openssl trust is handled by fixup automatically when brew is present.)

Step 6 — Login (optional, browser)

mfw runs without login — unauthenticated requests just follow the configured fail-open/closed policy — but it can't actually scan until authenticated. Check the login line in mfw doctor (Step 7). If not authenticated, ask whether to log in now. mfw login opens a browser OAuth flow you can't complete for them, so have them run it in this session: suggest they type ! mfw login (or set SEMGREP_APP_TOKEN). Don't block the rest of fixup on it.

Step 7 — Verify and hand off

  1. Run mfw doctor (use ~/.local/bin/mfw doctor if needed). Walk the user through anything still ✗. For managed configs the shell line stays ✗ until they restart their shell (and, for nix, rebuild first). Doctor also prints a few informational lines that aren't failures: a version/update check (up to date / update available … run mfw upgrade), whether auto-update is disabled, and whether the supervisor is running — don't treat those as ✗.
  2. Tell them to restart their shell — exec "$SHELL" -l or a new terminal — then re-run mfw doctor; it should print the "Semgrep mfw is protecting this machine." banner (a green ○○○ logo + a little watching face whose eyes are randomized each run). If they're not logged in the headline is instead "mfw can't scan anything until you authenticate — run mfw login" (see Step 6); other steps can still be ✓. If they're signed in but their Semgrep deployment doesn't have the Semgrep malware firewall enabled, the login line is ✗ and the headline is "the Semgrep malware firewall isn't enabled for your Semgrep deployment. Enable it in Semgrep or ask your org admin." — that's a backend entitlement issue, not a fixup step, so re-running mfw fixup won't fix it.
  3. Summarize what you did, where things live (~/.semgrep/mfw/, shims on PATH, the managed daemon), and that mfw uninstall reverses everything (and deletes the mfw binary). mfw keeps itself updated via the supervisor (auto-update on by default); mfw upgrade forces it now and mfw restart bounces the daemon.

Notes

  • Prefer the pre-approved commands above so the user isn't re-prompted. The curl … | install.sh | sh line modifies the system — it's expected to need one confirmation; let it.
  • mfw's own rc-edit prompt (only shown with a TTY — not when you drive it via the Bash tool): for the shell step it batches into one question, Edit them all? [Y]es / [n]o, show me the line to add myself / [s]kip, and per-file it's Apply to <path>? [Y]es / [n]o, I'll do it myself / [s]kip. The default is yes (Enter applies the edit); n immediately prints the source line to paste yourself, s skips. Because your Bash-tool calls have no TTY, mfw fixup runs non-interactively: it still writes rc-setup.sh, installs certs/shims/daemon, and prints (never edits) the rc lines — which is exactly why the managed-config path in Step 3 works.
  • Never put secrets/tokens in anything you write. The hook only sources a file.
  • If a step fails, report the actual error and what it means for protection (e.g. "certs not trusted → gated downloads fail TLS"); don't paper over it.

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。