Make the flow happen
The nossaifd skill gives an agent the steps for a page. The agent drafts the page by the guide and runs the checker. A subagent then runs the pass of the declaude skill by Oskar Austegard. Then the agent runs the checker again and the linter once more.
An agent follows these steps only when it loads the skill and keeps to it. Three parts of this package make that happen in a project. Each part does a different job, so the expensive pass runs once for each change of a page.
| Part | What it does | What it costs |
|---|---|---|
The instruction in AGENTS.md and CLAUDE.md |
It tells the agent to use the nossaifd skill for every page that a person reads. The agent reads the file at the start of each session | Nothing. It is text |
| The hooks at the start and the end of a turn | They find each page that the turn changed. They block the end of the turn once when such a page has a hard problem or no record of its pass | About a tenth of a second for each turn |
| The workflow for GitHub | It runs the checker on each page that a pull request adds or changes | Seconds on GitHub, and no model |
The instruction in AGENTS.md and CLAUDE.md
The file .agents/skills/nossaifd/assets/agents-prose.md holds the lines for the AGENTS.md and the
CLAUDE.md of a project. With them, the agent does the steps while it writes, and the hook rarely has to
ask.
The lines say that just prose replaces steps 6 to 8 of the skill only when .agents/stack.json sets
choices.tasker to the JSON value true. The gate tests the same setting, in gates_installed.
Otherwise the agent does the steps itself. It does them itself also when the project has no recipe
just prose, or when that recipe only runs the checkers. just prose-check only runs the checkers, so it never replaces those steps.
The hooks at the start and the end of a turn
A turn starts when a person sends a message, and it ends when the agent stops to answer. Claude Code and
Codex run .agents/skills/nossaifd/scripts/prose_gate.py at both moments.
- At the start of a turn,
prose_gate.py startkeeps a snapshot of the pages. The snapshot holds the last commit and the content of each page that git reports as changed. - At the end of a turn,
prose_gate.py hookcompares the pages with the snapshot. A page counts when its content differs from the snapshot. A page can differ in the working copy or in a commit that the turn made. Such a commit has the same author and was made after the turn started. A pull or a checkout brings commits that were made before the turn, so they do not count.
For each page that counts, the hook runs the checker of the page, and it looks up the page in the record
of passes. The checker is check.py, or another checker that the map of checkers of the project names
for the page. A page passes when its checker finds no hard problem and the record holds the page as it is now.
After step 8 of the nossaifd skill, the agent records each page:
uv run --no-project --quiet python .agents/skills/nossaifd/scripts/prose_gate.py record page.mdrecord refuses a page that has a hard problem, a missing page, and a file outside the repository. The
record is a promise of the agent, not a proof. The hook cannot see whether the declaude pass ran.
The hook blocks the end of a turn only once. When the agent tries to end the turn again, the hook lets it end, so it cannot loop. On the next turn, the hook asks about a page again only when the page changes again. A draft that a person edits, or a page of an earlier turn, does not block a later turn. A block names at most 20 pages.
The hook sees the working copy, not the agent. So when a person edits a page during a turn, or a second agent edits a page in the same working copy, that page counts for the turn.
The record lives in the folder .git/nossaifd. Every worktree of the repository shares it, so a page
that passed in one worktree passes in the others. It never shows in git status. The snapshots live in
the folder of git of each worktree. Pages in a submodule are out of scope.
The hook skips these files, because they are not pages for a person:
AGENTS.md,CLAUDE.mdandGEMINI.md, in any folder- a file
CHANGELOG.md, in any folder - the folders
.agents/,.claude/and.codex/ - the folders
node_modules/,_site/and.quarto/, in any folder
An error in the hook never blocks, and a missing script never blocks either. Set the environment
variable NOSSAIFD_GATE=off before you start Claude Code or Codex to turn the hooks off. Setting it in a
command of the agent has no effect.
To see which changed pages still need their steps, and the checker of each changed page, run:
uv run --no-project --quiet python .agents/skills/nossaifd/scripts/prose_gate.py statusAnother checker for some pages
Some pages follow another guide, for example the slides of a talk. The script of a talk is in the
speaker notes. The talk guide of nossaifd-talks asks for contractions in the script, because speech uses
them. check.py marks each contraction as a hard problem, so it fails a good deck. The talk checker
check_talk.py knows the slides from the notes, so it is the right checker for a deck.
The map of checkers tells the gate which checker checks a page. It is the file
.agents/nossaifd-checkers.json in the root of the project. The root is the top folder of the git
repository. This map gives the decks and the plans of talks to the talk checker:
{
"version": 1,
"checkers": [
{
"pages": ["**/slides.qmd", "**/plan.md"],
"checker": ".agents/skills/presentations/scripts/check_talk.py"
}
]
}versionis the number 1.checkersis a list of rules. Each rule has a listpagesof globs and the path of onechecker.- A glob matches the whole path of a page from the root. A
*matches any characters inside one folder name, and a?matches one character. A**that is a whole folder name matches any number of folders, also none. So**/slides.qmdmatchesslides.qmdandtalks/cache/slides.qmd. Every other character matches itself. A./at the start does not count. A map with a glob that starts with/, ends with/, has a space at either end, or holds\,//,.or..as a folder name is broken, because such a glob would match no page. - The first rule whose glob matches a page names its checker. A page that no rule matches gets
check.py. - The path of a checker is relative to the root, with
/between folders. It names a Python file inside the project. A map with an absolute path or a path with..is broken. The gate follows a symlink, so a skill that the installer linked into.agents/skills/still works.
prose_gate.py pages still decides what is a page, and the map decides which checker checks it. Every
command of the gate that checks a page uses the map. These commands are hook, status, record,
check-diff and check.
The command of a checker, and its exit codes
The gate runs a checker with its own Python, in the root of the project, once for each page:
python -B CHECKER PAGEPAGEis the path of the page from the root. A path that starts with-gets./before it.-Bstops Python from writing__pycache__into the folder of the checker.- Exit 0 means that the page has no hard problem.
- Exit 1 means that the page has hard problems. Each line of the output that starts with the word
HARD, after spaces, names one problem, as inHARD slide 4: the title is long. A line that starts with the path of the page is a summary, and it names no problem. The gate gives these lines in the message of a block. AHARDline also fails a page when the checker exits 0. - Any other exit is a failure of the checker. So is exit 1 with no
HARDline, which is what a crash of Python gives. - A checker that does not end in 30 seconds also fails. The gate then stops the checker and each program in its process group.
- The hook at the end of a turn gives all its checkers 40 seconds together, because Claude Code and
Codex stop the hook after 60 seconds. A page whose checker gets no time is a hard problem. Run
prose_gate.py checkon that page.
The talk checker and check.py both keep this contract. prose_gate.py check -v PAGE also passes -v
before the page, so that the checker prints its soft notes.
A page never passes in silence when its checker cannot judge it. Each of these is a hard problem of the page, with a message that says what went wrong:
- the checker is missing
- the checker fails, does not end in time, or gets no time in the hook
- the map is not JSON, or does not have the format above
The gate names the checker of each page in the message of a block, in status, in record and in
check-diff. When the checker is not check.py, the record of a pass also keeps its name. So a pass by
the old checker does not count for the new one. status asks again about each changed page that the
map gives to another checker. The hook asks again when such a page changes in a turn.
A change to the map does not check the pages that did not change. After you change the map, check its
pages with prose_gate.py check.
To check pages by hand with the checker of each page, run:
uv run --no-project --quiet python .agents/skills/nossaifd/scripts/prose_gate.py check -v page.mdcheck exits with 0 when no page has a hard problem, 1 when a page has one, and 2 for a missing page. A
file outside the project, such as a draft in a temporary folder, gets check.py.
prose_gate.py check-changed checks the pages that changed since the last commit. The recipe
just prose-check of the role runs it, as the step prose-check of just check:
uv run --no-project --quiet python .agents/skills/nossaifd/scripts/prose_gate.py check-changed -vThe recipe of the role ends with the line jlog step prose-check, which records the step for jlog pass.
That line needs the shell jlog of the index of jnterfaces. A project without that index copies the recipe
of the README instead, which has no such line.
- The changed pages are the files that
git diff --diff-filter=AMT HEADnames, with no rename, and the new files that git does not ignore.Tis a change of type, such as a link that became a file. The ruleis_pagekeeps the pages among them. So a deleted page is not checked, and a renamed page is checked under its new name. - Before the first commit, each page in the index and each new page counts as changed.
- No changed page is a pass, with exit 0.
- With names of pages, it checks those pages only, as
checkdoes.-vcan come before or after a page. A page whose name starts with-comes after--. - Outside a Git repository, it needs names of pages. With none, it exits with 2.
- It writes nothing: no record of a pass, and no snapshot.
check-changed exits with 1 on a hard problem, as check does.
After the pages, the recipe checks the API pages, the pages that smalldocs makes from the docstrings of
the code. Its second line asks just --summary for a recipe api-prose-check at the top of the project.
The api tool of the Python profile, jnprofile-python, gives that recipe, and the index of jnterfaces
brings it to the top. The recipe writes the API page of each changed module into a temporary folder,
outside the project, and it checks the page with check.py. The docs role of jnterfaces asks for
api-check in the same way.
- With no such recipe, the line does nothing.
- With
--base REFor--base=REF, the line passes the option on to the recipe, each argument whole. It drops-v, which the recipe does not need. - With names of pages or with
--, the line does not run the recipe, because the recipe takes no page. It prints a line that says so. - In CI, or with
--base, the recipe checks the modules that changed since a base. It takes the base frombase_commitofprose_gate.py, so it compares with the same commit ascheck-changed. An error of the base fails the step. This holds from jnprofile-python #17 on. - A recipe from before jnprofile-python #17 takes no argument. With
--base, it fails, becausejustfinds no recipe named--base. Update the profile then. In CI, it checks no API page, because a CI checkout is clean. So a pull request with a bad docstring passes the step in CI. - A failure of
api-prose-checkor ofjust --summaryfails the step, so the linejlog step prose-checkdoes not run.
The check in CI
A checkout in CI is clean, so it has no page that changed since the last commit. So in CI, check-changed
compares HEAD with a base, as check-diff does. It keeps the pages by the same rule, and it checks each
page with its checker, by the map. It also checks each page that changed since the last commit, as on a
machine, and it checks each page once. CI here means the variable CI, which GitHub sets to true.
- CI counts as set when
CIholds a value other than empty,falseor0. Case and spaces around the value do not count. SoCI=falsegives the check since the last commit. - The default branch comes from the key
repository.default_branchof the event file of GitHub, atGITHUB_EVENT_PATH, or else fromorigin/HEAD. When neither gives a branch, the step exits with 2. - On a pull request, the base is the merge base of HEAD and
origin/BRANCH. BRANCH is the base branch, fromGITHUB_BASE_REF. So the check takes in only the commits of the pull request. - On a push to the default branch, the base is the commit before the push, the key
beforeof the event file. Each commit of the push is checked, because a commit can skip the commit gate with--no-verify. - When
beforeis all zeros, the push made the branch, as the first push does. Then the base is the empty tree, so the check takes in each page of HEAD. That holds also for a page of an earlier commit of the push. A line of the output says so. - When
beforeis no use, the base is the parent commit,HEAD^, and a line of the output says why. That holds whenbeforeis missing, or not in the history, or not an ancestor of HEAD, as after a force-push. - On another push, a merge queue or another CI system, the base is the merge base of HEAD and
the default branch. So each commit of a branch is checked, also after a force-push. When that merge
base is HEAD itself, HEAD has no commit of its own, and the base is
HEAD^. - When the base would be
HEAD^and HEAD has no parent, the base is the empty tree, so the check takes in each page of HEAD. - The event
pull_request_targetchecks out the base branch, so it has no change to check. The step exits with 2, and it names the eventpull_request. - The last line names the base, for example “compared with the merge base of origin/main and HEAD”.
The option --base REF gives the base as the merge base of REF and HEAD. REF is a branch or a
commit. The option runs the same check outside CI, and it wins over CI. Write it as --base REF or
--base=REF:
uv run --no-project --quiet python .agents/skills/nossaifd/scripts/prose_gate.py check-changed --base origin/main- With names of pages, CI changes nothing, and it checks the named pages. The option
--basewith names of pages exits with 2. - A deleted page is not checked, also a page that the working tree deleted since the last commit. A page that the diff names but that a sparse checkout left off the disk exits with 2.
- A clone with part of the history exits with 2. Such a clone is called shallow. Its history is cut
off, so the base can be missing. A commit with a missing parent then looks like the first commit. Set
fetch-depth: 0onactions/checkout, so that the clone has the whole history. - A base that is missing, or a base with no merge base with HEAD, exits with 2. The check never passes with no page checked because of an error.
- It writes nothing in CI too.
Other tools can load the installed prose_gate.py by its path and call base_commit(root, option).
It gives the pair of the base commit and its name, or None and the error. Its name, its arguments
and its result stay the same. The same holds for ci_set(), which tells whether CI counts as set.
base_commit prints at most one line, a line that starts with nossaifd:.
Set sys.dont_write_bytecode before the load, so that Python writes no __pycache__ in the skill.
Who may write the map
The map names a program, and the hook runs that program at the end of each turn. So treat the map as
code, as you treat a hook in .claude/settings.json or a recipe of the Justfile.
- Only the people who look after the project write the map, and they review each change to it.
- The gate reads the map only from the root of the project. It does not read a map in any other folder, such as the folder of a page, of the skill or of the call.
- A change to the map shows. It shows in the diff of a pull request, and the messages of the gate name the new checker.
- The workflow runs on
pull_request. It runs the gate and the map of the pull request, with a token that can only read. Do not run it onpull_request_target, which gives the secrets of the repository to that code.
Beside the commit gates
A gate is a check that stops a commit when it fails. The commit gates of agent_gest_git_skills check each
commit. A project has the gates when its file .agents/stack.json turns on the tasker role. The tasker
role is the package of skills of agent_gest_git_skills. The hooks of this page make a turn gate. The turn
gate stays beside the commit gates, and it has a different job:
| Gate | When it runs | Its job |
|---|---|---|
| The turn gate, the hooks of this page | At the end of each turn | It asks early, at little cost. It blocks the end of a turn once |
| The commit gate | At each commit | It gives the final answer. A commit that changes a page needs a prose record and a pass of the step prose-check |
just prose. With the gates, the message of the hook that blocks a turn says “runjust prose”. The target gives the pages to a fresh agent, which is an agent that the harness starts for one task. The fresh agent does the plain-writing pass and the pass of the declaude skill by Oskar Austegard. Then it records each page that it passed, withprose_gate.py record. Its base task is.agents/skills/nossaifd/references/targets/prose.md.- The
proserecord. The steps of the skill, done by hand, record a page, so the hook lets the turn end. But a page pass is not aproserecord. The commit gate needs theproserecord of the tree, and onlyjust prosegives it. - The store of page passes. One store in
.git/nossaifdholds the passes, with or without the gates. So a page thatjust prosepassed in one worktree does not block a later turn in another worktree. - The rule for pages. The
@pagesof the commit gate take the pages fromprose_gate.py pages. The stepprose-checkrunsprose_gate.py check-changed, which keeps the pages by the same ruleis_page. So they use one rule with the hook, and they accept the same pages. A change toCHANGELOG.mdalone needs noproserecord.
prose_gate.py pages prints each path that is a page:
git diff -z --name-only --no-renames --diff-filter=AMT HEAD | uv run --no-project --quiet python .agents/skills/nossaifd/scripts/prose_gate.py pages -z
uv run --no-project --quiet python .agents/skills/nossaifd/scripts/prose_gate.py pages README.md AGENTS.md- The paths come from the arguments. With no path, they come from standard input, one on each line.
- With
-z, a NUL character ends each path, in the input and in the output. Use-zfor a path that can hold a newline. - Each path is relative to the root of the repository, as git prints it. An absolute path inside the repository is read as its path from the root of that repository. A symlink inside the repository is not followed.
- The output is each path that is a page, as written and in the order given. The command reads only
the names. It does not check that a file exists, so take out the deleted files first, as
--diff-filter=AMTdoes. - The exit code is 0, also when no path is a page. It is 2 for an unknown option.
- A path that starts with
-must come after--.
The workflow for GitHub
.agents/skills/nossaifd/assets/prose-check.yml goes into .github/workflows/ of the project. On each
pull request, it runs prose_gate.py check-diff. That command checks each page that the pull request
adds, changes or renames, with the checker of the page, and it skips the files that the hook skips. It
fails on a hard problem.
The workflow catches a page that a person edited without an agent. It cannot run the declaude pass,
because that pass needs a model. It needs the skill committed in .agents/skills/nossaifd/.
With the commit gates, just check runs the step prose-check, and the installer of jnterfaces removes
the workflow when the tasker role is installed. In CI, the recipe just prose-check checks the pages of
the pull request or of the push, as “The check in CI” says. So the step prose-check in CI catches a page
that a person edited without an agent. The job in CI must check out the whole history, with
fetch-depth: 0. A shallow clone makes the step fail with exit 2.
Install the parts
The file skill-package.json names the parts for an installer. The installer adds the instruction to AGENTS.md,
the hooks to .claude/settings.json and .codex/hooks.json, and the workflow. With npx, which installs
only the skills, copy the parts by hand:
- Add the lines of
assets/agents-prose.mdtoAGENTS.md. Claude Code readsCLAUDE.md, so make sure thatCLAUDE.mdholds the line@AGENTS.md, which importsAGENTS.md, or holds the lines too. - Merge
assets/claude-settings-hook.jsoninto.claude/settings.json. - Merge
assets/codex-hooks.jsoninto.codex/hooks.json. Codex runs the hooks of a project only when you trust the project. - Copy
assets/prose-check.ymlinto.github/workflows/.
The hook of Oskar Austegard’s skill, in the folder hooks of the declaude skill, is a different hook. It
works only when his skill is installed as a plugin, so it does not run here.