Release

S37 Learning Loop

The S37 Learning Loop keeps the corrections you give your AI agent and checks whether each one changed what the agent does.

Version 0.1.0 By Joshua Shane AGPL-3.0, Apache-2.0 and CC BY-SA 4.0

← All releases

01 / what it is

Part 1

The learning loop

Keeps the corrections you give Claude Code, Codex or Gemini CLI as lessons. It shows you, session by session, whether each one is holding.

Part 2

Night Watch

Checks the loop’s own setup when a session starts, at most once a day. It repairs what is safe to repair inside its own files and lists the rest for you to approve. It comes with the loop.

Every lesson with a stake is watched against your agent’s real tool calls, and the session line says whether it is holding or has recurred. Night Watch counts a repair as fixed only when a separate check proves it worked.

Before you rely on it, read the limits below.

02 / who it’s for

You have an AI-assisted document

If you have a document an AI helped produce and you are about to act on it, that’s the Verification Kit’s job. The installer here offers to fetch it.

You want your corrections to hold

Install the learning loop in Claude Code, Codex or Gemini CLI. Night Watch comes with it.

03 / requirements and install

The loop installs in Claude Code, Codex and Gemini CLI, and needs bun. It has been checked in live sessions in Claude Code and Codex, and in Gemini CLI only as far as install. Without bun, the loop checks nothing, and the session-start hook says why.

The loop’s checks are code, so they work the same whichever model your agent uses. /lesson ($lesson in Codex), which turns your correction into a lesson, is instructions the model follows, so it is designed for the top tiers of models as of October 2026. Smaller models such as Claude Haiku 4.5 aren’t supported.

Technical detail

Requirements

What you need

The loop installs into Claude Code, Codex or Gemini CLI.

The learning loop and Night Watch need bun. Without bun, the loop’s hooks let every call through and the session line says why.

Gemini CLI needs the installer run from a clone of the repository.

Supported models

Models

The loop’s hooks, Night Watch and the s37 command are code. They work the same whichever model your agent runs.

/lesson is a set of instructions the model carries out, so how well it works depends on the model. It’s designed for the top tiers of models as of October 2026.

Smaller models such as Claude Haiku 4.5 aren’t supported. The loop’s live checks recorded the agent’s version, not the model, so no model is claimed.

Install

You need a Mac or Linux computer and one of Claude Code, Codex or Gemini CLI. The loop also needs bun, a free tool it runs on. If bun is missing, the installer stops and tells you how to get it.

  1. Copy the repository to your computer from GitHub.
  2. In that folder, run sh install.sh. It finds your agents and installs the loop into each one.
  3. When it asks whether to install the S37 Verification Kit too, the answer defaults to yes.
  4. If you use Codex, open /hooks once and trust the two s37 hooks. Codex skips them until you do.
  5. Start a new session. You’ll see one line from s37 at the top. The next time you correct your agent, type /lesson to keep the correction, and /lessons to see which ones are holding. In Codex they are $lesson and $lessons.

To remove it, run sh install.sh --uninstall. Your lessons are kept. They stay on your computer, private to your user account, and nothing is sent anywhere.

Technical detail

From a clone of the repository:

sh install.sh             # the loop, in each agent it finds; then it offers the Verification Kit
sh install.sh --no-kit     # the loop only
sh install.sh --uninstall  # remove the loop from each agent; your lessons are kept

What the installer does:

  • It looks for Claude Code, Codex and Gemini CLI on your PATH, and installs the loop into each one it finds. If it finds only Kimi Code, it says the loop isn’t available for Kimi and where the Verification Kit is. If it finds none of them, it stops.
  • Each agent does its own installing, through its own plugin or extension commands. The script never edits an agent’s settings, and uninstalling leaves nothing of ours in them.
  • Then, unless you pass --no-kit, it asks whether to install the Verification Kit too. The answer defaults to yes. It clones the Verification Kit into ~/.local/share/s37/s37-kit (under $XDG_DATA_HOME instead, if you set it), or updates it there if it’s already there, and runs the Verification Kit’s own installer. That folder is kept. If the clone fails, it prints the two commands to run yourself, and the loop is still installed. Nothing is piped from the network into a shell.
  • --uninstall removes the loop, not the Verification Kit. It prints how to remove the Verification Kit, after which you can delete that folder. It never deletes the folder itself.
  • The loop needs bun. Without it, the installer stops and tells you how to get it.
  • Gemini CLI is installed only when you run the script from a clone. Gemini asks you to trust the folder it installs from.
  • In Codex, open /hooks once and trust the two s37 hooks. Codex skips new plugin hooks until you do.
  • Run from a clone, it records Night Watch’s baseline (s37 init). Otherwise the first session start records it.
  • Your lessons, the event log and Night Watch’s reports are kept in ~/.local/state/s37-system/, private to your user account. Nothing is sent anywhere.
  • The loop finds your home folder from the system’s user database, not from the HOME setting, so an agent can’t point it at a different state folder. A side effect: setting HOME doesn’t isolate an install. To test the loop apart from your everyday setup, use a separate user account.

Start a new session afterwards. You’ll see one line from s37 at the start of each session.

Then keep your first correction with /lesson, and see what’s holding with /lessons.

View on GitHub

04 / roadmap

These are plans, and they will change. None of it is built yet; what gets built, and in what order, follows what testing and use show matters most.

Changes need your say-so

Changes to the loop’s rules and files would need you to approve them in person, with Touch ID or an Apple Watch, and any change made without approval would be reported.

Night Watch for your whole setup

Today it checks only the loop’s own files. Next: your skills, instruction files, hooks and MCP settings.

Night Watch on a schedule

An optional schedule, so it runs even on days you don’t start a session.

Approvals tied to what you approved

Not only to you being there.

More agents

The loop in Kimi Code, configuration locations shared across agents, and a live check in a Gemini CLI session.

Standing facts as their own kind of lesson

With their own place at session start, so a fact that never recurs isn’t the first thing left out.

A clock on lessons that keep recurring

When a lesson keeps recurring in observe mode, after a set time one prompt asks you to enforce it, edit it or drop it.

A paired test for each lesson

The same task run with and without the lesson’s rule, with a fixed pass check, so you can see whether a capture-only lesson changes anything on the model you run.

05 / limits

It measures only what the agent does. A mistake counts only when it shows up as something the agent does, such as a command or a file edit. A correction about reasoning, tone or judgement is kept and given to your agent each session, but isn’t measured.

It watches before it blocks. A new lesson starts in observe mode: a repeat is logged and allowed. A lesson blocks only after you switch it to enforce.

Where it runs. Claude Code, Codex and Gemini CLI. Not Kimi Code.

Night Watch checks the loop’s own setup. It doesn’t yet check your other skills, instruction files or settings, and it repairs only the loop’s own files.

Holding means no repeat was seen. The loop can’t tell a lesson the agent has learned from a situation that hasn’t come up again.

The check on changes to your lessons matches text. A path or verb hidden in a variable or an encoding gets past it. Deleting the event log and disabling the plugin aren’t checked.

It isn’t a sandbox. It governs only sessions that load it. If its own hook fails, the call goes through and the error is logged.

Tested on macOS and Linux. Not Windows. Hands-on testing is by the author, Joshua Shane. J. Scott King reviewed it. Each release also gets an automated release test in Claude Code and Codex, kept private and available on request.

Saving a lesson in Codex. The command is $lesson. In a headless Codex run (codex exec) it isn’t available, and in an interactive Codex session it hasn’t been checked live yet. You can always save a lesson yourself: when a save is stopped, the agent gives you the complete command to paste into your own terminal.

Every limit we know of is listed in the README’s Limits section.

06 / testing
42 of 42 rule sites caught 24 defects fixed as classes Report dated 2026-11-13

The test report is generated for each release from the repository itself. The current report is dated 2026-11-13. It shows no failing tests on Linux or macOS. A later change isn’t covered until the report is regenerated.

Linux

CI results

258 pass, 1 skip, 0 fail. 11 install lifecycle tests in Claude Code, Codex and Gemini CLI.

macOS

CI results

259 pass, 0 skip, 0 fail. 11 install lifecycle tests in Claude Code, Codex and Gemini CLI.

Mutation testing

Rule coverage

Every rule site is disabled alone, and a test must fail. 42 of 42 rule sites were caught.

Why tests were skipped

Live checks

Some checks need a real agent session with a model behind it, so they can’t run in CI. They were run by hand and recorded with the agent’s version.

What testing caught

Testing caught 24 defects since the class-fix gate began on 2026-09-24. Each was fixed as a class, with a test that now guards it. One example: the loop’s state folder and files are now private to your user account.

The test report ships with the repository.

07 / licence and authorship

Copyright Joshua Shane, for the components he authored.

Licences are assigned by artifact type. The learning loop is AGPL-3.0. The installer, scripts, tests and other code outside the learning loop are Apache-2.0. Content is CC BY-SA 4.0.

Attribution means crediting Joshua Shane for his components.

J. Scott King’s S37 Synthesis Ladder is a separate release with its own repository and terms. Nothing of his is in this package.

View on GitHub