Skip to content

Matsumiko/runbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


RunBook

Operational instruction kit for AI coding agents


npm License GitHub


Codex Claude Cursor Copilot Node


Audit first. Implement carefully. Verify honestly.


RunBook helps AI coding agents work with structured project memory, context routing, session recovery, and verification discipline.

It gives a repository:

  • AGENTS.md as the agent operating entry point
  • CONTEXT.md as a routing map so agents read the right files for the task
  • PROJECT.md as durable project memory for commands, architecture, paths, environment, tests, and gotchas
  • SESSION.md plus .runbook/sessions/ for resumable work
  • frontend and backend guardrails
  • native adapters for opencode, Claude, Cursor, Copilot, Gemini, Windsurf, Cline, and Aider

The focus is the core workflow: project memory, context routing, recovery, adapters, and honest verification.

Quick Start

Install the CLI globally first:

npm i -g @matsumiko/runbook
runbook --version

Then initialize RunBook in a project:

cd my-project
runbook init

Pick a profile:

runbook init --profile minimal
runbook init --profile frontend
runbook init --profile backend
runbook init --profile full

Add adapter files:

runbook init --agent claude
runbook init --agent opencode
runbook init --agent cursor,copilot
runbook init --agent all

Preview before writing:

runbook init --dry-run
runbook upgrade --dry-run

Upgrade an existing RunBook install safely:

runbook upgrade
runbook doctor
runbook doctor --strict
runbook doctor --strict-live
runbook doctor --json
runbook finish

One-shot usage is still supported when you do not want a global install:

npx @matsumiko/runbook init

Install Options

Use case Command Run command
Recommended CLI npm i -g @matsumiko/runbook runbook ...
One-shot usage no install needed npx @matsumiko/runbook ...
Project-local dependency npm i -D @matsumiko/runbook npx runbook ... or an npm script

Profiles

Default runbook init uses --profile full.

Profile Installs Best for
minimal AGENTS.md, CONTEXT.md, PROJECT.md Small repos that only need operating rules and project memory.
frontend Minimal + FRONTEND.md UI, visual consistency, interaction, and design-system work.
backend Minimal + SECURITY.md API, auth, data, billing, uploads, webhooks, or migrations.
full All RunBook files Teams that want decisions, bug history, module maps, planning, sessions, backlog, changelog, guardrails, and adapters.

Core Workflow

  1. Run runbook init in the project root.
  2. Fill PROJECT.md with real commands, architecture, important paths, environment notes, tests, and gotchas.
  3. Have the agent read AGENTS.md.
  4. Have the agent read CONTEXT.md and choose task-specific files.
  5. Before repository-changing work, create a runtime session with runbook session new.
  6. During work, update the session with step, touch, and verify.
  7. Before closing, review durable memory and update the files that gained reusable facts.
  8. Close the session, then run the final RunBook proof gates.
  9. Record meaningful finished work in CHANGELOG.md.

Durable Memory

RunBook separates active task progress from long-term project memory.

File Purpose
PROJECT.md Commands, architecture, important paths, environment notes, tests, gotchas, and do-not-touch areas.
MODULE-MAP.md Module responsibilities, first files to inspect, related rules, common tasks, and module-specific pitfalls.
DECISIONS.md Accepted product, business, architecture, security, data, or UX decisions future agents must not undo accidentally.
BUG-HISTORY.md Fixed bugs, causes, fixes, changed files, and regression checks.
FRONTEND.md Actual frontend design and interaction decisions.
SECURITY.md Security-sensitive rules, auth/authorization constraints, secrets, abuse protection, and sensitive data behavior.

Before closing repository-changing work, agents must review durable memory:

  • update the relevant memory file when the task created or verified reusable facts
  • preserve the file's structure and add concrete entries under the right section
  • checkpoint every memory update with runbook session touch <file>
  • state in the final report when a relevant memory file was reviewed but did not need changes

Active progress still belongs in .runbook/sessions/*.json, not in durable memory files.

Context Routing

RunBook uses CONTEXT.md so agents do not need to load every file by default.

runbook context list
runbook context frontend
runbook context backend
runbook context architecture
runbook context bugfix
runbook context module-work
runbook context security-audit
runbook context resume
runbook context planning
runbook context inspect

Read more: docs/context-routing.md

Session Recovery

For non-trivial work, RunBook can create project-local runtime sessions:

runbook session pending
runbook session new
runbook session resume
runbook session note "Found failing auth test"
runbook session step "Fix token refresh handling"
runbook session touch src/auth.ts
runbook session verify "npm test passed"
runbook session latest
runbook session show
runbook session close --status completed
runbook session validate

Agents should check session pending before repository-changing task work. If a recoverable session exists, they should wait for the user to type exactly I will fight before resuming.

When the CLI is available, agents must use session CLI commands instead of hand-writing session JSON. Hand-written sessions are only a fallback if both runbook and npx @matsumiko/runbook fail after a real attempt.

Completed/cancelled runtime sessions are kept to the newest 5 by default; recoverable sessions are not auto-deleted.

Finish Gates

Before an agent claims repository-changing work is complete, these commands should pass after the runtime session is closed:

runbook session pending
runbook session validate
runbook doctor --strict-live
runbook finish

doctor --strict-live checks RunBook health plus runtime session validity and confirms no recoverable session remains. finish is the final completion gate over doctor, session validation, pending sessions, and placeholder memory files.

Read more: docs/session-recovery.md

Example: Fixing A Bug With RunBook

  1. runbook init --agent codex
  2. Fill PROJECT.md with project commands and gotchas.
  3. Agent reads AGENTS.md, then CONTEXT.md.
  4. For a frontend bug, agent uses runbook context frontend and reads FRONTEND.md.
  5. For a backend or auth bug, agent uses runbook context backend and reads SECURITY.md.
  6. For a regression, agent uses runbook context bugfix and reads BUG-HISTORY.md.
  7. For module-specific work, agent uses runbook context module-work and reads MODULE-MAP.md.
  8. Agent updates BUG-HISTORY.md after the bug is fixed and verified.
  9. Agent updates MODULE-MAP.md if module ownership, entrypoints, or first files changed.
  10. Agent verifies the fix, closes the session, and runs the finish gates.

Docs

Repository Layout

.
|-- bin/
|   `-- runbook.js
|-- docs/
|-- templates/
|-- variants/
|-- AGENTS.md
|-- CONTEXT.md
|-- PROJECT.md
|-- MODULE-MAP.md
|-- DECISIONS.md
|-- BUG-HISTORY.md
|-- SESSION.md
|-- FRONTEND.md
|-- SECURITY.md
|-- POLICIES.md
`-- package.json

Contributing

Issues and pull requests are welcome.

Changes to the instruction system should be concrete, defensible, and helpful for safer, more consistent, or easier-to-audit agent work.

License

MIT. See LICENSE.

About

Operational memory and execution discipline for AI coding agents.

Topics

Resources

License

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Contributors