/knowledge-graph:kg-scoutfrom knowledge-graph
Mines Claude Code, Codex, and Antigravity conversation history for patterns and insights worth preserving. Uses a tension-driven tiered approach: lightweight scanning first, deep investigation only when signals indicate value.
Ships in knowledge-graph. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Scout extracts knowledge from Claude Code, Codex and Antigravity CLI conversation history using a tension-driven, tiered approach: lightweight scanning first, deep investigation only when signals indicate value.
The goal is not to extract everything — it's to find patterns worth preserving while being economical with tokens.
No special tools needed. You read history files directly with Read/Bash. Progress persists via kg_progress.
Before scouting, ensure:
kg_read(cwd="<project root>") # Load graph + get session_id
kg_progress(session_id, task_id="scout") # Check where you left off
~/.claude/history.jsonl{"display": "...", "project": "/path", "timestamp": ..., "sessionId": "..."}~/.claude/projects/{encoded-path}/{session}.jsonl/home/user/project becomes -home-user-projectResolve the history root from CODEX_HOME, falling back to ~/.codex.
history.jsonl is an optional prompt index, not a complete history of app
sessions. Enumerate sessions/**/rollout-*.jsonl; read session_meta for
id (or session_id), cwd, originator and cli_version. Filter projects using
that cwd, never the date directories or a path guessed from the filename.
Keep the memory session bound to the requested project even while reading
another project's history. If metadata is missing or conflicting, report
unresolved identity instead of assigning a project. A fork or subagent's
inherited prefix is context, not a second occurrence of a user preference.
For each changed rollout, scan complete JSONL records and retain line numbers and byte offsets. A partial final line waits for the next pass. First skim genuine user prompts for the same tension signals as the Claude recipe; then inspect the nearby assistant decisions and tool activity:
response_item / message: content text is in payload.content[];
accept assistant text as the model's account, not proof that work succeeded.
For user messages, prefer metadata
internal_chat_message_metadata_passthrough.content_item_kinds containing
user.text. When this metadata is absent, inspect provenance before treating
a user-role record as a human statement. Exclude environment/AGENTS/skill
blocks, KG injections, tool results, summaries and replayed context.event_msg / item_completed provides another representation of messages
(UserMessage, AgentMessage) and structured executed tools. Choose one
message representation; deduplicate by item/message id, not text alone
(a real repeated correction matters). Do not double-count both copies.response_item / function_call records carry JSON arguments in
payload.arguments, keyed by call_id; pair with function_call_output.
custom_tool_call named exec carries JavaScript source, not JSON.
Never execute it. Prefer completed CommandExecution records (id, command,
actual cwd, status), McpToolCall (tool, arguments, result), and FileChange
(changes, status). These describe inner calls even when JS builds arguments
dynamically or completes parallel calls out of source order.Compaction/replay blocks (compacted, replacement history, summaries),
developer/system records and inherited fork history are navigation aids.
Do not mine them as new claims. When their origin is unclear, find the original
message before capturing. Preserve provenance as harness, session id, rollout
path, line/byte range, timestamp and tool/message id when available; record
whether a claim was the user's decision, the assistant's claim, or verified
by a tool result. Keep raw transcripts and private prompts out of public files.
Merge a codex object into the existing kg_progress(task_id="scout") state;
preserve the Claude cursor and unrelated fields. Key it by the resolved
CODEX_HOME and session id. Per rollout store its path, reviewed complete-line
byte offset, last line/ordinal, size, mtime_ns, and a hash of the prefix through
that offset. Also keep candidate ranges still awaiting investigation.
Enumerate all date directories on every inventory pass. Size/mtime changes
select candidates; a resumed old rollout can append today. Before resuming a
cursor, verify the saved prefix hash. A shorter/replaced/changed prefix means
rescan with provenance deduplication, never seek blindly into it. Advance only
past records actually reviewed or explicitly skipped; when stopping for budget,
persist pending candidates before advancing the scan cursor. An unchanged file
with pending candidates still needs work. sessions_reviewed is not a permanent
skip list for Codex. Use overlapping context around the cursor for understanding
but do not recapture already processed records. Report absent/pruned rollouts
as unavailable, not reviewed.
All under ~/.gemini/antigravity-cli/ (the CLI's directory; the desktop app
and IDE keep their own and are out of scope).
history.jsonl, one line per prompt or slash command:
display, timestamp (ms), workspace, conversationId, type.conversation_summaries.db (SQLite; open read-only, e.g.
sqlite3 'file:...?mode=ro'), table conversation_summaries:
conversation_id, workspace_uris (JSON list of file:// URIs; filter the
project with these), step_count, last_modified_time, nesting_depth,
parent_conversation_id, agent_name. Skip nesting_depth > 0
(subagents) and agent_name = 'kg-maintainer' (this plugin's own chores).brain/<conversation_id>/.system_generated/logs/transcript_full.jsonl,
one step per line: step_index, source, type, created_at, and
content or tool_calls (arguments as objects). Human prompts are
USER_INPUT from USER_EXPLICIT; the words are between <USER_REQUEST>
and </USER_REQUEST>, and the rest of that record is metadata. Model turns
are PLANNER_RESPONSE (text and tool_calls, KG tools named
mcp_knowledge-graph_kg_kg_*); GENERIC steps are tool results.
SYSTEM_MESSAGE steps are injections (KG preload and recall among them) and
CHECKPOINT steps are compaction summaries: navigation, never new claims.Keep a per-conversation cursor in the scout progress state under an
antigravity object: conversation id, last reviewed step_index, and
step_count when read. A conversation whose step_count grew has new steps.
Don't read full sessions blindly. Use the prompt index to identify tension signals:
| Signal | What it looks like in the prompt index | Action |
|---|---|---|
| Repetition | Same topic appears 3+ times | Deep-dive one session to capture pattern |
| Correction | "no I meant", "that's wrong", "actually" | Check session for preference/clarification |
| Decision | "let's use", "I chose", "going with" | Capture rationale |
| Frustration | "again", "still not", "keeps failing" | Find what was eventually solved |
| Meta | "always do", "never", "remember that" | Direct extraction candidate |
No tension signal → skip deep investigation.
kg_progress(session_id, task_id="scout")
For Claude history, continue from last_ts. For Codex, use the per-rollout
cursor above. If empty, begin with a bounded inventory of the requested scope.
~/.claude/history.jsonl (or tail recent lines if very large).session_meta of each changed
rollout, then its genuine user prompts. Codex's history.jsonl is optional
and misses app sessions, so it is never the index on its own.history.jsonl in the CLI's directory, joined to the
inventory above by conversationId.Group by:
Checkpoint before deep-diving. When the user is present, list the candidate sessions with their signal and rough size, and let the user choose which get a deep-dive: full transcripts are the expensive tier, and they may hold things the user would rather not have mined. Skip the checkpoint when the request already names specific sessions or a topic narrow enough to need only a few reads, and in unattended runs (below).
For sessions with tension signals:
~/.claude/projects/{encoded-project-path}/{sessionId}.jsonlFor Codex, follow the rollout recipe above instead of constructing a Claude
transcript path. For Antigravity, read the conversation's
transcript_full.jsonl from its cursor.
Assistant message parsing: Content is nested: .message.content[] | select(.type == "text") | .text
Use standard memory tools:
kg_put_node(session_id, level="user", id="...", gist="...", notes=["mined from session {id}, {date}"])
kg_put_edge(session_id, level="project", from="...", to="...", rel="...")
Always:
notes: ["mined from session {id}"]kg_progress(session_id, task_id="scout", state={
"last_ts": 1770000000,
"sessions_reviewed": ["abc123", "def456"],
"patterns_found": ["docker-networking", "pytest-fixtures"],
"patterns_extracted": ["docker-networking"]
})
| Activity | ~Tokens | Frequency |
|---|---|---|
| Scan history.jsonl (500 lines) | 2-3k | Once, then incremental |
| Review patterns, decide | ~500 | Per scan |
| Fetch one session (filtered) | 1-3k | Only for tension signals |
| Extract & create nodes | ~500 | Per session |
Total productive scout: 5-10k tokens. Compare: blindly reading 10 sessions = 50-100k tokens, mostly noise.
Nobody is there to approve, so never stop to ask. Pick the deep-dives yourself from the tension table, strongest signal and most recent first, and record in the progress state what you chose and what you skipped, for later review.
Quota is the brake instead. Read the runner's own gauge before the first deep-dive and again before each further session:
jq . ~/.claude/last-limits.json, which gives
five_hour_pct, seven_day_pct and seven_day_resets_at.rate_limits event in your own rollout. Its windows
are told apart by window_minutes (300 = 5h, 10080 = weekly), each with
used_percent and resets_at.agy -p /usage --output-format json (no model call):
command.data.groups[].buckets[] with remaining_fraction and
reset_time; used % = (1 − remaining_fraction) × 100. Use the group of the
model you run on (Gemini or Claude/GPT). Plans with weekly buckets only have
no 5h gate; the weekly gates below still apply.Continue only while all three hold. These are the gates a maintenance pass uses:
5h below 40%;
weekly below 70%;
weekly pace at most 1.0, where
pace = weekly_pct / (100 × fraction of the week elapsed)
fraction = 1 − (weekly resets_at − now) / 604800
A pace at or under 1.0 means the week is on course to leave quota unused, and that surplus is what unattended mining may spend. Stop if the gauge is missing or unreadable, or if the pace cannot be computed yet (in the first ~3 hours of a new week). When a gate fails, save the cursor and pending candidates (Step 5) before stopping. Never leave a session half-read without saving progress.
Good times:
Bad times:
User-level (cross-project):
Project-level:
Skip: Generic greetings, one-off questions, raw code without insight, session mechanics ("continue", "yes").
Before creating any node/edge:
What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/kg-coreKnowledge Graph — persistent, granular, evolving memory.
Part of memory arrives preloaded: a "KG MEMORY PRELOADED" block carrying the
session_id and most important portion of memory.
Then the full read is on you: kg_read(cwd="<project root>") comes
before any work, whatever the task. Full read still brings up only most important memories.
Recall: if a gist points in the right direction, read the full node;
Search for more — in a rich graph the fact you need is often buried
under fresher work; search reaches every tier.
Capture: at the moment of learning, once the dots connect.
One lesson, one node: the gist states the lesson so it holds beyond
the case that taught it; each note tells one case of this lesson — a
failure that taught or confirmed it, what happened, where.
Before writing, walk back through the session: each point where another
choice would have changed the outcome is a lesson — rarely just one.
A failure met again sharpens its lesson and adds a note.
Name: the id names the SUBJECT in 3-5 words, never a container
("…-lessons", "…-log"); ids are load-bearing in search.
Connect rather than duplicate; a new lesson still earns its own node.
Endorse with kg_useful — the nodes that helped, judged at wrap-up against
results, and the ones that were MISSING when they should have been there,
sent the moment the gap shows. That credit keeps a node alive, and a miss
is the only signal that corrects a wrong archival.
Mechanics live in the kg_* tool descriptions; operations in /kg-ops.
/kg-Other plugins' skills for the same job
npx claudepluginhub mironmax/kg-memory --plugin knowledge-graph