Okl – hold your agent to rules proven by checks and gated at push Emeraldleaf released okl (Observed Knowledge Ledger), a CLI installed via `pipx install 'observed-knowledge-ledger[mcp]'` that briefs AI coding agents on a repository's conventions, architecture decisions and checks before each task and gates pushes when the files those lessons govern drift. The tool requires Python 3.10+ and git for drift detection, is tested on macOS and Linux with Windows untested, seeds the store with 20 starter lessons plus stack-specific packs, and wires Claude Code hooks, an MCP server and a pre-push drift gate through `okl init`, with an opt-in GitHub Actions workflow available via `--ci`. Guardrails and a learning loop for AI coding agents. Engineering rules, architecture decisions, documentation and diagrams: recorded once, briefed to your agent before every task by a hook in Claude Code; any MCP agent can ask for the same briefing , proven by checks you choose, and flagged before you push or in CI when what they govern changes. Each session's lessons are fed back in. Use it in one repo, or share one store across every repo your team runs. πŸš€ Quickstart quickstart Β· πŸ“˜ Getting started guide https://github.com/emeraldleaf/okl/blob/main/docs/GETTING-STARTED.md Β· πŸ”¬ How it works how-it-works Β· πŸ“Š Results measured-effect-and-its-limits Β· πŸ§ͺ Eval report https://github.com/emeraldleaf/okl/blob/main/evals/REPORT.md Β· 🧩 Plugin install-as-a-claude-code-plugin A small store of what a codebase knows β€” its conventions, architecture decisions and why they were made, the checks that catch mistakes already made once, and the claims its docs and diagrams make β€” plus a hook that hands the relevant ones to a coding agent or a person before they start a task. Each session can record what it learned, so the store grows with the work; it survives past a session and can be shared across a team. And it stays true: an entry is verified by running a check, and flagged when the files it governs change, whether those are code, docs or diagrams. New here? docs/GETTING-STARTED.md https://github.com/emeraldleaf/okl/blob/main/docs/GETTING-STARTED.md walks through setup, the habit of adding to the canon as you build a feature, and keeping your docs from drifting. Already have a CLAUDE.md , ADRs, standards or specs? Load your rules https://github.com/emeraldleaf/okl/blob/main/docs/LOAD-YOUR-RULES.md shows how to load them, prove the ones that matter, and keep them current. 1. Install the CLI the PyPI name differs β€” PyPI refuses okl as confusable with oki β€” but everything you type afterwards is okl : pipx install 'observed-knowledge-ledger mcp ' Needs Python 3.10+ and git for drift detection . Tested on macOS and Linux. Windows is untested : the core should work, but the Claude Code hooks likely need fixes there 85 https://github.com/emeraldleaf/okl/issues/85 . 2. Wire your repo. From the repository root: okl init --repo my-repo --dry-run lists every file it would write; writes nothing okl init --repo my-repo config, Claude Code hooks, MCP server, pre-push drift gate, starter lessons init detects your stack .csproj , package.json , pyproject.toml … , sets the repo's interests from it, and fills the store with 20 starter lessons that hold on almost any codebase plus the bundled packs for your stack, so the first prompt is already briefed --interests chooses your own subjects; --no-seed leaves the store empty . init wires Claude Code when the repo has a .claude/ directory or claude is on your PATH; --claude forces it and --no-claude skips it. Drift is gated locally by default: in a git repository init installs a pre-push hook that runs the drift gate and blocks a push only when lessons have drifted --no-git-hook skips it . The GitHub Actions workflow is opt-in, because it spends a private repo's minutes and does nothing on another CI: --ci installs it instead of the hook, unless an earlier init already installed the hook, which stays --ci --git-hook gives both , for a team that wants a gate git push --no-verify cannot skip; a repo an earlier okl gave the workflow keeps it. Later runs remember both choices. Prefer the plugin? Install it before running init β€” /plugin marketplace add emeraldleaf/okl , then /plugin install okl@okl in Claude Code β€” and init leaves the hooks to the plugin, so nothing is wired twice. Installed after? okl doctor reports the double wiring; run okl init --uninstall , then okl init again, which leaves the Claude Code hooks to the plugin and reinstalls okl's pre-push gate; where another tool owns the pre-push hook, init prints the one line to add to it instead. 3. Add a rule of your own. The starter lessons are generic; what pays is what only your codebase knows. Tell your agent β€” "record an okl rule for this repo: order lookups are scoped to the signed-in customer; governs app/orders.py" β€” and it records the lesson with okl's okl record MCP tool in Claude Code, /record drafts it and asks you first . Underneath, that is one CLI call you can also run yourself: okl record --type Rule --scope repo --id order-owner-scope \ --title "Order lookups are scoped to the signed-in customer" \ --symptom "an endpoint fetches an order by id with no owner filter" \ --fix "filter by the caller's customer id in the query; return 404 on no match" More: okl seed lists every bundled pack; /seed-from-docs has your agent propose cited records from the rules, ADRs, standards and specs you already wrote, and /seed-from-codebase from your own code. Both come with the Claude Code plugin or okl scaffold . Seed it seed-it-so-the-very-first-check-returns-something . 4. Check it works: okl check --task "add an endpoint that returns an order for the logged-in user" okl doctor flags other memory tools, double wiring, and where drift is gated - You prompt as usual. The pre-task hook runs okl check on what you typed and puts the relevant lessons in the agent's context before it starts, and shows you one line β€” okl Β· briefed 9 lesson s : … β€” so you can see it working OKL QUIET=1 hides it . - When you learn something worth keeping β€” a decision, a convention the agent broke, a bug you fixed β€” say so and the agent records it okl record , or okl record , with the files it governs. In Claude Code the Stop hook also asks once, at the end of a session that changed files, what was learned, and names the lessons the session was briefed on and those whose files it changed, so the agent can propose correcting or retiring one you approve . - Using another agent? The briefing and recording are MCP tools okl mcp ; register them and add one line to your AGENTS.md : before each task call okl check . The hooks that do this automatically are Claude Code's; see Getting started https://github.com/emeraldleaf/okl/blob/main/docs/GETTING-STARTED.md using-another-agent . - When a lesson needs correcting, take its id from the briefing and change only what is wrong: okl update