Memory and Handoffs
These three CLIs keep knowledge and progress across sessions. They do not inject their records automatically. Pi separately maintains a same-session task checkpoint, with retrievable raw history; it does not replace cross-harness handoffs.
,handoff โ task progress across sessions and harnessesโ
Use it when you stop in one harness and continue in another, or before a long break.
,handoff save auth-fix <<'NOTE'
Goal: โฆ
Decisions: โฆ
Approvals: โฆ
State: โฆ
Remaining: โฆ
Files: โฆ
Verify: โฆ
NOTE
,handoff list # this repo, newest first (--all for every repo)
,handoff show auth-fix # --prev for the previous version
- Notes live in
~/.local/share/agent-handoffs/<repo>/<topic>.md(override withAGENT_HANDOFF_DIR). <repo>is the main checkout's directory name, so all worktrees of a repo share one namespace; outside git it isglobal.- Saving keeps the previous version as
<topic>.prev.md. Notes over 4 KB save with a warning. - The
k-handoffskill tells agents what to write on "handoff X" and how to resume on "continue X": treat the note as a starting point and re-check the files and git state it names. Only the commit, push, and PR requests under the note'sApprovals:carry into the new session, and itsState:names the task's starting commit, the paths already changed when it started, and the path of anyk-reviewVerify baseline, so a later review and commit still separate the task's changes from the user's.
,behavior-map โ critical behaviors per repoโ
A short map of the behaviors a user or caller relies on, seen from their side. It replaces the old .mermaids/ file inventories:
entries name at most three code entry points ("anchors"), and agents find internals at runtime.
,behavior-map show # status line + index; `show <area>` or `show <id>` for full entries
,behavior-map save <id> < entry # write; keep the header line that `show <id>` printed
,behavior-map affected [paths] # entries and areas a planned or finished change touches; unmapped dirs
,behavior-map check # stale, broken, drifted, conflicting entries; merged or gone overlays
,behavior-map promote <branch> # merge a merged branch's overlay into the base map
Storage: ~/.local/share/k-ai-behavior-map/<repo>/ (override with AGENT_BEHAVIOR_MAP_DIR). <repo> is the main checkout's directory name; a checkout named main, master, or trunk (~/code/<repo>/main) uses its parent's name.
| Layer | Path | Written from |
|---|---|---|
| Base map | base/<area>/<name>.md | the default branch |
| Branch overlay | branches/<slug>/<area>/... | that branch, in any worktree |
| Fork copy of the base entry | <name>.base.md in overlay | the CLI, when a branch first edits an entry |
- One Markdown file per entry: YAML front matter (
id,status,anchors,verify,verified_date, optionalstates, and afingerprintthatsavecomputes) and a body ofTrigger:,Expect:,Must not:,Gotchas:lines. - Concurrent sessions: every write takes a repo lock;
savealso refuses when the entry changed since the session read it. showon a branch merges base and overlay.driftmeans the base entry changed after the branch started;stalemeans the anchored content changed since the entry was saved;brokenmeans an anchor no longer resolves.promotecopies unchanged-base entries, three-way merges the rest withgit merge-file, and keeps conflicts in.merge.mdfiles untilresolve.- An area owns the directories its entries claim with
dir/anchors; a file anchor claims only that file.affectedlists entries anchored to a changed file, whole areas that own one, and paths in no area. - The
k-behavior-mapskill owns the lifecycle. Before a code change it collects the change's impact list from source (what it can break: callers, keys, persisted forms, tests, docs, co-change history; for new or changed behavior, every domain and scope it must fit), runsaffectedon the list's repo paths, and maps an unmapped area first where it will edit or create a file (area init, at most 10 entries, saved unverified and verified by the update after the change; skipped for/tmpclones and read-only sessions). In Claude Code thebehavior-map-guardmod refuses the first edit in an unmapped directory and notes mapped entries an edit touches. After a Bash command that may write, it adds the same notes for the files the command changed (Claude mods). After the change the skill updates the listed entries. Repo-wide init, add, refresh, promote and resolve are the other modes.
,ai-kb โ durable, reusable knowledgeโ
A local knowledge base of short capsules with hybrid (BM25 + vector) search.
,ai-kb search "<literal identifiers or error text>" --limit 5 --json
,ai-kb remember --title โฆ --body โฆ --kind gotcha --scope project --workspace "$(pwd)" --source โฆ --confidence 0.9 --domain โฆ
,ai-kb get <id> --json
- Search when starting on a subsystem you may have touched before, or on an unfamiliar error. Treat hits as leads.
- Remember only verified, reusable gotchas and recipes with literal identifiers and a source; never task progress.
rememberrefuses title collisions and near-duplicates;--supersedes <id>amends a stale capsule in place.,ai-kb curatededupes and decays capsules; run it by hand when the store grows noisy.
The k-ai-kb skill holds the search and write rules; ~/.agents/skills/k-ai-kb/references/cli.md holds the flag contract.