-
Notifications
You must be signed in to change notification settings - Fork 9
docs: surface Claude Code plugin #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,90 +1,85 @@ | ||
| # Claude Code Integration | ||
|
|
||
| foxguard can run as a [Claude Code hook](https://docs.anthropic.com/en/docs/claude-code/hooks) to scan agent-written code before each commit. When findings are detected, the commit is blocked and Claude sees the output — giving it a chance to fix the issue before retrying. | ||
|
|
||
| ## Setup | ||
|
|
||
| Add the following to `.claude/settings.json` in your project root: | ||
|
|
||
| ```json | ||
| { | ||
| "hooks": { | ||
| "PreCommit": [ | ||
| { | ||
| "command": "npx foxguard --changed --severity high .", | ||
| "description": "foxguard security scan" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| foxguard ships a Claude Code plugin in [`plugins/claude-code`](../plugins/claude-code). It is the recommended Claude Code integration path because it runs automatically during an agent session instead of waiting until commit time. | ||
|
|
||
| ## What The Plugin Does | ||
|
|
||
| - Runs a `PostToolUse` hook after `Write`, `Edit`, `MultiEdit`, and `NotebookEdit` so files Claude changes are scanned immediately. | ||
| - Emits medium-and-above findings back to Claude so the agent can fix them before the issue lands in the repo. | ||
| - Adds a `SessionStart` secure-coding preamble covering command execution, SQL, SSRF, path traversal, secrets, randomness, crypto, and deserialization. | ||
| - Provides namespaced `/foxguard:*` skills for setup, full scans, diff scans, PQ audits, secrets scans, and TUI triage. | ||
|
|
||
| ## Local Install | ||
|
|
||
| Install foxguard first: | ||
|
|
||
| ```sh | ||
| curl -fsSL https://foxguard.dev/install.sh | sh | ||
| # or: npm i -g foxguard | ||
| # or: cargo install foxguard | ||
| ``` | ||
|
|
||
| Then load the plugin from this repo: | ||
|
|
||
| ```sh | ||
| claude --plugin-dir ./plugins/claude-code | ||
| ``` | ||
|
|
||
| That's it. Claude Code will run foxguard before every commit. | ||
| Inside Claude Code, run: | ||
|
|
||
| ## What happens when findings are detected | ||
| ```text | ||
| /foxguard:setup | ||
| ``` | ||
|
|
||
| 1. Claude writes code and attempts to commit. | ||
| 2. foxguard scans the changed files. | ||
| 3. If any findings at or above the configured severity are found, foxguard exits non-zero. | ||
| 4. Claude Code blocks the commit and shows foxguard's output to the agent. | ||
| 5. The agent sees the finding (rule ID, file, line, description) and can fix it. | ||
| 6. On the next commit attempt, foxguard runs again. | ||
| That verifies the `foxguard` binary is available and explains the active hook severity threshold. | ||
|
|
||
| ## Customizing severity threshold | ||
| ## Hook Behavior | ||
|
|
||
| The `--severity` flag controls the minimum severity that causes a non-zero exit: | ||
| The auto-scan hook reads the Claude Code hook JSON from stdin, extracts `tool_input.file_path` or `tool_input.path`, and runs: | ||
|
|
||
| ```json | ||
| { "command": "npx foxguard --changed --severity critical ." } | ||
| ```sh | ||
| foxguard --format json --severity medium <edited-file> | ||
| ``` | ||
|
|
||
| Valid values: `low`, `medium`, `high`, `critical`. | ||
| If findings are present, the hook exits `2` and prints a compact finding summary to stderr. Missing binaries, unreadable files, invalid hook input, and clean scans exit `0` so plugin machinery does not block Claude by itself. | ||
|
|
||
| - `critical` — only block on critical findings (SQL injection, command injection, etc.) | ||
| - `high` — block on high and critical (recommended default) | ||
| - `medium` — block on medium and above | ||
| - `low` — block on everything | ||
|
|
||
| ## Adding secrets scanning | ||
|
|
||
| To also catch leaked credentials, add a second hook entry: | ||
|
|
||
| ```json | ||
| { | ||
| "hooks": { | ||
| "PreCommit": [ | ||
| { | ||
| "command": "npx foxguard --changed --severity high .", | ||
| "description": "foxguard security scan" | ||
| }, | ||
| { | ||
| "command": "npx foxguard secrets --changed .", | ||
| "description": "foxguard secrets scan" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| Tune the threshold with: | ||
|
|
||
| ```sh | ||
| export FOXGUARD_HOOK_SEVERITY=high | ||
| ``` | ||
|
|
||
| ## Combining with the VS Code extension | ||
| Valid values: `low`, `medium`, `high`, `critical`. | ||
|
|
||
| ## Commands And Skills | ||
|
|
||
| For a full agentic security loop: | ||
| Claude Code plugin skills are namespaced by the plugin name: | ||
|
|
||
| 1. **VS Code extension** — scans on save, shows findings as inline underlines while the agent is editing. | ||
| 2. **Claude Code hook** — catches anything missed before commit. | ||
| - `/foxguard:setup` verifies installation and configuration. | ||
| - `/foxguard:scan [path]` runs a full scan and summarizes findings. | ||
| - `/foxguard:diff-scan [base]` reports findings introduced by the current branch. | ||
| - `/foxguard:pq-audit [path]` runs post-quantum crypto and CNSA 2.0 checks. | ||
| - `/foxguard:secrets [path]` scans for leaked credentials and private keys. | ||
| - `/foxguard:triage [args]` opens or explains the interactive TUI triage flow. | ||
|
|
||
| Install the extension from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=peaktwilight.foxguard), then add the hook config above. The two complement each other: the extension gives real-time feedback, the hook is the final gate. | ||
| The plugin also includes a model-invoked `secure-coding` skill so Claude can pull in foxguard-aligned remediation guidance while writing security-sensitive code. | ||
|
|
||
| ## Pinning a version | ||
| ## Pre-commit Still Helps | ||
|
|
||
| To avoid network fetches on every commit, pin the version: | ||
| The plugin is live feedback. A pre-commit hook is still useful as a final gate for human edits, other agents, or terminal changes outside Claude Code: | ||
|
|
||
| ```json | ||
| { "command": "npx foxguard@0.6.2 --changed --severity high ." } | ||
| ```sh | ||
| foxguard init | ||
| ``` | ||
|
|
||
| Or install foxguard globally (`curl -fsSL https://foxguard.dev/install.sh | sh`) and reference the binary directly: | ||
| Or configure your own hook to run: | ||
|
|
||
| ```json | ||
| { "command": "foxguard --changed --severity high ." } | ||
| ```sh | ||
| npx foxguard --changed --severity high . | ||
| ``` | ||
|
|
||
| ## Publishing Status | ||
|
|
||
| The plugin can be loaded locally today with `--plugin-dir`. Publishing to an official Claude plugin marketplace is an external release step: it requires final marketplace metadata, a release/versioning decision, local plugin smoke testing in Claude Code, and submission through Anthropic's plugin form. | ||
|
|
||
| Track the publishing checklist in the GitHub issue linked from the README/PR queue rather than treating it as part of the scanner binary release. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the effective hook command with env override.
Line 40–Line 42 currently implies a fixed
mediumthreshold, but the hook actually usesFOXGUARD_HOOK_SEVERITY(defaulting tomedium). Please reflect that so operators don’t misread runtime behavior.Suggested doc tweak
📝 Committable suggestion
🤖 Prompt for AI Agents