pks brain

stable

Turn your own Claude Code session history into a searchable personal knowledge base — ingest, extract, synthesize, and render a wiki plus ADRs.

Author: Poul Kjeldager
Usage: pks brain <command> [options]
Category: infrastructure

Examples

$ pks brain init

Create the global and per-project brain layout

$ pks brain ingest

Parse Claude session logs into the raw firehoses

$ pks brain status

Show what the brain currently knows

$ pks brain refresh --dry-run

Plan the whole pipeline and print a cost estimate

$ pks brain search Keycloak --since 7d

Full-text search recent prompts, tools, and errors

pks brain is a personal knowledge base built from the Claude Code session logs already sitting on your machine. It reads ~/.claude/projects/**/*.jsonl, turns those sessions into structured data, and — with a few AI passes — writes per-session extracts, cross-session themes, wiki pages, and architecture decision records into the git repo you are standing in.

Overview

Every Claude Code session you run leaves a JSONL transcript on disk: your prompts, the assistant's replies, every tool call, every file it touched, every error it hit. That history is complete and local, and it is unreadable by hand. pks brain is the pipeline that makes it readable.

  • Deterministic first. Ingest, search, scan, conversation export, and commit planning read local files only. No model calls, no cost, no network.
  • AI second, with a plan. Extract, synth, wiki, and adr call a Claude-capable backend. Every one of them plans first — eligible items plus a cost and time estimate — before spending anything.
  • Two storage layers. Raw ingested data is global at ~/.pks-cli/brain/. Generated artifacts are per-repo at ./.pks/brain/.
  • Local scope only. Everything is scoped to one user's session logs and the current git repository. This is not a shared or team knowledge base.

What you get

  • A raw firehose. Ingest parses every session into four append-only files — prompts, tool calls, file operations, errors — with a per-session cursor so repeat runs stay cheap.
  • Per-session extracts. One markdown summary per session: what was worked on, what struggled, which prompt techniques were used, the user story, and tags. Each carries a JSON sidecar with model, tokens, cost, and skill hash.
  • Cross-session synthesis. Extracts are clustered by theme and narrated into themes.md and bad-habits.md, plus a machine-readable clusters.json.
  • A generated wiki. One page per qualifying cluster — overview, user stories, what is built, open threads, hot files — plus an index.
  • Drafted ADRs. Clusters tagged as architectural become Status/Context/Decision/Alternatives/Consequences/Evidence documents.
  • Session forensics. Search across the firehose, scan which sessions touched a given file, export a single session as readable markdown, and group uncommitted files by the session that produced them.

How it fits together

The pipeline runs in five phases, each consuming the previous one's output. ingest walks the Claude session logs and writes the global raw layer. extract summarizes each ingested session into ./.pks/brain/extracts/. synth clusters those extracts and writes ./.pks/brain/synthesis/, including the clusters.json that both later phases read. wiki and adr each render from those clusters, with different evidence thresholds — a wiki page needs 3 sessions by default, an ADR needs 5.

pks brain refresh runs all five in order with a single combined cost estimate and one confirmation prompt, and skips the downstream phases when extract produced nothing new. The remaining commands sit outside the pipeline: search, scan filepath, conversation, and commit-plan are ad-hoc tools, and skill manages the editable prompts that drive the four AI phases.

  • Global, cross-project: ~/.pks-cli/brain/ — the raw ingested firehoses.
  • Per-repo, generated: ./.pks/brain/ — extracts, synthesis, wiki, adr, conversations. pks brain init adds it to .gitignore.

Commands

init · ingest · extract · synth · wiki · adr · refresh · status · search · commit-plan · scan filepath · conversation · skill list · skill init · skill show

CommandPhaseWhat it does
pks brain initsetupCreates the global and per-project layout, and gitignores the project directory.
pks brain ingest1Parses Claude session JSONL into the global raw firehoses. Deterministic.
pks brain extract2AI-summarizes each session into a per-session markdown extract.
pks brain synth3Clusters extracts and narrates cross-session themes and bad habits.
pks brain wiki4Renders one wiki page per qualifying cluster, plus an index.
pks brain adr5Distils architectural clusters into ADRs, plus an index.
pks brain refresh1–5Runs the whole pipeline with one combined estimate and gate.
pks brain statusDashboard of raw totals, extract stats, and refresh suggestions.
pks brain searchFull-text search across the firehoses and the project's extracts.
pks brain commit-planGroups uncommitted files by the session that produced them.
pks brain scan filepathFinds every session whose tool calls touched a path.
pks brain conversationExports one session as readable markdown.
pks brain skillLists, installs, and shows the editable prompts behind the AI phases.

For the full flag surface of every command in one place, read the pks brain CLI reference.

Defaults

SettingValue
Global root~/.pks-cli/brain/
Per-project root./.pks/brain/
Session source~/.claude/projects
AI modelhaiku
Parallel AI calls10
Summarizer backendpks

These are resolved from your home directory and the current git repository. There is no PKS_HOME or PKS_CONFIG override for the brain root — HOME (or USERPROFILE on Windows) determines both paths.

Next steps

Subcommands

pks brain adr

stable

Distil architectural clusters into standard decision records — status, context, decision, alternatives, consequences, and the sessions that evidence them.

pks brain adr [options]

pks brain commit-plan

beta

Group a pile of uncommitted files by the Claude session that produced them, so one messy working tree becomes several focused, session-coherent commits.

pks brain commit-plan (--files <paths> | --files-from <path> | --uncommitted) [options]

pks brain conversation

stable

Export a single Claude session as readable markdown — human prompts and assistant replies, with tool traffic collapsed into references instead of inlined.

pks brain conversation <session> [options]

pks brain extract

stable

Summarize each ingested Claude session into a per-session markdown extract with a cost sidecar, planning and gating the spend before any model runs.

pks brain extract [options]

pks brain ingest

stable

Parse every Claude Code session log into four append-only firehose files under the global brain root — deterministic, cursor-based, and free to run.

pks brain ingest [options]

Quickstart: build your first brain

stable

Go from zero to a readable wiki page in five steps — initialize the layout, ingest your Claude session logs, extract, synthesize, and render.

pks brain init && pks brain ingest && pks brain refresh

pks brain CLI reference

stable

Complete command, flag, argument, and path reference for the pks brain group — the pipeline phases plus search, scan, conversation, commit-plan, and skills.

pks brain <command> [options]

pks brain refresh

stable

Run ingest, extract, synth, wiki, and adr in one pass with a single combined cost estimate, one confirmation gate, and automatic downstream skipping.

pks brain refresh [options]

pks brain scan filepath

stable

Find every Claude session whose tool calls touched a file or directory, scanning the raw session logs directly with no ingest and no model calls.

pks brain scan filepath <path> [options]

pks brain search

stable

Grep across every prompt, tool call, file operation, and error you ever ran through Claude Code, plus the current project's session extracts.

pks brain search <query> [options]

pks brain skill

stable

List, install, and inspect the editable prompts behind the brain's AI phases, so extract, synth, wiki, and adr produce the shape of output you want.

pks brain skill <list|init|show> [options]

pks brain status

stable

Show what the brain currently knows — global raw totals, per-project extract cost and token stats, and the sessions that are due for a refresh.

pks brain status

pks brain synth

stable

Cluster per-session extracts by theme and narrate the cross-session story into themes.md, bad-habits.md, and the clusters.json that wiki and adr read.

pks brain synth [options]

pks brain wiki

stable

Render one wiki page per synthesized cluster — overview, user stories, what is built, open threads, and hot files — plus an index linking them all.

pks brain wiki [options]