agent-wisdom
Conditional wisdom for AI agents: advice that says when it applies, when it fails, and what the opposite advice is.
agent-wisdom is a small read-only command, wisdom, over a folder of Markdown files. Each file is one entry: a claim, the situation where it holds, the situation where it fails, and the opposite advice with the observable cue that chooses between the two. An agent about to commit, open a pull request or merge runs wisdom lookup "<situation>" and gets back at most three entries, or none. The match is plain keywords: no model, no embeddings, no network, the same answer every time. It has one runtime dependency, yaml.
Why it exists
Agents record plenty of concrete lessons ("this repo's tests need a build step first"), but almost none of that becomes judgment they can apply to a new situation. And advice without conditions is a trap: "test first" and "ship fast" are both good advice, and an agent that has only read one of them cannot tell when it is wrong. A conditional entry makes the agent check fit before it acts, and "no match" is a first-class answer, so the store never pads a bad guess into the context.
Install
npm install -g agent-wisdom # Node 18 or newer
wisdom --help
60-second quickstart
The repository ships a small synthetic store in examples/store. From a clone (or from the installed package's examples/ folder):
export WISDOM_DIR=examples/store
wisdom validate --strict
# 8 file(s) checked: 0 error(s), 0 warning(s)
wisdom lookup "about to commit a change to one module" --point commit --no-log
# w-narrow-test-first [technique, score 5] Run the narrow test before the full suite
# applies: a change touches one module and its own tests are quick to run
# fails: the change alters shared fixtures, build configuration, or a public interface other modules use
# opposite: Run the full suite first (w-full-suite-first)
# cue: shared fixtures or build configuration changed
#
# w-small-focused-commits [technique, score 5] Keep each commit to one logical change
# ...
wisdom lookup "quantum chromodynamics" --no-log
# no matching entry
Read the first result the way an agent should: does applies describe my situation? Does fails describe it instead? If the cue holds, follow the opposite. Then start your own store: create ~/.agent-wisdom/techniques/w-my-first.md (see below) and run wisdom validate.
The entry format
One Markdown file per entry, <layer>/<id>.md. The layer is core/, values/, techniques/ or precedents/.
---
id: w-narrow-test-first
kind: technique
claim: Run the narrow test before the full suite
applies_when: a change touches one module and its own tests are quick to run
fails_when: the change alters shared fixtures, build configuration, or a public interface other modules use
opposite:
text: Run the full suite first
cue: shared fixtures or build configuration changed
entry: w-full-suite-first
triggers: [commit, review]
tags: [testing, commit]
sources:
- { kind: lesson, ref: example-lesson-3, task: example-task-1 }
- { kind: notebook, ref: example-shelf-3, task: example-task-2 }
- { kind: correction, ref: example-review-3, task: example-task-3 }
status: active
created: 2026-01-10
updated: 2026-01-10
---
Optional prose: the reasoning, an example.
An active technique or value should have at least 3 sources from at least 2 different tasks; validate warns when it does not, and --strict makes that an error.
Entries can link to each other by id: opposite.entry, supersedes (this entry replaces older, retired ones), and on a precedent winner/loser, distinguishes (narrows an earlier draw or open ruling) and dissent. A value entry can name the value it serves with promotes. validate checks that every link points at a real file, that there are no cycles, and that a superseded entry is retired; wisdom graph draws them. The full schema is in docs/entry-format.md.
Commands
| Command |
What it does |
wisdom validate [--strict] [--json] |
Checks every entry. Exit 1 on errors; --strict makes warnings errors. |
wisdom list [--layer L] [--status S] [--json] |
One line per entry. The claim is cut to 100 characters (--json is not). |
wisdom show <id> [--json] |
One entry in full. Exit 1 on an unknown id. |
wisdom lookup "<situation>" [--point P] [--limit N] [--role R] [--task T] [--repo R] [--json] [--no-log] |
Keyword match over active entries and all core entries, less any entry a served entry supersedes. At most 3 results, possibly none. Skips entries that fail validation and says so on stderr. |
wisdom graph [--around <id>] [--hops N] [--format mermaid\|json] [--json] |
The links between entries and precedents (opposes, decides, supersedes, distinguishes, dissent) as a Mermaid flowchart or JSON, built in memory from the files. --around keeps what is within N links (default 1, at most 3). Exit 1 on an unknown id. |
The store is $WISDOM_DIR, else ~/.agent-wisdom. lookup appends one line to <store>/lookups.jsonl (task from --task or $WISDOM_TASK, repo from --repo or $WISDOM_REPO); it fails open and --no-log turns it off. Nothing else is ever written. Exit codes: 0 success (including no match and an empty graph), 1 a validation error or unknown id, 2 a usage error.
How this differs from agent-notebook
agent-notebook is the sibling project: a bounded memory of one-line lessons ranked by votes. It answers "what did we learn that I might forget?" and it surfaces lessons by listing them. agent-wisdom answers a different question, "what general judgment applies at this decision, and when does it not?". Its entries are conditional (claim, applies, fails, opposite with a cue), they are not voted (quality is argued through conditions, precedents and independent sources), and they are looked up at decision points. They are complementary: a notebook lesson is a good source for a wisdom entry.
Using it from an agent harness
Put the contract in AGENTS.md in front of your agent, and optionally run the lookup from a hook at git commit and gh pr create. See docs/harness-setup.md (Claude Code and Codex, with Kookr as one worked example).
Documentation
- Getting started — the plain-language guide.
- Entry format — every field, with examples.
- Harness setup — wiring
lookup into Claude Code and Codex.
- Rationale — why not a vector database, a graph database, or agent-notebook's format.
- Requirements — the specification, design principles and non-goals.
- AGENTS.md — the operating contract for agents; CONTRIBUTING.md; SECURITY.md; CHANGELOG.md.
License
MIT. See LICENSE.