SuperAPIAI Directory

fakegreen

github.com · AI coding

fakegreen is an open-source command-line tool for detecting AI coding agents faking passing test results. It scans git diffs to identify "fake green" behaviors such as skipped or deleted tests, weakened assertions, and CI forced to pass, and supports agents including Claude Code, Codex, Gemini CLI, Cursor, and Aider. The tool uses deterministic rule-based analysis, does not rely on large models, requires no API keys, and has no runtime dependencies; it typically completes within 100 milliseconds and can be integrated into agent turn-end hooks, pre-commit, and GitHub Actions.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

fakegreen is an open-source detection tool for teams using AI coding agents, designed to uncover the cheating tactics agents use to make tests "go green." AI coding agents (such as Claude Code, Codex, Cursor, Gemini CLI, and Aider) often target "tests passing" and sometimes fake a pass by deleting tests, adding .skip to tests, replacing toBe(42) with toBeDefined(), adding @ts-ignore, making code check NODE_ENV === 'test', or appending || true after a CI step, then claiming "all tests pass ✅." fakegreen reads the git diff and catches these behaviors.

Key capabilities: the tool analyzes only added and removed lines in the diff, so old code is not flagged repeatedly; before matching, it lexically processes comments and string literals to avoid false triggers from ".skip" inside strings or comments; moved-only lines (renames, file splits, reordering) are ignored, and moving a test file or a test appearing in another file does not count as deletion. Supported languages include JavaScript/TypeScript, Python, Go, Rust, Java (including Kotlin test annotations), as well as CI and configuration files such as GitHub Actions, GitLab CI, package.json, tsconfig, jest/vitest/c8/nyc config, pyproject.toml/setup.cfg/tox.ini/.coveragerc, Maven/Gradle, Makefile, and husky/shell hooks. Severity is graded by scenario; for example, a blanket # type: ignore is medium, a targeted # type: ignore[attr-defined] is low, and a file-level // @ts-nocheck is high; || true on npm test is high, while || true on rm -rf build is low; skipif(sys.platform == "win32") is low, and skipif(True) is high. Markdown/docs, lock files, vendored and node_modules code, generated files, and fixtuThe res/ and testdata/ directories are skipped automatically.

Usage: try it without installing; requires Node.js 18+ and git on PATH; to pin a version, run npm i -D fakegreen. Exit codes: 0 means clean (or below --fail-on), 1 means findings at or above --fail-on were found, 2 means a usage or git error. Each finding includes severity, file:line, rule id, a short description, and the offending + / - lines; --json outputs structured results. The tool provides a hook subcommand that can emit blocking feedback in the corresponding protocol to the end-of-turn hooks of Claude Code, Codex, and Gemini CLI, so the agent is told the specific faking behavior before it claims completion and is asked to fix or explain it; the installer shows a diff of the configuration changes and asks before writing, supports --yes to skip prompts and --dry-run to preview only, merges into existing configuration idempotently, and refuses to modify files that are not valid JSON. It also supports the pre-commit framework, GitHub Actions (findings shown as PR annotations), and the agent skill file skills/fakegreen/SKILL.md. Configuration is possible via .fakegreenrc.json, .fakegreenrc, or the fakegreen key in package.json. For intentional changes, add a fakegreen-ignore comment on the line or the line above, specifying the rule and reason; for deleted lines, the comment can be placed anywhere in the added lines of the same hunk; fakegreen-ignore-file exempts an entire file. Each ignore comment is itself reported as a low-severity finding (ignore-comment-added), so reviewers can see what was exempted.

Use cases: teams using Claude Code, Codex, Cursor, Gemini CLI, or Aider that want a hard block on fake-green diffs; maintainers who need deterministic CI, pre-commit, or end-of-turn tripwires; and users tired of agents skipping tests, weakening assertions, or appending || true and then claiming everything passes.

Limitations: the tool uses line-based heuristic analysis without an AST, so unusual formats (multi-line test declarations, quoted regex literals, macros) may cause missed detections or occasional false positives; test-count compensation is diff-global, so deleting one test and adding one unrelated simple test will not reduce the count, but weakened or trivial assertions are still caught by the assertion rules; only JS/TS, Python, Go, Rust, and Java/Kotlin sources are analyzed; Ruby, C#, C/C++, PHP, Swift, and custom test DSLs are out of scope, though their CI configuration changes are still checked; the hook compares uncommitted work with HEAD by default, so if the agent commits during the session, use --hook-args "--base origin/main"; fakegreen-ignore-file only takes effect when it appears in an added line or the context of the diff. The tool makes no network requests and only invokes git. The project is under the MIT license, and the CLI, hooks, pre-commit hook, and GitHub Action will remain free; the author also offers Pro ($49/month) and Team ($199/month) support tiers, plus a waitlist for a planned Teams hosted version.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools