# Repository Briefing: PenglinChina/footgun-guard
> Source: https://repoforai.com/repo/PenglinChina/footgun-guard (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/PenglinChina/footgun-guard
- **Category**: Coding, Skills & MCP (AI 编程 / Skills / MCP)
- **Primary Language**: JavaScript
- **License**: MIT
- **Engineering Health**: A (76/100 · Maintenance 35/35 · Adoption 1/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v0.1.0 (2026-12-01) — https://github.com/PenglinChina/footgun-guard/releases
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: CLI
- **Momentum**: 77 ★ total (+1 24h / +76 7d) · 0 forks
- **Topics**: `code-review`, `footguns`
- **When to Use**: Best for: Polyglot teams using coding agents that want a shared review baseline, immediate post-edit feedback, and a local CI check whose failure policy they control. Skip if: You need an MCP endpoint, deep interprocedural analysis, or a tool that can certify code safety from a clean scan.

## Overview
```text
### Architecture & Core Mechanics
FootgunGuard separates four responsibilities: agent instructions, local detection, post-edit feedback, and CI enforcement. `skill/SKILL.md` and `AGENTS.md` guide the agent; `src/cli.js` routes commands to a dependency-free JavaScript engine. The engine identifies the language, masks comments and strings, and applies rules to source text and nearby context. Rules in `src/rules/` map to stable IDs in the Chinese and English GuardLists; manual entries have no detector.

`src/commands/hook.js` returns findings to the agent as non-blocking `additionalContext`. CI consumes the scanner's exit status independently of the agent. The integration surface is a local CLI, skill bundles, and host hooks; no MCP transport or server entrypoint is shown.

### Key Capabilities & Differentiators
Coverage spans C, C++, C#, Java, JS/TS, Python, Go, and Rust. The current GuardLists contain 80 entries, including deliverable-quality checks; that is not a count of automated detectors. `doctor` checks mapping completeness and hook wiring, `list --manual` identifies checks that require review, and `explain` looks up a rule. The fixture tests check that each language's positive sample hits all of its detectable checklist items and that its clean sample produces no findings.

`detect` supports JSON, SARIF, and GitHub-oriented output. It returns 0 for a clean scan, 2 for findings, and 1 if a target cannot be scanned. The SARIF upload example deliberately accepts exit 2 so the report can be uploaded. To block merges on findings, configure a required CI check that treats 2 as a failure.

### Trade-offs & Limitations
Compared with relying on ESLint and similar language-specific linters alone, FootgunGuard adds a shared review baseline and an edit-to-agent feedback loop across languages. It does not replace richer language tooling: the scanner does not follow cross-function data flow, expand macros, or infer types across files. It treats `.h` files as C and skips code embedded in masked strings or comments.

Deterministic output makes recurring findings reproducible, not necessarily correct. Context heuristics can still raise false positives, while questions such as whether a test independently validates a requirement need human judgment. Start by reviewing findings on representative code before making the check mandatory. An exit code of 0 confirms only that the enabled detectors found nothing.

### Hardware & Deployment Guide
Use Node.js 18.19.0 or newer. The package exposes the `footgun` binary, but the checkout-based path avoids relying on npm publication: `node src/cli.js detect .` runs directly from the repository. The scanner needs neither a model API nor a GPU and can run offline on developer machines or CI runners. Start with the intended scan paths when evaluating runtime cost; no resource measurements are available.

For skill installation, `node scripts/install.mjs --host claude` targets the current project; `--scope global` selects a user-level install for supported paths. Claude Code's settings snippet and the DSH plugin provide separate hook wiring. Twenty generated host directories are checked in with bundled scanner copies, and `node scripts/build.mjs --check` verifies that those artifacts match their sources. v0.1.0 is the first integration release.
```

## Key Capabilities
```text
- Rule traceability: Chinese and English GuardLists share stable IDs and ordering, enforced by tests.
- Detection engine: Dependency-free Node.js scanning masks comments and strings before applying pattern and context checks.
- Manual review: `footgun list --manual` exposes checklist items that have no detector.
- Agent feedback: Post-edit hooks return findings as non-blocking `additionalContext`.
- CI policy: JSON, SARIF, and GitHub-oriented output are available; exit 2 means findings and exit 1 means a scan failure.
- Host distribution: Twenty generated skill directories bundle the scanner, and `build --check` detects drift from source.
```

## Quick Start / Clone
```bash
node src/cli.js detect .              # 扫当前目录
node src/cli.js detect src/ --json    # 机器可读
node src/cli.js context               # 打印给 agent 的常驻指令块
node src/cli.js list --manual         # 列出没有检测器的条目
node src/cli.js explain c-unsafe-string-fn   # 查一条规则
node src/cli.js doctor                # 自检：规则完整性、hook 接线
```
