Decision log

From masharratt/claude-flow-novice · View interactive version

Decision log is an AI agent skill from the GitHub repository masharratt/claude-flow-novice. Cross-session decision memory. Two stores in one SQLite DB: an FTS5 index of past conversation messages (query/lookup/briefing) and a structured register of resolved plan decisions (record/decisions). Lets planning phases query prior art and avoid re-opening settled forks.

How to use this skill

Skill file

Decision Log

Purpose

Persist project decisions and conversation history across sessions so planning phases can query prior art before re-solving a problem or re-opening a settled fork. One SQLite database backs two distinct stores:

  1. messages (conversation FTS index): user/assistant text from Claude Code session JSONL files, BM25-ranked with recency boost. Written by the ingest scripts and the SessionStart hook. Read by query.sh, lookup.sh, briefing.sh.
  2. decisions (structured register): curated plan-time decisions (the chosen option, rationale, rejected alternatives, blocking flag, supersession chain). Written by record.sh from the cfn-decide phase. Read by decisions.sh.

The two stores are separate on purpose: conversation noise stays out of the structured register, and RESOLVED forks survive as queryable records distinct from raw chat.

Inputs

Outputs

Usage

Structured decisions (the `decisions` store)

# Write a decision (one invocation per BLOCKING fork; non-blocking optional)
./.claude/skills/decision-log/record.sh \
  --slug <plan-slug> --id D1 --title "<t>" --chosen "<option>" \
  [--rationale "<why>"] [--alternatives "<rejected>"] \
  [--status proposed|accepted|superseded] [--blocking] \
  [--supersede D0] [--project <p>] [--session <sid>] [--timestamp <iso>]
# required: --slug --id --title --chosen. Upserts on (project, slug, decision_id).
# --supersede Dn marks a prior decision superseded by this one.

# Read decisions
./.claude/skills/decision-log/decisions.sh list   [--project <p>] [--slug <s>] [--status <st>]
./.claude/skills/decision-log/decisions.sh show   <slug> [--project <p>]
./.claude/skills/decision-log/decisions.sh search "<terms>" [--project <p>] [--limit N]

Conversation index (the `messages` store)

# Full-text search across conversation history (BM25 + recency boost)
./.claude/skills/decision-log/query.sh "<terms>" [limit] [project] [context-window]

# Expand one result by message id, with adjacent messages from same session
./.claude/skills/decision-log/lookup.sh <message-id> [context-window]

# Generate a prior-decisions briefing for a task (phrase + term FTS, project-affinity boost)
./.claude/skills/decision-log/briefing.sh "<task-description>" [max-chars] [--project <name>]

Lifecycle / maintenance

./.claude/skills/decision-log/init.sh         # create empty DB from schema
./.claude/skills/decision-log/ingest.sh <session.jsonl> [project]   # incremental ingest (tracks last_line)
./.claude/skills/decision-log/ingest-all.sh   # backfill every project's session files
./.claude/skills/decision-log/stats.sh        # message/session/project counts + DB size

Ingest is incremental: ingest_state tracks last_line per session file, so re-runs only process new lines. The SessionStart hook .claude/hooks/cfn-decision-log-ingest.sh sweeps every project at session start, so the conversation index stays current without manual calls. The hook schedules only — it shells out to ingest.sh per file, which is the single source of truth for parsing. It must be registered under hooks.SessionStart in ~/.claude/settings.local.json to run at all; verify with:

jq -r '.hooks.SessionStart[].hooks[].command' ~/.claude/settings.local.json | grep decision-log

The sweep detaches (setsid) so startup never blocks, and takes a non-blocking flock on ~/.claude/decision-log/ingest.lock so concurrent session starts cannot contend on the SQLite file. Last run's output: ~/.claude/decision-log/ingest.log.

Cursor caveat: ingest.sh advances last_line to EOF whether or not rows were inserted. If a parsing bug drops messages, re-running will not recover them — the cursor says the file is done. After any fix to the extraction logic, reset before backfilling:

sqlite3 ~/.claude/decision-log/decisions.db "UPDATE ingest_state SET last_line = 0;"
./.claude/skills/decision-log/ingest-all.sh

Re-ingest is idempotent (messages.uuid is UNIQUE, inserts are INSERT OR IGNORE), so this cannot duplicate rows.

Consumers

Dependencies

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.