drive

A command that repeatedly follows a goal file through a fixed decision loop until the work is complete or a stop condition is reached.

In plain words
What is it for?
Use it to run multi-step work with a defined route, phase, token budget, and maximum number of cycles.
Why use it?
It turns a goal into explicit next actions and checks that the goal file is present and valid before proceeding.

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/drive
Clone the repo
git clone --depth 1 https://github.com/fockus/skill-memory-bank
Per session 15 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,373 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.00015 $0.02373
Opus 5 $0.00008 $0.01187
Sonnet 5 $0.00003 $0.00475
Haiku 4.5 $0.00002 $0.00237

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

Security

Grade A, and why

drive scanned grade A with 0 findings 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/drive.md · 185 lines

How it starts

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

/mb drive

Drive goal.md to completion by looping the deterministic decision function scripts/mb-drive.sh — a "ralph-loop" rebuilt over the firewall instead of over the model's own judgement (drive-loop ADR-1).

You are the runtime. mb-drive.sh is a stateless brain: it prints exactly ONE next action and exits. It starts no daemon, holds no cross-invocation state, and never dispatches a subagent itself. You call it, execute the action it returned, then call it again — until it returns a stop_* action (REQ-DR-002/003).

/mb drive [--route R] [--phase P] [--budget TOK] [--max-cycles N]

1. Preflight — resolve or refuse (REQ-DR-031)

/mb drive never silently starts. It reads goal.md; if the file is absent it scaffolds templates/goal.md into the bank and still refuses, so you have something concrete to fill in. If the file exists but does not resolve, it reuses the /mb goal failure path verbatim — scripts/mb-goal-validate.sh prints one concrete fix-hint per problem on stderr and exits 1.

Run this before the loop, every time:

SKILL_DIR="${SKILL_DIR:-$(cd "$(dirname "$0")/.." && pwd)}"   # memory-bank skill bundle root

# Bank resolution goes through the skill's ONE resolver (explicit arg → MB_PATH
# → local .memory-bank → global registry → legacy pointer). A hardcoded default
# would silently drive the wrong bank for globally-stored or relocated banks.
# shellcheck source=../scripts/_lib.sh
. "$SKILL_DIR/scripts/_lib.sh"
BANK="$(mb_resolve_path "${BANK:-}")"

# Flags this fence conducts. The loop below reads the very same variables, so a
# flag is either wired here or it does not exist.
BUDGET="${BUDGET:-}"          # --budget TOK
MAX_CYCLES="${MAX_CYCLES:-}"  # --max-cycles N

# No bank at all — /mb drive has nothing to drive.
if [ ! -d "$BANK" ]; then
  echo "[drive] refusing to start: no Memory Bank at '$BANK' — run /mb init first, then re-run /mb drive" >&2
  exit 1
fi

# Absent goal.md: scaffold the durable template, but still refuse. A bare
# template is not a goal — the loop must never start off placeholder text.
if [ ! -f "$BANK/goal.md" ]; then
  cp "$SKILL_DIR/templates/goal.md" "$BANK/goal.md"
  echo "[drive] refusing to start: no goal.md — scaffolded a template at $BANK/goal.md." >&2
  echo "[drive] fill in id, ## Description, ## Acceptance criteria and progress_source, then re-run /mb drive" >&2
  exit 1
fi

# Present but unresolvable: reuse the validator's failure path (exit 1 + one
# fix-hint per problem on stderr). The second argument pins the bank being
# driven, so `progress_source` resolves against IT and not against whatever
# .memory-bank happens to sit in the current working directory.
# An untouched scaffold fails here too: the validator rejects `<...>`
# placeholder acceptance criteria (a template is not a goal).
if ! bash "$SKILL_DIR/scripts/mb-goal-validate.sh" "$BANK/goal.md" "$BANK"; then
  echo "[drive] refusing to start: goal.md does not resolve — fix the hints above, then re-run /mb drive" >&2
  exit 1
fi

# ---- the goal resolves; arm durable state ---------------------------------
# ONE run id is minted here and threaded through every stateful consumer
# (work-state, budget, stop-telemetry, and the loop itself), so a parallel
# drive can never read another run's cycle counter or budget.
RUN_ID="${MB_WORK_RUN_ID:-$(bash "$SKILL_DIR/scripts/mb-work-state.sh" new-run-id)}"
export MB_WORK_RUN_ID="$RUN_ID"

# Durable cycle counter. `--max-cycles` reaches the run HERE or nowhere: it is
# what turns `stop_human max-cycle` from a constant into a user-set ceiling.
bash "$SKILL_DIR/scripts/mb-work-state.sh" init drive 0 --run-id "$RUN_ID" --mb "$BANK" ${MAX_CYCLES:+--max-cycles "$MAX_CYCLES"} >/dev/null

# Budget is stamped ONLY when --budget was given. A drive without --budget must
# not inherit or invent a ceiling — mb-drive.sh then never emits `stop_budget`.
if [ -n "$BUDGET" ]; then
  bash "$SKILL_DIR/scripts/mb-work-budget.sh" init "$BUDGET" --run-id "$RUN_ID" --mb "$BANK" >/dev/null
fi

# Arm stop-telemetry LAST — only a drive that actually starts is RUNNING. This
# is also the only thing that arms hooks/mb-drive-resume-gate.sh, so ordinary
# sessions are never gated (REQ-DR-033/034).
bash "$SKILL_DIR/scripts/mb-drive-stop.sh" arm --bank "$BANK" --run-id "$RUN_ID" >/dev/null

Read the full file on GitHub · 185 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 · 185 lines · 15 tokens per session scan A 9d61ab512b58

Subscribe to this mod's changes

drive is a command published in the GitHub repository fockus/skill-memory-bank (25 stars, last pushed 1mo ago), licensed MIT. It adds 15 tokens to every session and 2,373 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.