fast-gate
Deterministic pre-flight facts for Fact-Forcing Gate (GateGuard-style) hooks.
Hooks like GateGuard reject a Write or Update unless the agent first states: who calls the file, that nothing
already serves the same purpose, the schema of any data it touches, and the user's instruction verbatim. fast-gate
computes the first three from the workspace and formats all four, so the agent does not have to research or reformat
them by hand.
Install
uv pip install -e . # or: pip install -e .
The package is published as fast-gate-py; the command is fast-gate. Python 3.10+.
Use
# print the four-point block for a file you are about to write
fast-gate inspect src/app/export.py --instruction "Add a CSV exporter to app" --root .
# exit 0 if the target is safe to write, 1 (with reasons on stderr) otherwise
fast-gate check src/app/export.py
Relative targets are resolved from the current directory; --root (default .) is the workspace to scan.
Example output:
## Pre-flight facts for `src/app/export.py` (create new file)
### 1. Callers / importers
- No existing file imports or references the target.
- Planned caller / entry point: `src/app/cli.py` (console script `app = app.cli:main`) is expected to import or dispatch to it
### 2. Non-duplication
- Searched 14 file(s) under the workspace root (skipped: .git, .venv, venv, __pycache__, ...).
- No file has the same name, the same stem, or a similar name; nothing existing serves this purpose.
### 3. Data schemas
- N/A: the target does not exist yet and the instruction names no data file; ...
### 4. Verbatim user instruction
> Add a CSV exporter to app
What it checks
| Fact | How |
|---|---|
| Callers / importers | AST scan of every .py file for imports of the target (absolute, relative, aliased, from pkg import module), with line numbers. Non-code targets are matched by string literals. New files get a planned entry point from [project.scripts], the package __init__, or pytest collection. |
| Non-duplication | Same name, same stem, or a similar name (difflib ratio >= 0.8) anywhere in the tree, ignoring .git, .venv, venv, __pycache__, caches, and build output. |
| Data schemas | CSV, JSON, JSONL, SQLite, and YAML are read; Parquet needs pyarrow, and YAML values need PyYAML (otherwise keys only). Output is field names, type names, date-format names, and a synthetic example row. Values are never printed, and SQLite is opened read-only without reading rows. |
| Verbatim instruction | Passed through --instruction, quoted line for line. |
Workspace text (paths, field names, source lines) is stripped of backticks and control characters before it is put in the block, so a hostile CSV header cannot forge a heading.
Claude Code integration
skills/fast-gate.md: the skill. Copy it to~/.claude/skills/fast-gate/SKILL.md(or a project's.claude/skills/) to have Claude runfast-gate inspectbefore guarded writes..claude/commands/fast-gate.md: the/fast-gate <target_file>slash command for this repo.
Some hooks deny the first attempt on every new file no matter what was presented, then accept an identical retry.
fast-gate cannot change that behavior; it makes the facts correct and complete so the retry is a single call.
Development
./venv/bin/pytest tests/ -v
ruff check .
Release files for fast-gate-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fast_gate_py-0.1.0.tar.gz | 17.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fast_gate_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.0 kB
Release files / fast_gate_py-0.1.0.tar.gz
| Download URL | fast_gate_py-0.1.0.tar.gz |
|---|---|
| Size | 17.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8b4d220c5372e558ab255381c59e0b1c7acacd6ddefb565c1c7cef7afdb20ae
|
|
BLAKE2b-256 checksum How to use checksums |
1844632c6e35774bb62a4839cf4a791d5a1c2ae33840ec45cb8924331ec0ec56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Release files / fast_gate_py-0.1.0-py3-none-any.whl
| Download URL | fast_gate_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6556be4977f207a65df2c50a4ea4f09aba696b9c5a7a35c40505263d5f2192e2
|
|
BLAKE2b-256 checksum How to use checksums |
72a1dd2af8901cdf7c0bfc173fd4b77a0dfa7be72104be23f40bb15d98558b00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|