scoped-gate
Skill1 starsChanged 37 days agoMITView on GitHub
Use when a repo-wide quality gate never turns green because of preexisting debt the diff never touches. Documents the diff-scoped gate pattern (baseline, file scope, four edge cases) — hygiene the agent runs mid-session, never a substitute for `qualityGate.full`.
In this repository41 other files it gives its agents.
- AGENTS.mdAGENTS.md
- patient/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- patient/CLAUDE.mdCLAUDE.md
- author-skillSkill
- context-intakeSkill
- debug-failureSkill
- dominioSkill
- follow-up-prsSkill
- locate-codeSkill
- master-planSkill
- plan-advancedSkill
- plan-simpleSkill
- pytestSkill
- quality-attributesSkill
- resolve-ticketSkill
- review-diffSkill
- scoped-gateSkill
- secure-by-designSkill
- security-invariantsSkill
- solution-designSkill
- spec-bootstrapSkill
- verify-before-doneSkill
- author-skillSkill
- context-intakeSkill
- debug-failureSkill
- dominioSkill
- follow-up-prsSkill
- locate-codeSkill
- master-planSkill
- plan-advancedSkill
- plan-simpleSkill
- pytestSkill
- quality-attributesSkill
- resolve-ticketSkill
- review-diffSkill
- secure-by-designSkill
- security-invariantsSkill
- solution-designSkill
- spec-bootstrapSkill
- verify-before-doneSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 33
Run the linter/formatter against exactly that list.
- Very specific: line 58
BEFORE the commit, so a scope built only from git diff reports 0 files to scan — the gate goes green over a file nobody read.
- Very specific: line 67
Baseline freshness: Prefer origin/main over the local ref: an agent worktree is cut from whatever the base pointed at when it was created …
- Distinctive: line 76
Write your own script following this pattern, with the same worktree and scope handling described above.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- navori:managed id="scoped-gate-base" hash="991f0e09" version="0.12.3" source="@navori/core" fmkeys="name,description,metadata" -->Scoped gate — diff-scoped quality gate as hygiene, not a seal
The problem
A repo-wide qualityGate.fast judges the repo's historical debt, not the
agent's work. In a repo with preexisting failures, a blocking check never
turns green — not because it's slow, but because it's scoped wrong: it fails
on files the diff never touched. Measured across four repos: three are red on
lint/format from files outside any given diff.
The pattern
Scope the fast check to the files actually in the diff instead of the whole tree:
- Resolve a baseline:
origin/mainfirst, the local ref only as fallback. - List files in scope:
git diff --name-only <base_sha>plusgit ls-files --others --exclude-standardfor untracked files. - Run the linter/formatter against exactly that list.
base='main'
if git rev-parse --verify --quiet "origin/$base^{commit}" >/dev/null; then
base_sha=$(git rev-parse "origin/$base")
elif git rev-parse --verify --quiet "$base^{commit}" >/dev/null; then
echo "scoped-gate: origin/$base not found; falling back to local ref $base (may be stale)" >&2
base_sha=$(git rev-parse "$base")
else
echo "scoped-gate: no ref found for base '$base' (checked origin/$base and $base)" >&2
exit 1
fi
files=$( { git diff --name-only --diff-filter=ACMRT "$base_sha" -- '*.ts' '*.tsx'; \
git ls-files --others --exclude-standard -- '*.ts' '*.tsx'; } | sort -u)
[ -n "$files" ] && eslint $filesAdapt the pathspec and linter to the repo; the shape (baseline → scope → run) matters.
Four edge cases — each one cost a real bug to discover
- Untracked files (#777). Most of an agent's work is new files. When a
single Bash call does
git add x && git commit, thePreToolUsehook runs BEFORE the commit, so a scope built only fromgit diffreports0 files to scan— the gate goes green over a file nobody read. Always addgit ls-files --others --exclude-standardto the scope. - A failed listing is not "nothing changed" (#511). A
gitcall that fails (unborn HEAD, a corrupt index, a base that vanished) produces empty output — indistinguishable from an empty diff unless you check its exit status. Without a sentinel, the gate reports0 files to scanand approves a tree it never read. Capture the exit code of every listing, not just the file list. - Baseline freshness. Prefer
origin/mainover the local ref: an agent worktree is cut from whatever the base pointed at when it was created and never moves again, so the local ref has no freshness guarantee and can silently drift behind merged work. - Agent worktrees. A hook fired by a commit inside a worktree still starts execution from the main repo's cwd. Resolving paths against the wrong root makes the scanner never run at all — silently, since an empty scope looks identical to a clean one without edge case #511's sentinel.
Write your own script following this pattern, with the same worktree and scope handling described above.
Wiring: a package.json script, not a bare path
Claude Code pre-approves <package-manager> run <script> as
Bash(<step>:*), but a bare script path (bash path/to/script.sh) earns
no rule and prompts on every run (packages/cli/src/engines/claude/build-settings.ts:634-638).
Define the scoped check as a package.json script invoked by the repo's
package manager (e.g. pnpm run gate:fast), never as a direct path to a
script file — pointing at the script directly reintroduces the friction that
led agents to wrap commands in bash -c '…' to dodge prompts.
The honest limit: typecheck does not scope
tsc type-checks the whole project graph; there is no "these files only"
without losing correctness (a change in file A can break file B's types).
Two options, neither free: filter the reported errors by touched file
(misses errors your change caused elsewhere), or leave typecheck in the
repo-wide gate only. Default: leave it out of the scoped gate. A repo that is
already green on typecheck can afford to keep it repo-wide — the check is
typically sub-second there.
Hygiene, never a seal
A scoped gate is hygiene, never a seal: it catches the agent's own
mistakes mid-session, cheaply, in a repo where the repo-wide check can't. It
never replaces qualityGate.full, which stays repo-wide and remains the
reviewer's Pass 2. Treating a scoped-green result as approval is worse than
having no scoped gate at all — it launders preexisting debt as a pass.
<!-- /navori:managed id="scoped-gate-base" -->Your repo's scoped gate
<!-- user: document here the concrete wiring for this repo — the
`package.json` script name, the pathspec/extensions it scopes to, and
whether `typecheck` stays repo-wide or gets excluded. -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

