mb

A command for keeping a project's long-term notes, code understanding, and work context in a `.memory-bank` folder.

In plain words
What is it for?
Use it to collect context, search code, inspect dependencies and test coverage, and maintain the project's memory files.
Why use it?
It helps an agent recover project knowledge instead of starting from scratch or relying only on the current conversation.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/fockus/skill-memory-bank/mb
Clone the repo
git clone --depth 1 https://github.com/fockus/skill-memory-bank
Per session 8 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 23,303 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00008 $0.23303
Opus 5 $0.00004 $0.11652
Sonnet 5 $0.00002 $0.04661
Haiku 4.5 $0.00001 $0.02330

Measured 3d ago against content hash 70a7bb20ea25, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

mb scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

| `statusline [--force]` | Claude Code only. Install the context-window statusline (`% of context filled` + model · branch · project) by running `scripts/mb-statusline.py --install`, which patches `~/.claude/settings.jso
commands/mb.md · 1,661 lines

How it starts

The opening of the file, as written. The whole thing — 1,661 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Memory Bank — /mb

The /mb command is the single entrypoint for managing project Memory Bank (.memory-bank/).

Subcommands

Arguments: $ARGUMENTS

Determine the subcommand from the first word of $ARGUMENTS. Remaining words are parameters for that subcommand.

Routing

GraphRAG-lite retrieval routing

code_context is the default for ambiguous code-understanding questions such as "where is the logic for X?" and "find similar implementation". Exact structural questions use graph tools directly: "who calls/imports/defines X?" → graph_neighbors, "reverse deps" or impact analysis → graph_impact, and "what tests cover this file/symbol?" → graph_tests. User explicitly asks "semantic search" → search_code, served by scripts/mb-semantic-search.py (BM25 by default, opt-in local embeddings); respect explicit tool intent.

Fail open: for missing graph or stale graph, explain the limitation and suggest /mb graph --apply; for missing semantic provider or unavailable native extension, use scripts/mb-code-context.py, scripts/mb-graph-query.py, rg, and read as CLI fallback instead of blocking.

Subcommand Action
(empty) or context Collect project context
start Extended session start
search <query> Search information in the memory bank
recall <query> Lexical recall over session-memory log + notes (ripgrep over session/ + notes/) — session-memory subsystem
recap <sid> Reconstruct a full progress.md entry from session/<sid>*.md via one Haiku call, replacing that session's auto-capture stub idempotently. Missing session → exit non-zero, no writes; a real (non-stub) entry already present → refuse. recapped frontmatter makes a rerun a no-op
conflicts [--judge] [--threshold N] Surface memory entries with high lexical overlap and opposing/replacement assertions (en+ru markers) as conflict candidates — $0 pass (token-set Jaccard > N, default 0.3) over notes/ + lessons.md + recent progress.md, zero LLM calls. --judge confirms/rejects each pair via one Sonnet call and prints a suggested [SUPERSEDED: YYYY-MM-DD -> <ref>] marker. PRINT-ONLY — never writes to any bank file
consolidate [--apply] [--days N] Fold sessions older than N days (default 30) that cluster by shared files / lexical overlap into 5–15 line notes/ candidates, archive those session files VERBATIM → session/archive/, and move their contiguous auto-capture progress STUBS VERBATIM → progress-archive.md. Zero LLM calls. Dry-run is the DEFAULT (writes nothing — bank byte-identical); --apply performs it. Real progress entries are immutable and never move
research <query> Graph-first multi-source research — codebase / memory / library / prior-art / web; dispatches the mb-research agent and returns file:line-grounded findings (narrow → single dispatch; broad → fan-out parallel subagents). Fail-open: graph/index optional, degrades to Grep/Read
note <topic> Create a note
update Actualize core files (with real code-state analysis)
doctor Find and fix internal MB inconsistencies
tasks Show unfinished tasks
index Registry of all entries
done End session (actualize + note + progress)
plan <type> <topic> Create a plan
discuss <topic> 5-phase requirements-elicitation interview → EARS-validated context/<topic>.md (Phase 1 Purpose & Users / Phase 2 Functional EARS / Phase 3 Non-Functional / Phase 4 Constraints / Phase 5 Edge Cases). Feeds traceability matrix.
ask_me <topic> Alias for discuss — same interview, easier to remember. Dispatch identically.
groom <topic> (also grooming) Critical grooming session for any task/idea at any stage: challenge necessity + approach, cover white spots, propose solutions. Summary → context/<topic>-groom.md; confirmed decisions routed to agreements.md (AGR) / backlog ## ADR / ## Ideas; proposes next steps (spec/plan). No EARS. See commands/groom.md.
sdd <topic> [--force] Create Kiro-style spec triple specs/<topic>/{requirements,design,tasks}.md. If context/<topic>.md exists, EARS section copied verbatim into requirements.md. --force overwrites.
openspec <import|list|status|sync> [args] One-way import adapter: OpenSpec changes/<id>/ → MB spec triple specs/<topic>/ via scripts/mb-openspec.sh (no openspec CLI dep). import <dir> [--as <topic>] [--normalize] writes the triple + drift frontmatter; list [--all]/status <topic> show imported/drifted/not-imported; sync [<topic>] re-imports only on hash drift. Opt-in --normalize fills LLM text slots (EARS/scenario/Covers), cached + fail-open. See ### openspec below.
config <init|show|validate|path> Manage execution pipeline.yaml (spec §9). init copies bundled default into <bank>/pipeline.yaml; show prints resolved config; validate runs schema check; path prints absolute path of resolved file.
pipeline <list|new|use|show|path|validate> Manage multiple named pipelines under <bank>/pipelines/<name>.yaml (different models + workflow per pipeline). list shows all + active; new NAME [--agent a,b] [--from NAME] [--default] scaffolds one; use NAME switches the default; show/path/validate [--all] inspect. Each can bind a code-agent host (agents:) for auto-selection by /mb work.
work [target] [--range A-B] [--dry-run] Execute stages from a plan. Auto-selects role-agent per stage (mb-backend / mb-frontend / mb-ios / mb-android / mb-architect / mb-devops / mb-qa / mb-analyst, fallback mb-developer). Sprint 2: implement-step dispatch + dry-run; Sprint 3 adds review-loop, severity gates, verifier integration.
verify Verify plan execution (plan vs code)
map [focus] Scan the codebase and write MD documents to .memory-bank/codebase/. Focus: stack / arch / quality / concerns / all (default: all)
upgrade Update the skill from GitHub (git pull + re-install). Flags: --check (check only), --force (skip confirmation)
`compact [--dry-run --apply]`
import --project <path> [--since YYYY-MM-DD] [--apply] Bootstrap MB from Claude Code JSONL (~/.claude/projects/<slug>/*.jsonl). Extracts progress.md (daily), notes/ (architecture-discussion heuristic), PII auto-wrap. Dedup via SHA256 + resume state
graph [--apply] [--cochange] [--questions] [src_root] Multi-language code graph: Python (stdlib ast, always on) + Go/JS/TS/Rust/Java (via tree-sitter, opt-in through pip install tree-sitter tree-sitter-go ...). Output: codebase/graph.json (JSON Lines, community ids) + codebase/god-nodes.md (Top symbols / Top modules + Communities & Bridge files via optional networkx). Incremental SHA256 cache. Opt-in --cochange adds deterministic git co-change file edges (co_change kind); --questions appends deterministic suggested questions to god-nodes.md
wiki [--dry-run] [src_root] Opt-in LLM layer (see ### wiki below). Codebase wiki (one article per community, Haiku) + "surprising connection" semantic edges the static graph misses (Sonnet), via host subagents — no API key. Deterministic prep in scripts/mb-wiki.py. Default /mb graph untouched
tags [--apply] [--auto-merge] Normalize frontmatter tags: detect synonyms via Levenshtein ≤2 against a closed vocabulary and propose merges. --auto-merge only applies distance ≤1. Vocabulary is in .memory-bank/tags-vocabulary.md (fallback: references/tags-vocabulary.md). mb-index-json.py auto-normalizes to kebab-case
`init [--minimal --full]`
profile <subcommand> Manage rule profiles: init, show, path, validate, set. See commands/profile.md. Example: mb-profile.sh init --scope=user --role=backend --stack=go
install [<clients>] Install Memory Bank for the project. If <clients> is empty, ask for an 8-client multiselect (claude-code/cursor/windsurf/cline/kilo/opencode/pi/codex). Calls memory-bank install --clients ... --project-root $PWD
statusline [--force] Claude Code only. Install the context-window statusline (% of context filled + model · branch · project) by running scripts/mb-statusline.py --install, which patches ~/.claude/settings.json (backup first, refuses to clobber an existing statusLine unless --force)
help [subcommand] Help. No argument → list all subcommands. With argument → show details for that specific one (/mb help compact, /mb help tags, ...)
deps [--install-hints] Dependency check (required: python3, jq, git; optional: rg, shellcheck, tree-sitter, PyYAML). --install-hints prints OS-specific install commands
idea <title> [HIGH|MED|LOW] Capture new idea in backlog.md with auto-generated monotonic I-NNN ID (priority defaults to MED)
idea-promote <I-NNN> <type> Promote an idea → plan. Creates plan file via mb-plan.sh, flips idea status NEW|TRIAGED → PLANNED, adds **Plan:** [plans/...] link, runs plan-sync. type ∈ feature|fix|refactor|experiment
adr <title> Capture Architecture Decision Record with auto-generated monotonic ADR-NNN ID inside backlog.md ## ADR section — skeleton includes Context / Options / Decision / Rationale / Consequences
agree <subcommand> Manage the running list of agreements — the canonical registry of confirmed decisions in <bank>/agreements.md (add [--supersedes N] | defer | reject | question | resolve | list | sync), auto-synced into a managed block in CLAUDE.md/AGENTS.md. See commands/agree.md + references/agreements.md
goal Scaffold .memory-bank/goal.md + .memory-bank/project.md from templates (copy-if-absent), then validate the goal with scripts/mb-goal-validate.sh. Phase-1 Dynamic Flow primitive (REQ-DF-001..005). See commands/goal.md
analyze-task Auto-classify goal + git-diff scope into ONE route and write it into the mb-flow fence (default Dynamic Flow router). See commands/analyze-task.md (REQ-DF-020/022)
flow <route> Explicitly select a route (skip auto-classification); the deterministic route-floor + firewall STILL apply. Escape-hatch. See commands/flow.md (REQ-DF-025)
drive [--route R] [--phase P] [--budget TOK] [--max-cycles N] Drive goal.md to completion over the deterministic firewall: call scripts/mb-drive.sh next, execute the ONE action it prints, repeat until a stop_*. Refuses without a resolvable goal. See commands/drive.md (REQ-DR-001/003/030/031)
migrate-structure [--dry-run|--apply] One-shot v3.0 → v3.1 structural migrator. Upgrades singular <!-- mb-active-plan --> to plural, adds mb-active-plans + mb-recent-done blocks to status.md, restructures backlog.md to ## Ideas + ## ADR skeleton. Creates .pre-migrate/<timestamp>/ backup. Idempotent
(unrecognized) Search by $ARGUMENTS

Read the full file on GitHub · 1,661 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 1,661 lines · 8 tokens per session scan B 70a7bb20ea25

Subscribe to this mod's changes

mb is a command published in the GitHub repository fockus/skill-memory-bank (25 stars, last pushed 1mo ago), licensed MIT. It adds 8 tokens to every session and 23,303 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.