{"slug": "show-hn-hooks-that-stop-claude-code-from-faking-tests-and-inventing-packages", "title": "Show HN: Hooks that stop Claude Code from faking tests and inventing packages", "summary": "A developer published a Claude Code plugin, claude-code-project-template (installed via `/plugin install cct --marketplace John99101/claude-code-project-template`), that generates a project's CLAUDE.md, rules, permissions, hooks, skills, agents and MCP server configuration from a few multiple-choice questions. The kit's hooks include a done gate that runs only the tests related to a change before Claude Code finishes, a dependency check that blocks package names that do not exist on npm, PyPI or crates.io, a claim check that rejects assertions of checks Claude never ran, and a test guard that asks before skips, deleted tests or changed expected values. The author says hand-building the same setup takes hours per project and goes stale, and that answers are remembered so subsequent projects only prompt for what is new.", "body_md": "One command, and Claude reads your repo, asks a few multiple-choice questions, and writes the whole setup for you:\n`CLAUDE.md`, rules, permissions, hooks, skills, agents and MCP servers, all matched to your real stack.\n\n<sub>Illustrative session. Every message from the kit in it is the hooks' real output.</sub>\n\n```\n/plugin install cct --marketplace John99101/claude-code-project-template\n/cct:setup\n```\n\n[Quick start](#quick-start) · [What you get](#what-you-get) · [A day with the kit](#a-day-with-the-kit) · [FAQ](#faq) · [Full guide](https://github.com/John99101/claude-code-project-template/blob/main/docs/GUIDE.md)\n\nOut of the box, Claude Code doesn't know how your tests run, which folders are generated, what your team's commit style is, or that it must never touch `.env`. So it guesses, and you correct it over and over.\n\nClaude Code can learn all of this through `CLAUDE.md`, rules, settings, hooks, skills, agents and MCP. Setting them up by hand takes hours per project, is easy to get wrong, and goes stale. **This kit does it for you, and keeps it current.**\n\n| Without the kit | With the kit | \n|---|---|\n| Claude guesses `npm test` while your repo uses`pnpm vitest` | `CLAUDE.md` lists the real commands, detected from`package.json` ,`Makefile` and CI | \n| \"Done!\" … and the tests fail | The **done gate** runs your checks before Claude finishes, and only the tests related to the change | \n| Lint errors show up in CI an hour later | Every edited file is **formatted and linted** , and problems go straight back to Claude | \n| One `rm -rf` or force-push away from a bad day | A **guard** blocks destructive commands and secret-file edits, and asks before risky ones | \n| Claude installs a package whose name it made up | The **dependency check** blocks names that don't exist on npm, PyPI or crates.io, and asks before brand-new ones | \n| \"All tests pass!\" … but nothing ran | The **claim check** sends Claude back when it claims a check it never ran | \n| \"Don't touch the API\" is forgotten after compaction | **`/pin`** keeps it in Claude's context and the guard enforces path pins | \n| Claude rewrites a helper you already have | **Duplicate hints** point it to the existing function | \n| Cursor, Copilot and Claude follow different instructions | **One `AGENTS.md`** feeds every tool; generated copies can't drift | \n| Commands and hooks break for the Windows half of the team | The **portability check** flags POSIX-only commands, backslash paths and CRLF scripts | \n| Claude makes a failing test pass by skipping it | The **test guard** asks before skips, deleted tests, removed assertions or changed expected values | \n| Database + web browsing + `curl` in one session: one poisoned page away from a leak | The **trifecta check** warns about the combination and asks before data leaves the machine | \n| A 2,000-line change nobody can review | The **small-batch nudge** says when to commit, before it gets that big | \n| A teammate changes the rules and nobody notices | **Session notices** flag teammates' config changes, stale installs, missing`.env` keys and outdated commands | \n| Every new repo starts from zero | Your answers are **remembered** , so the next project only asks what's new | \n\n**Plugin** (easiest). In Claude Code:\n\n```\n/plugin install cct --marketplace John99101/claude-code-project-template\n```\n\nThen run **`/cct:setup`** in any project. Updates arrive through `/plugin`. On older Claude Code versions, add the marketplace first with `/plugin marketplace add John99101/claude-code-project-template`, then `/plugin install cct@cct-kit`.\n\n## **Other ways to install: into one repo for your team, device-wide, or as a new repo**\n\n**Ask Claude.** In Claude Code, inside your project:\n\n```\nInstall github.com/John99101/claude-code-project-template into this project, following its INSTALL.md\n```\n\nClaude previews the install, applies it, then walks you through setup. The config lives in the repo, so your whole team shares it.\n\n**Install script.**\n\n```\ngit clone --depth 1 https://github.com/John99101/claude-code-project-template /tmp/cct\npython3 /tmp/cct/install.py --project ~/code/my-app   # one project, shared with your team via git\npython3 /tmp/cct/install.py --global                  # every project on this device\n```\n\nOn Windows, in PowerShell: `.\\install.ps1 --project C:\\code\\my-app` (or `py -3 install.py …`). Add `--dry-run` to preview. Existing files are never overwritten, and `settings.json` is merged with a backup. Then run **`/setup`** in Claude Code (or `/setup --defaults` to skip the questions).\n\n**New repository.** Click **Use this template**, run `python3 install.py --adopt` once, restart Claude Code and run `/setup`.\n\n|  | Plugin | Project install | Device install | \n|---|---|---|---|\n| Commands | `/cct:setup` ,`/cct:pr` … | `/setup` ,`/pr` … | `/setup` ,`/pr` … | \n| Shared with your team | Optional | Yes, committed to git | No | \n| Updates | `/plugin` | `/template-update` | `/template-update` | \n\n`--update` pulls kit updates and keeps your changes; `--uninstall` removes the kit but keeps files you changed.\n\n**Requirements:** Claude Code and Python 3.8+ (the hooks use only the standard library). Tested on every push on **Linux, macOS and Windows**.\n\n*Illustrative run on a TypeScript API:*\n\n```\n[cct]   The Claude Code kit is installed here, but setup isn't finished. Run /setup to finish it.\n\nYou     /setup\nClaude  Found: TypeScript + Fastify, pnpm, Vitest, ESLint + Prettier, Postgres, Conventional Commits.\n        ? How thorough should setup be?          › Quick (recommended)\n        ? How independently should I work?       › Ask before big or risky changes (recommended)\n        ? What must pass before I say I'm done?  › pnpm lint, pnpm typecheck, pnpm test\n        ? Run those automatically when I finish? › Yes, the fast checks, only related tests\n        ? Connect any tools via MCP?             › GitHub, Postgres\n\n        Plan: CLAUDE.md (stack, 7 commands, architecture) · 5 rules + typescript.md\n              settings: allow pnpm test/lint/typecheck · .mcp.json: GitHub, Postgres\n        Apply? › Apply\n\nClaude  PASS  pnpm lint (2.1 s) · PASS  pnpm typecheck (4.0 s) · PASS  pnpm vitest related (1.3 s)\n        Done. Set GITHUB_PERSONAL_ACCESS_TOKEN and DATABASE_URI, then restart Claude Code.\n```\n\nQuick setup asks about a dozen questions; Thorough asks about 30. Monorepos get a short brief per package. See the [full walkthrough](https://github.com/John99101/claude-code-project-template/blob/main/docs/GUIDE.md#6-a-full-example).\n\n**A project brief Claude reads every session.** `CLAUDE.md` with your stack, real commands, architecture, conventions and a \"before you say it's done\" checklist. Topic rules (code style, testing, API design, security, git) and language packs for Python, TypeScript, Go, Rust and Java/Kotlin load only for matching files.\n\n**Commands for the whole workflow**\n\n| Command | What it does | \n|---|---|\n| `/start-issue 123` | Reads the GitHub or GitLab issue, creates a branch in your naming style, finds the code involved and proposes a plan | \n| `/check` | Lint, type check and tests, then fixes what recent changes broke | \n| `/review-changes` | Reviews your diff with a reviewer agent (and a security auditor when it matters) | \n| `/commit` | Commits in your project's message style | \n| `/pr` | Opens a review-ready pull request: suggests a split when it's too big, ticks only checks that really ran, and tells the reviewer its assumptions, what's untested and where to look first | \n| `/handoff` | Saves where a task stands, so tomorrow's session ( `/handoff resume` ) picks up exactly there | \n| `/pin` | Pins a constraint for the task (\"don't change the public API\", `only edit: src/billing/**` ). It survives compaction, and path pins are enforced | \n| `/spec` | Writes a short behaviour spec (examples, acceptance criteria, non-goals) for your OK before any code, then builds and checks against it | \n| `/tidy` | Proposes small cleanups for the code you just changed, each tested and committed apart from feature work | \n| `/learn on` | Learning mode: Claude explains concepts, lets you guess a bug's cause first, and leaves small parts for you to write | \n| `/setup` | Re-tunes anything later: \"make the guard strict\", \"add a rule for our GraphQL conventions\" | \n\nClaude also picks up `write-tests`, `debug-issue`, `release-notes` and `remember-preference` by itself when they fit, and has four specialist agents: planner, reviewer, security auditor and test writer.\n\n**Hooks that enforce, not suggest**\n\n- **Guard:** blocks`rm -rf ~` ,`curl … | sh` , force-pushes to`main` and writes to`.env` or keys, even when they're hidden in`sh -c` ,`eval` or`$(…)` . It asks before`git reset --hard` ,`sudo` ,`DROP TABLE` and publishing.\n- **Format and lint on every edit** with the tools your project already has (prettier, biome, eslint, ruff, black, gofmt, golangci-lint, rustfmt, clippy, shellcheck). It never downloads anything.\n- **Done gate:** your checks run before Claude finishes a turn that changed files; a failure sends Claude back to fix it.\n- **Dependency check:** before an install, every package is looked up in its registry. Names that don't exist are blocked (AI models invent package names, and attackers register them); packages under 30 days old or barely downloaded need your OK. New imports that no manifest declares are pointed out too.\n- **Test guard:** edits that add`skip` markers, delete test cases, remove assertions or only change an expected value need your OK, so Claude can't make a test pass by weakening it.\n- **Trifecta check:** when MCP servers and permissions give Claude private data, untrusted content*and* a way to send data out (Simon Willison's \"lethal trifecta\"), you're warned, and outbound commands such as`curl -d` need your OK.\n- **Small-batch nudge:** past 300 uncommitted lines (lockfiles and generated files excluded), you're told to commit the finished part.\n- **Claim check:** if Claude's final reply says \"tests pass\" or \"verified\" but no check ran in that turn, it's sent back to run it or correct the claim.\n- **Duplicate hints:** a new function that already exists elsewhere (`formatDate` /`format_date` ) is pointed out, so Claude reuses it.\n- **Status line:**`Opus · my-app (main) · $0.42 · guard standard · setup done` .\n\n**Session notices.** At session start you see what needs attention before Claude touches anything:\n\n```\n[cct] This machine doesn't quite match the project:\n- pnpm-lock.yaml changed since the last install. Run `pnpm install`.\n- .env is missing STRIPE_KEY (listed in .env.example).\n- Node 20 is required (.nvmrc), but `node` is 18.19.1.\n[cct] Teammates (Alex) changed the Claude config since your last session: .claude/rules/testing.md.\n[cct] There's a handoff note from 2026-11-27 18:05 in .claude-handoff.md. Run /handoff resume to pick up where you left off.\n```\n\nIt also flags commands in `CLAUDE.md` that no longer exist, linters your project configures but you haven't installed, instruction files for other AI tools that disagree with `AGENTS.md`, and, for teams with Windows, commands, hooks and scripts that won't work there.\n\n```\n/start-issue 482        → branch feat/482-rate-limit, plan, your OK\n… Claude works …        → every edit formatted and linted; the done gate runs related tests\n/review-changes         → reviewer and security auditor read the diff\n/commit  →  /pr         → PR opened from your template, test plan filled in\n/handoff                → end of day; tomorrow: /handoff resume\n```\n\nSeveral features answer specific findings about AI-assisted coding:\n\n| Finding | What the kit does | \n|---|---|\n| Experienced developers were 19% slower with AI but believed they were 20% faster ( [METR](https://metr.org/blog/2025-07-10-early-2025-ai-experienced-os-dev-study/) ) | Done gate, claim check and the session cost in the status line replace gut feeling with evidence | \n| Agents disable or delete tests to get a green run ( [Kent Beck](https://tidyfirst.substack.com/p/augmented-coding-beyond-the-vibes) ) | Test guard | \n| Private data + untrusted content + outbound access enables prompt-injection leaks ( [Simon Willison](https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/) ) | Trifecta check | \n| Model reliability drops as context grows ( [Chroma](https://research.trychroma.com/context-rot) ) | `/pin` and`/handoff` keep what matters outside the conversation | \n| Developers who let AI write the code learned less, especially debugging ( [Anthropic](https://www.anthropic.com/research/AI-assistance-coding-skills) ) | `/learn` | \n| Spec-first workflows give humans and agents one source of truth ( [Böckeler, Thoughtworks](https://www.martinfowler.com/articles/exploring-gen-ai/sdd-3-tools.html) ) | `/spec` | \n| AI raises delivery speed but lowers stability; small batches help ( [DORA 2025](https://services.google.com/fh/files/misc/2025_state_of_ai_assisted_software_development.pdf) ) | Small-batch nudge, `/pr` size check | \n| Refactoring fell and copy-paste rose with AI adoption ( [GitClear](https://www.gitclear.com/ai_assistant_code_quality_2025_research) ) | Duplicate hints, `/tidy` | \n| AI models invent package names that attackers then register ( [Socket](https://socket.dev/glossary/slopsquatting) ,[CSA](https://labs.cloudsecurityalliance.org/research/csa-research-note-slopsquatting-ai-supply-chain-20260419-csa/) ) | Dependency check | \n\nAnything that makes Claude do extra work is capped, and everything that's just information costs nothing:\n\n- **Lint feedback** stops for a file after 3 reports in a row (`lint_max_repeats` ), so Claude never loops on a linter it can't satisfy.\n- **The done gate** gives up after 3 tries per turn, and runs only the tests related to the change.\n- **Notices** are shown to you, not sent to Claude, so they use no tokens.\n- **The status line** shows the session's cost as you go.\n\n**Does it work with my stack?** Setup detects Node (npm, pnpm, yarn, bun), Python (uv, poetry, pip), Go, Rust, Java/Kotlin and more, plus monorepos (pnpm, Turborepo, Nx, Cargo and Go workspaces). Anything it can't detect, it asks about.\n\n**Will it overwrite my existing `CLAUDE.md` or settings?** No. Existing files are never overwritten; setup merges into them and asks before dropping anything you wrote. `settings.json` is merged with a backup.\n\n**Can my team share it?** Yes. A project install lives in the repo, so everyone gets the same rules, guard and commands. Personal tweaks go in `CLAUDE.local.md` and `settings.local.json`, which stay out of git.\n\n**Does it work alongside other plugins?** Yes. As a plugin, its commands are namespaced (`/cct:…`). See [using it with other plugins](https://github.com/John99101/claude-code-project-template/blob/main/docs/GUIDE.md#10-using-the-kit-with-other-plugins-eg-ecc).\n\n**Does it update itself?** No, on purpose: the hooks run code on your machine, so new code only arrives when you choose. Plugin installs update through `/plugin`. Script installs use `/template-update` and can opt in to a weekly \"new version\" notice.\n\n**Can I turn things off?** Every hook has a switch in `.claude/cct.json`. See the [configuration reference](https://github.com/John99101/claude-code-project-template/blob/main/docs/GUIDE.md#8-configuration-reference).\n\n| Check | When | \n|---|---|\n| [Test suite](https://github.com/John99101/claude-code-project-template/blob/main/tests/test_kit.py) : every hook, the installer, updates, uninstall, the plugin and file formats | Every push, on Linux, macOS and Windows | \n| [Setup eval](https://github.com/John99101/claude-code-project-template/blob/main/tests/eval_setup.py) runs`/setup` for real on four sample projects; the[question eval](https://github.com/John99101/claude-code-project-template/blob/main/tests/eval_questions.py) checks the questions it would ask | Weekly on GitHub, or any time locally ( [how](https://github.com/John99101/claude-code-project-template/blob/main/docs/GUIDE.md#running-the-setup-eval) ) | \n| [MCP catalog check](https://github.com/John99101/claude-code-project-template/blob/main/scripts/check_mcp_catalog.py) : every server URL and package still exists | Weekly; opens an issue if something breaks | \n\n## **Repository layout**\n\nThe repository uses Claude Code's standard plugin layout. The plugin uses these folders directly; the installer copies them into a project's `.claude/`.\n\n```\n.\n├── .claude-plugin/        # plugin manifest, marketplace entry, icon\n├── skills/                # setup, start-issue, check, review-changes, commit, pr, handoff, template-update,\n│                          # remember-preference, write-tests, debug-issue, release-notes\n├── agents/                # planner, reviewer, security-auditor, test-writer\n├── hooks/                 # guard, file protection, format and lint, done gate, session notices, status line\n├── rules/                 # code-style, testing, api-design, security, git-workflow\n├── rule-packs/            # python, typescript, go, rust, java\n├── templates/             # CLAUDE.md templates, settings, cct.json, mcp.json\n├── install.py             # install, update, adopt, uninstall (+ install.sh / install.ps1 launchers)\n├── scripts/  tests/       # helpers, test suite, setup eval, sample projects\n└── docs/GUIDE.md          # the in-depth guide\n```\n\nWhat a project gets after `install.py --project`:\n\n```\nmy-app/\n├── CLAUDE.md              # project brief, filled in by /setup\n├── .mcp.json              # MCP servers\n└── .claude/\n    ├── settings.json      # permissions, hooks, status line\n    ├── cct.json           # kit switches\n    ├── rules/  skills/  agents/  hooks/\n    └── cct/               # rule packs, package template, install manifest\n```\n\n- **[Guide](https://github.com/John99101/claude-code-project-template/blob/main/docs/GUIDE.md):** how each part works, the setup flow, safety model, configuration, troubleshooting\n- **[Hooks](https://github.com/John99101/claude-code-project-template/blob/main/hooks/README.md):** what each hook does and how to add your own\n- **[INSTALL.md](https://github.com/John99101/claude-code-project-template/blob/main/INSTALL.md):** install instructions written for Claude\n- **[Changelog](https://github.com/John99101/claude-code-project-template/blob/main/CHANGELOG.md)**\n\nIssues and pull requests are welcome; see [CONTRIBUTING.md](https://github.com/John99101/claude-code-project-template/blob/main/CONTRIBUTING.md). Run the tests with `python3 tests/test_kit.py -v`.\n\nIf the kit saves you time, a ⭐ helps other developers find it.", "url": "https://wpnews.pro/news/show-hn-hooks-that-stop-claude-code-from-faking-tests-and-inventing-packages", "canonical_source": "https://github.com/John99101/claude-code-project-template", "published_at": "2026-11-27 17:01:08+00:00", "updated_at": "2026-11-27 17:14:36.376737+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "agent-protocols"], "entities": ["Claude Code", "claude-code-project-template", "Anthropic", "npm", "PyPI", "crates.io", "MCP"], "also_reported_by": [], "takeaway": "Install the cct plugin and run /cct:setup to auto-generate CLAUDE.md, hooks and permissions from your repo's package.json, Makefile and CI, with hooks that gate completion on related tests and block nonexistent npm, PyPI or crates.io package names.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-hooks-that-stop-claude-code-from-faking-tests-and-inventing-packages", "markdown": "https://wpnews.pro/news/show-hn-hooks-that-stop-claude-code-from-faking-tests-and-inventing-packages.md", "text": "https://wpnews.pro/news/show-hn-hooks-that-stop-claude-code-from-faking-tests-and-inventing-packages.txt", "jsonld": "https://wpnews.pro/news/show-hn-hooks-that-stop-claude-code-from-faking-tests-and-inventing-packages.jsonld"}}