Diffcap — AI skill for Claude Code
Cap how much an AI coding agent changes before a human looks: a Claude Code PreToolUse hook (and CLI / CI check) that asks or blocks once the working tree passes N changed lines or M files, from git d.
How to install Diffcap
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open acus9345/diffcap and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
What Diffcap does
Cap how much an AI coding agent changes before a human looks: a Claude Code PreToolUse hook (and CLI / CI check) that asks or blocks once the working tree passes N changed lines or M files, from git diff --numstat. Cross-platform, zero dependencies.
Alternatives in AI
- Tokentab — A CLI that reads Claude Code, Codex, and Gemini CLI session logs and works out how much they cost, by model, p 226 ★
- Claude Code Sourcemap Learning Notebook — Reverse-engineering Claude Code's 512K+ lines of TypeScript — architecture, design decisions, and 11 transfera 160 ★
- Cost — AI Build Cost Tracker — track how much AI costs per feature, task, and project 63 ★
README
diffcap
**Cap how much an AI coding agent changes before a human looks.** Unlike commit-time or after-edit diff-size checks (blog recipes, yurukusa's `diff-size-guard`), diffcap stops the edit *before* it lands.
Agents make reviewable changes right up until they don't. One "while I'm here" refactor later you are staring at 1,800 changed lines across 40 files. `diffcap` is a Claude Code `PreToolUse` hook that checks each edit before it happens. If the edit would push the work tree past *N changed lines or M files* since the last commit, the agent has to stop and ask you, or split the work:
$ diffcap init --write # adds the hook to .claude/settings.json
diffcap: the work tree would reach 438 changed lines (cap 400) since the last commit. Allow this edit to src/api/client.ts anyway?
❯ Yes No
The same binary is a CI or git-hook check:
$ diffcap --max-lines 400
diffcap: 612/400 ✗ lines, 9/15 files changed since HEAD over the cap
+401 -12 src/api/client.ts
+88 -40 src/api/types.ts
...
(not counted: package-lock.json)
$ echo $?
1
Why it's new
Today the options are a line in CLAUDE.md ("keep changes small"), which the model may ignore, or a copy-paste bash recipe. Those recipes either check the staged diff when the agent runs `git commit`, which is after the damage is done, or they print an advisory after each write (PostToolUse). `diffcap` takes a different approach:
- Projects the size before the write. Work tree size (
git diff --numstat HEAD, plus untracked files) + the estimated line delta of the pendingEdit/MultiEdit/Write/NotebookEdit. The estimate reads the existing file, so aWritethat rewrites a file counts changed lines, not file length, andreplace_allis multiplied by the number of occurrences. - Three modes:
ask: you confirm in Claude Code.deny: the agent is told to stop, summarize and checkpoint.warn: context is injected fo
Related Skills
Commit Pilot
An autonomous, AI-powered maintainer. Once a day, CommitPilot opens a repository you choose, asks Claude for o
Vector Gate
Stop an AI coding agent before it does something it cannot undo. A deterministic PreToolUse hook for Claude Co
Claude Watermark Remover Skill
Claude watermark remover skill for Claude Code. Rewrites Claude-written text with a different model (never Cla
Claude Watermark Rewrite Skill
Claude watermark remover skill for Claude Code. Rewrites Claude-written text with a different model (never Cla
Skillgate
Deterministic finish-line gates for AI coding agents. A model-independent evaluator that blocks commit/publish
AI Agent Guardrails Windows Guide
Verified guide: a global guardrail that blocks catastrophic shell commands from AI agents on Windows (Claude C
Related Agents
Visual Checker
Looks at page screenshots so the main session does not have to. Give it a URL, what changed, crop paths from c
Kaizen Verifier
Verifies what Kaizen just applied — every installed hook passes its self-test, every touched settings.json par
Red Line Auditor
Pre-commit/pre-deploy auditor for LUMINA's red lines — the violations that fail the assignment outright. Read-