Docs

Open source · runs in your repository

Say what the software should do. Your agent won’t forget why.

Kibi is a requirements framework for AI coding agents. It records the reasoning behind your code (the intent, assumptions and trade-offs you agreed in the chat) as requirements in your repository, links them to the code and tests, and makes every later agent respect them.

  • Keeps the why behind each change, not just the what
  • Shows the agent that reasoning before it edits the code
  • Refuses new rules that contradict old ones
  • Reports which requirements are actually tested
› Set up Kibi in this repository, then bootstrap its knowledge base.
Set up Kibi (https://github.com/Looted/kibi) in this repository, then bootstrap its knowledge base.

1. Install: confirm Node.js 22+ is available. With the package manager this repository already uses, add kibi-core, kibi-cli and kibi-mcp as dev dependencies. Do not skip optional dependencies; the bundled SWI-Prolog runtime is one.
2. Initialize: run every `kibi` command through the package manager's local runner (npm: `npm exec -- kibi <command>`). Run `kibi init`; if it reports a problem, run `kibi doctor` and fix what it names. If this platform has no bundled SWI-Prolog, tell me what to install and stop.
3. Connect: register the project-local `kibi-mcp` server for the agent host you are running in, following https://looted.github.io/kibi/guide/connect-an-agent.html. Prefer project-scoped configuration, and ask me before installing a plugin or changing global settings. Until the kb_* tools are visible to you, use Kibi's CLI JSON routes instead.
4. Bootstrap: run `kibi skills load kibi-bootstrap --format markdown` and follow that skill exactly. It starts by asking me where product intent lives outside the code (issue trackers, wikis, specs) and which sources to trust; read them through the connectors you have and cite them. Show me the complete plan and its hash, and write nothing until I approve it.
5. Verify: run `kibi check` and `kibi status`, fix anything they report, and summarize what was added. Do not commit; I will review the changes.

Each line is a requirement riding to the gate. Only fresh end-to-end evidence clears it.

  • intent
  • cleared the gate
  • waiting on evidence
  • contradiction

Plugins for the agents you already use

01The problem

Code shows what the software does. Not what it must keep doing.

In source, every line looks equally deliberate. A hard-won trade-off, a business rule, a temporary assumption, a shortcut and a forgotten leftover all read the same. The difference lived in the conversation where they were decided, and that conversation is gone. So the next agent either “cleans up” a decision or carefully preserves an accident.

billing.ts
export const TRIAL_DAYS = 14;
firm: ask before changingREQ-trial-length

A trade-off: shorter trials convert better, and we accept more churn.

export function canCheckout(cart) {
  return cart.total > 0;
}
firm: ask before changingREQ-checkout-total-positive

A business rule: never charge for an empty cart.

export const MAX_SEATS = 50;
exploratoryREQ-seat-cap

An assumption: holds until enterprise pricing exists. Revisit when this area is touched.

export function chargeWithRetry(order) {
  return retry(() => charge(order), { attempts: 5 });
}
defaultREQ-payment-retry

A shortcut: the payment provider drops webhooks. A later agent may rework it with evidence.

export function legacyDiscount(user) {
  return user.createdAt < CUTOFF ? 0.1 : 0;
}
no requirement owns this

Nobody recorded why. Kibi asks the agent to write down what it does before changing it.

Five pieces of code. Without the reasons, any of them could be a decision or a mistake.With Kibi, the reasons are written down, linked to the code, and shown to the agent before it edits these lines.

  • 01

    The why outlives the chat

    Without

    The chat said “we’ll do X to retain users”. The code only says X, and the next agent cannot tell a trade-off from a mistake.

    With Kibi

    Each requirement records why it exists, and decisions keep their trade-offs. They live in .kb/ beside the code on every branch, and Kibi flags requirements that do not say why.

  • 02

    Decisions stop getting undone

    Without

    The agent rewrites a rule it never knew existed.

    With Kibi

    Before it edits a file, the agent is shown the requirement that code implements, what it must keep true, and the decision behind it.

  • 03

    Conflicts are caught before the code

    Without

    Two prompts a week apart contradict each other, and nobody notices.

    With Kibi

    A rule that contradicts an existing one is refused with both named, and you decide which wins.

  • 04

    “Done” means tested, not claimed

    Without

    Green CI does not say which product behavior still works on this commit.

    With Kibi

    The health report shows which requirements have fresh end-to-end evidence, which rest only on someone’s word, and which have gaps.

02Why not a memory file

Memory remembers. Kibi enforces.

Notes files and memory servers help an agent recall things. Kibi turns intent and its reasons into rules that are linked to code, checked for contradictions, put in front of the agent at edit time, and backed by evidence.

Project memory
Kibi
The why behind the code
Sometimes, somewhere in prose.
Every requirement records why it exists and decisions keep their trade-offs. A requirement that does not say why is flagged.
What it holds
Free-text notes the agent wrote or you pasted.
Typed requirements, scenarios and facts, linked to the functions that implement them and the tests that check them.
When the agent sees it
When it remembers to look, if the note fits in context.
Automatically, before it edits code a requirement owns. Hooks put the rule in front of the agent.
Two rules that conflict
Both are kept. Whichever the agent reads last wins.
The new rule is refused, checked against typed facts, not text similarity, with both rules named.
Changing a decision
Anyone can overwrite a note, silently.
A firm decision changes only with your words, and every replacement records why.
Code with no rule
Invisible.
A changed function that no requirement owns is flagged, so the agent records what it does.
Is it still true?
Unknown.
Each requirement is labeled proved, tested, asserted or unverified from fresh evidence on this commit.

Watch Kibi check an agent’s work

› Sessions must expire after 30 minutes idle. kb_upsert REQ-session-idle-timeout ✓ saved› Remember me keeps users signed in for 30 days. kb_upsert REQ-session-remember-me ✗ refused Contradicts REQ-session-idle-timeout session idle timeout: ≤ 30 min vs ≥ 30 days Nothing was written. A person decides which rule wins.

Simplified from what Kibi reports in each case.

03How it works

From prompt to proof, on one rail

Kibi keeps intent attached to the work at every stage, and it is conservative about the last one.

  1. Intent

    You say it once

    Prompt the behavior in plain words, the way you already do. That sentence stays the source.

  2. Requirements

    The agent writes it down

    Requirements, scenarios and typed facts land in .kb/ beside the code, citing the ticket or page they came from.

  3. Enforcement

    Every edit hears it

    Hooks name the requirement before an agent edits the code that implements it. Checks flag contradictions and untraced code.

  4. Evidence

    Tests leave receipts

    A test that claims a requirement records evidence tied to the exact code snapshot it ran on.

  5. Proof

    Only fresh evidence passes

    Stale receipts and passing unit tests do not clear the gate. Proved is reserved for claims a checker established for every case.

04Your part

What you actually do

Three things, and none of them is filling in a requirements form.

  1. 01

    State the behavior

    Prompt the way you already do. “Draft edits must save when someone navigates away.” You do not fill in a requirements form.

  2. 02

    Approve real decisions

    The agent proposes a plan before it writes project knowledge. You approve it, or you correct the product call. A plan compiled from your prompt lands in full or not at all, and the bookkeeping stays with the agent.

  3. 03

    Read the result

    The health report names what is tested, what still has a gap, and what contradicts itself, and labels each requirement proved, tested, asserted or unverified. A green test run is a different fact.

05Setup

Add Kibi to the repository

Kibi is driven by your coding agent, so the recommended setup is a prompt. Your agent installs the packages, runs kibi init, connects itself to Kibi, and bootstraps the knowledge base behind a plan you approve, then adds scenarios, predicates and the claims the plan could not write in the normal workflow, and proposes how proof runs for your test runner in a second plan you approve. The package-manager tabs are the manual route; re-running kibi init completes missing directories and schema files while preserving existing knowledge and schema files. It does not invent what the product does.

The agent first asks where your product intent lives, such as issue trackers, wikis and specs, and which sources to trust. Every requirement in the bootstrap plan cites the ticket or page it came from, and nothing is written until you approve the plan. When a claim sits next to an existing requirement on the same topic that Kibi cannot check logically, the plan names that requirement so the agent compares the two, including for claims the plan leaves for the agent to write. How plans are built, applied and resumed after an interruption is in the MCP reference.

prompt
Set up Kibi (https://github.com/Looted/kibi) in this repository, then bootstrap its knowledge base.

1. Install: confirm Node.js 22+ is available. With the package manager this repository already uses, add kibi-core, kibi-cli and kibi-mcp as dev dependencies. Do not skip optional dependencies; the bundled SWI-Prolog runtime is one.
2. Initialize: run every `kibi` command through the package manager's local runner (npm: `npm exec -- kibi <command>`). Run `kibi init`; if it reports a problem, run `kibi doctor` and fix what it names. If this platform has no bundled SWI-Prolog, tell me what to install and stop.
3. Connect: register the project-local `kibi-mcp` server for the agent host you are running in, following https://looted.github.io/kibi/guide/connect-an-agent.html. Prefer project-scoped configuration, and ask me before installing a plugin or changing global settings. Until the kb_* tools are visible to you, use Kibi's CLI JSON routes instead.
4. Bootstrap: run `kibi skills load kibi-bootstrap --format markdown` and follow that skill exactly. It starts by asking me where product intent lives outside the code (issue trackers, wikis, specs) and which sources to trust; read them through the connectors you have and cite them. Show me the complete plan and its hash, and write nothing until I approve it.
5. Verify: run `kibi check` and `kibi status`, fix anything they report, and summarize what was added. Do not commit; I will review the changes.

Requires Node.js 22+. SWI-Prolog is bundled on Linux (x64, arm64) and macOS; other platforms need swipl (SWI-Prolog 9.0+) on your PATH. A system swipl is only a fallback; set KIBI_SWIPL=system to prefer it. Bun commands and per-platform setup are in the installation guide. Each release has one version, such as Kibi 2026.11.0, that names its exact package set; kibi --version and kibi doctor show it (release versions), and the CLI tells you once a day when a newer one is out (update notices). Kibi sends anonymous usage statistics; see what is sent and how to turn it off.

06Docs

Where to go next

07FAQ

Questions people ask first

The short answers. The guide has the long ones.

Do I write the requirements myself?

No. You describe the behavior. Your agent turns that into requirements, scenarios, tests, and links to the code. You step in when the product decision is actually ambiguous.

Does this replace my issue tracker?

No. Keep the tracker you have. During bootstrap the agent asks which trackers, wikis, and specs hold your product intent, reads them through its own connectors, and cites the ticket or page behind each requirement. Kibi then connects that decision to the code that implements it, and to evidence that the code still does it.

Which languages does Kibi understand?

TypeScript and JavaScript work out of the box. Add the optional kibi-plugin-treesitter package for Python, Go, Rust, Java, C#, PHP, C, C++, Bash, Ruby, SWI-Prolog, and Terraform/HCL. It runs offline with pinned grammars, and each language is a small kibi-lang-* pack you install only if you use it. Generated files don't count toward a pack or need requirement links unless the KB uses them, and you can decline any pack. Code and source proofs read TypeScript, JavaScript, Python and SWI-Prolog directly, and through the plugin, source proofs read the imports, calls and environment reads of Go, Java, C#, Rust, PHP, C and Bash files, and the property values of PHP, C and Terraform/HCL files, without compiling them. Setup is in the plugin reference.

Can Kibi stop agents drifting from our UI design?

Partly, and only if you opt in. The experimental kibi-plugin-ui package, which /kibi-bootstrap offers when it finds React or Angular components, makes kb_check require every component to implement a design requirement, and flags a component that loses the class names or test ids that mark its agreed pattern. That catches an agent rewriting a timeline as cards. It cannot see pixels, colours or spacing; those stay with your linter. Details are in the plugin reference.

Can my agent ask Kibi what governs a change?

Yes. kb_search accepts a plain question and, alongside ranked matches, returns the current requirements that govern the topic with their linked facts, scenarios, tests, and ADRs (with an excerpt of each decision). For each requirement it also reports any contradiction or infeasible-scenario finding that names it, the approved exceptions that exempt it, and what the checks could not decide, and it names the branch and KB snapshot the answer came from. On a new branch whose store was never compiled, the answer says so and points at kibi sync instead of returning a silent empty result. Superseded and retired requirements are listed separately so they are not read as current policy, and a top match that no requirement owns is named as such rather than dressed in lower-ranked requirements. No finding is not proof: full consistency and proof status still come from kb_check, which also says which rules it evaluated and how many fact pairs it compared, and kb_coverage. The answer is ten rows by default, and on Claude Code it is sent once, as structured content with a short text summary rather than a second JSON copy in the text.

Can my agent ask a precise question instead of searching?

Yes. kb_query asks the modeled facts directly, without the agent writing Prolog: {predicate: "permission_rule", where: {actor: "admin"}} returns each rule with its allow or deny effect, {predicate: "has_role", where: {user: "alice"}, distinct: "role"} counts a user's roles, and {subjectKey: "user.role_assignment", propertyKey: "max_roles"} returns a limit with its operator and value. {factKind: "predicate_schema"} lists the predicates and argument names the project models, an unknown argument name comes back with the declared ones, an empty answer lists the values that do exist, and every answer names the next call to make. The facts that kb_search links to a requirement carry the same typed claim and the query that asks about it, and {id, includeBody: true} returns a requirement's authored body so a stale sentence in it can be corrected.

Can my agent check a rule before writing it?

Yes. kb_upsert with dryRun: true runs the validation a real write runs, including the contradiction check for a requirement, and with plannedFacts it stages the facts kb_model planned, so an allow rule that would contradict a stored deny on the same actor, action and resource is refused before either is written, with the conflict named. kb_model also returns such a grounding as a hash-bound plan: its contradiction analysis is computed over the current knowledge base, a conflict leaves the plan blocked, and a clean plan writes the fact and its link in one kb_apply_plan call, all or nothing. kb_delete also takes dryRun: true, and deleting an authored entity first returns a hash-bound plan with the exact kb_apply_plan call that applies it.

What happens when an agent edits code a requirement owns?

With the Claude Code, Cursor, Codex, ZCode, or OpenCode plugin, the pre-edit hook (OpenCode: the edit prompt) names the requirement the file implements, what it must keep true (from its linked facts), and the decision behind it (its ADR), before the change is made. With the Claude Code plugin this also covers edits the agent makes through shell commands, which get the same context right after the command runs. A superseded or retired requirement is not shown as current. Afterwards kb_check, scoped to the changed files, names any changed function in a file no requirement owns, so the agent records what it now does without being asked; it quotes the statement and firmness of each requirement the changed code implements, and opens with "no structural violations" rather than "no violations", because it never compares code with a requirement's prose; for a file with no linked symbols, both the hook and the check name the requirements whose titles share the file's path words, so "nothing linked" is not read as "no rule applies"; and reports conflicts it can decide, such as an allow and a deny for the same actor, action and resource, and says when an analysis is incomplete instead of calling it clean. A scenario that assumes something a current requirement forbids, on its own or only in combination with its other assumptions, is flagged and blocks proof. Conditional requirements count: "checkout may happen only when the cart total is positive" becomes a typed rule, and a checkout scenario with a zero total is flagged unless a human approved an exception for it.

Does Kibi work on a CI checkout or a detached commit?

For reading, yes. On a commit no single branch points at, such as a CI checkout of a SHA or a bisect, search, query, status, check, coverage, and graph answer from a read-only snapshot compiled from that checkout, and every answer says so. Writes are refused until you check out a branch or set KIBI_BRANCH. Details are in the CLI reference.

How do I tell what the agent wrote from what I approved?

Each entity can record its origin: written by a human, an agent, a migration or an import, and who approved it. New entities from your agent are marked as agent-written. kb_check lists agent-written requirements nobody has approved, exceptions whose approval only the agent recorded, and requirements that do not say why they exist. Kibi cannot confirm that a person approved something. It shows you what still needs your review.

Requirements and ADRs also record how firmly they were decided. A rule you stated is firm and points at your words; only another firm decision can replace it, so the agent is told to ask you first, and the agent cannot reword it in place unless it cites your new words. Kibi checks that the reference is there, not that you really wrote it. A choice you delegated, or one the agent made, is default: a later agent may replace it when it has evidence, and every replacement must say why it changed. A guess is exploratory. A rule with no firmness counts as firm unless the agent wrote it, and bootstrap marks the rules it imports from your documents as firm. When your request conflicts with any recorded rule, the agent names the rule and asks before changing it. Search results and the edit hooks show which is which.

What counts as tested, and what as proved?

A requirement is tested only when a test that claims to verify it has fresh end-to-end evidence for the current code. A passing unit test, a coverage percentage, or an old receipt does not count. The one exception is a requirement that only names a UI pattern, such as "this list is a line-and-dots timeline in both views": an isolated component test with a fresh receipt covers it, because rendering the component shows everything the requirement says. Freshness is computed from repository-relative paths and file contents, so CI and your own checkout of the same commit agree on what is tested. Tests sample cases, so tested is not proved: Kibi reserves proved for a claim a checker established for every case, with a certificate a second program can re-check. Certificate proof kinds cover enumerated domains, type-level checks, arithmetic and solver constraints, rules, state machines (including states that can never be reached and states every path must pass through), patterns, and the project's own routes, database schemas, configuration and code references, which Kibi reads itself. A requirement no current test checks is asserted when a person stands behind it and unverified when only an agent does.

Will Kibi decide the product for me?

No. kibi init creates the directory and the Git hooks; it leaves hooks it did not write alone, and with lefthook, husky or the pre-commit framework it installs none and prints the configuration to add (kibi init --print-hook all --format lefthook). It also tells agents in a fresh clone about Kibi through AGENTS.md, installs the hooks again from the package.json prepare script, and compiles a clone's store on its first query. What it commits is what you and the agent authored: symbol line positions are derived by every sync into a gitignored cache, so parallel branches do not conflict over them. It does not infer behavior. Checks prove what was encoded. Missing knowledge stays visible.

This repository publishes its own report

Every push to the default branch republishes requirement health for Kibi itself: how many current requirements are fully tested end to end, which ones rest only on someone's word, which ones contradict each other, and which evidence has gone stale.

Tested means fresh end-to-end evidence on the current code snapshot.
Open the live report

Start with one prompt.

Paste the setup prompt into your agent, approve the plan it shows you, and read your first health report.

Prompt the intent. Kibi makes the agent remember it—and prove the implementation.