ドキュメントはじめに

クイックスタート

数分でポリシーを作成し、プロジェクトをスキャンし、プロンプトをマスクし、.env ファイルを暗号化し、Git および AI ツールフックをインストールします。

このページの内容

このページでは、最も一般的な shk のワークフローを順に説明します。CLI がすでにインストールされていることを前提としています。まだの場合はインストールを参照してください。

1. プロジェクトポリシーを作成する

プロジェクトのポリシーファイルを作成します。

shk init
bash

これにより、カレントディレクトリに shk.toml が書き込まれます。読み取り専用のコマンドはこのファイルがなくても動作しますが、ファイルやツール設定を書き込むコマンドにはプロジェクトポリシーが必要です。package.json が存在する場合、shk initignore-scripts=true やリリース経過日数のゲートなど、パッケージマネージャーのサプライチェーン強化も適用できます。この手順をスキップするには --no-npm-hardening を渡してください。

medium 重要度の検出結果で失敗する、より厳格な初期設定を使うには次のようにします。

shk init --strict
bash

2. プロジェクトをスキャンする

現在のプロジェクトをスキャンします。

shk scan .
bash

機械可読なレポートを出力します。

shk scan . --json
bash

ステージ済みファイルのみ、またはベースブランチに対して変更されたファイルのみをスキャンします。

shk scan --staged
shk scan . --changed-since origin/main
bash

Git 履歴のスキャン、SARIF 出力、終了コードのセマンティクスについては shk scan を参照してください。

3. AI と共有する前にコンテンツをマスクする

標準入力からの機密コンテンツをマスクします。

shk mask < prompt.txt
bash

Office ドキュメントをマスクして新しいファイルに書き出します。

shk mask report.docx --output report.redacted.docx
bash

クリップボードを直接スキャンまたはマスクします。

shk clipboard scan
shk clipboard mask --write
bash

4. .env ファイルを暗号化する

.env ファイルをその場で暗号化し、復号した値を実行時にのみ注入してコマンドを実行します。

shk env encrypt .env --in-place
shk env run -- npm test
bash

秘密鍵はデフォルトで OS キーリングに保存されます。チームは 1Password にオプトインすることもできます。Env シークレットストアを参照してください。

5. フックをインストールする

ステージ済みファイルをスキャンする Git pre-commit フックをインストールします。

shk hooks install
bash

ブロックせずに観察するため、監査モードで AI ツールフックをインストールします。

shk hooks install-ai --audit
bash

ブロックしつつメタデータのみのブロックログを残す AI ツールフックをインストールし、そのログを確認します。

shk hooks install-ai --log-blocked
shk audit
bash

フックは Claude Code、Cursor、Codex、GitHub Copilot、Antigravity、Windsurf でサポートされています。ツール固有のオプションについては shk hooks install-ai を参照してください。

6. CI を追加する

すべてのプルリクエストをスキャンする GitHub Actions ワークフローを生成します。

shk ci init github
# GitHub コードスキャンのアラートと PR アノテーションを追加する場合:
shk ci init github --upload-sarif
bash

または、Linux または macOS ランナーで checkout の後にリポジトリのコンポジットアクションを使います。

permissions:
  contents: read
  security-events: write

steps:
  - uses: actions/checkout@v7
    with:
      persist-credentials: false
  - uses: Kazuki-tam/security-harness-kit@v1
    with:
      path: .
      fail-on: high
      upload-sarif: true
yaml

モード、固定(ピン留め)、トラブルシューティングについては GitHub Actions を参照してください。

7. エージェントスキルをインストールしてカバレッジを確認する

Claude Code、Codex、Cursor、Copilot、Antigravity、Windsurf 向けに shk エージェントスキルをインストールします。

shk skills install
bash

ignore のカバレッジを確認します。

shk doctor ignore
bash

主なコマンド一覧

shk init
shk init --strict
shk init --yes --no-npm-hardening

shk scan .
shk scan . --json
shk scan . --json --with-value-hash
shk scan . --sarif
shk scan --staged
shk scan . --changed-since origin/main
shk scan --git-history
shk scan --git-history --preview
shk scan --git-history --ref HEAD~50..HEAD
shk allowlist suggest --from report-with-hashes.json --value-hash

shk mask < prompt.txt
shk mask --json < prompt.txt
shk mask report.docx --output report.redacted.docx
shk mask orders.csv --pseudonymize --columns "Email:email,Phone:phone" --output orders.pseudo.csv
shk pseudonymize key show

shk clipboard scan
shk clipboard mask
shk clipboard mask --write

shk doctor
shk doctor --strict
shk doctor ignore --fix
shk doctor env --dotenvx
shk doctor workflows --fix

shk audit
shk audit --reason action-guard
shk audit --since 7d --tool cursor
shk audit --json

shk mcp audit
shk mcp audit --json
shk mcp audit --sarif
shk mcp audit --global

shk env dotenvx import-keys .env.keys
shk env encrypt .env --in-place
shk env run -- npm test
shk env key import
shk env key list
shk env key delete --env staging
shk env key export --instructions
shk env key migrate --to 1password
shk env decrypt .env --output .env.local
shk secrets push --profile prod --dry-run

shk hooks install
shk hooks install-ai --dry-run
shk hooks install-ai --audit
shk hooks install-ai --log-blocked
shk hooks install-ai --tool copilot
shk hooks install-ai --tool antigravity
shk hooks install-ai --tool windsurf

shk ci init github
shk ci init github --upload-sarif
shk ci init github --dry-run
shk ci init github --mode audit
shk ci init github --shk-version v0.7.0

shk skills install
shk skills install --tool claude-code --global
shk skills install --tool windsurf
shk skills status
bash