Skip to content
Development
Skill

/knowledge-extraction

Sweep chunks for entries that match the project's schema and emit them via the event log. Use whenever the chunk phase has produced chunks and the extract phase is next, when the user says "extract X from the corpus," or when [[ralph-loop]] advances into the extraction phase.

From plugin
joharnessburg
928 skills5 agents5 commands

Claude Code

$ npx -y skills add kitchen-engineer42/joharnessburg --skill knowledge-extraction --agent claude-code

SKILL.md

knowledge-extraction.SKILL.md
name: knowledge-extraction
description: Sweep chunks for entries that match the project's schema and emit them via the event log. Use whenever the chunk phase has produced chunks and the extract phase is next, when the user says "extract X from the corpus," or when [[ralph-loop]] advances into the extraction phase. Subagent fan-out is the norm; each subagent processes one chunk; canonical state lives in the reducer's output.
metadata:
  triggers:
    - extract knowledge
    - extract entries
    - sweep the chunks
    - fan out extraction
    - run the extractor
    - extract rules
    - extract facts
    - extraction phase

knowledge-extraction

The phase where chunks become entries. This is where the vertical axis of John's matrix earns its keep — hundreds of subagents in parallel, each processing one chunk, each emitting events the reducer folds into canonical state. Without subagent fan-out, this phase doesn't scale.

Where the work happens

  • **Inputs**: `<project>/.john/chunks/<chunk-id>.md` + `<project>/.john/chunks/chunks_index.json` (from [[chunking]])
  • **Schema reference**: PLAN.md app-type definition section (per [[schema-design]])
  • **Outputs**: subagents emit to `<project>/.john/events/extract/<chunk-id>/<subagent-id>-*.json` (one file per event; exact event shapes and filename suffixes are in the `knowledge-extractor` agent definition); reducer (`${CLAUDE_PLUGIN_ROOT}/scripts/reduce_events.py extract`) folds to `<project>/.john/checkpoints/extract/state.json`; canonical state then drives [[knowledge-rewrite]].

The MECE sweep

Extract "everything there is" OR "everything needed for what" — which one depends on the project's intent. Decide that early and let it shape the sweep.

  • **Comprehensive sweep**: "extract everything there is in this corpus that matches the schema." Right for encyclopedic projects, regulations, broad knowledge bases.
  • **Goal-directed sweep**: "extract everything needed to answer X." Right for narrow apps where coverage outside the goal is wasteful.

Either way, MECE applies to coverage within the chosen scope: don't extract the same entry twice; don't leave the scope partially covered. Dedup across chunks happens later, in the rewrite phase (see [[knowledge-rewrite]]'s two-tier dedup) — the shipped reducer folds events without deduplicating; your job is to give that pipeline good raw events.

Fan-out per chunk

For each chunk, dispatch a subagent. Brief them comprehensively (per [[subagent-dispatch]]'s checklist):

1. **Project intent** (from PLAN.md top). 2. **The chunk** they're processing — the chunk file path or contents. 3. **The schema reference** — what an entry looks like, what fields, what cross-link semantics. 4. **The event log target** — where to write events (`<project>/.john/events/extract/<chunk-id>/`). 5. **What to return** — a one-line digest. No raw extracted content in the digest; that's in the event log. 6. **What NOT to do** — don't write canonical state directly; don't ask the user; don't try to dedupe across chunks (the reducer does that).

For small corpora (<10 chunks), inline extraction in the main agent context is fine. For real-world corpora (10s-1000s of chunks), always fan out.

The self-correction echo (mathlab pattern)

Borrowed from mathlab's "ops[0] echoes the problem" trick: have each extraction subagent's first action be to **echo back its understanding of the chunk** before extracting from it. This catches misreading, character encoding bugs, and chunks-handed-to-the-wrong-subagent failures cheaply.

Mechanically: the briefing includes the instruction *"Before extracting any entries, emit an event of type `chunk_echo` with a 2-3 sentence summary of what this chunk says. Then proceed."* The reducer folds the echoes into the checkpoint; its completeness check splits severity — a chunk missing `chunk_complete` lands in `incomplete_chunks` (possibly-unfinished work, worth a look before advancing), while a chunk that only skipped its echo lands in `chunks_missing_echo` (an INFO/audit note, *not* a reason to re-extract). YOU spot-check the echoes there — a wildly off-base echo flags a chunk for re-extraction.

Cost: one event per chunk's worth of summarization. Cheap compared to re-running an extraction that silently extracted from the wrong chunk.

Schema iteration during extraction

[[schema-design]] says the schema will iterate. Extraction is one of the phases where iteration surfaces:

  • An extractor reports *"this chunk has structure the schema doesn't represent."* The subagent emits a `schema_observation` event to the same event log; these fold into the extract phase's canonical state alongside the other events (filter on `event_type` when reviewing; a template's custom reducer may split them into a separate observations array).
  • You (the main agent, per [[ralph-loop]]) review these observations after the phase-fanout completes. If N≥3 observations point at the same gap, surface a schema-extension question to PLAN.md's Open Decisions and ask the user before proceeding.
  • [[knowledge-rewrite]] also reads these observations during the rewrite phase to guide cross-linking and dedup decisions — observations may flag entries that should be kept separate despite similarity.
  • Don't re-extract the entire corpus on every schema change. Use corrective events instead: a new `entry_replaced` event supersedes the older one. The reducer's fold function handles supersession deterministically.

Model tier per chunk

John core uses the active runtime's model routing. For extraction subagents:

  • **Sonnet** is usually right. Extraction needs decent reading comprehension + schema adherence; Sonnet has both.
  • **Haiku** works for highly structured chunks (e.g., extracting facts from a clean table). Cheap, fast.
  • **Opus** for chunks with judgment-heavy content (e.g., extracting *intent* from a legal preamble where the wording is deliberately vague).
  • **WorkerLLMs** (SiliconFlow, DeepSeek, etc.) where
Read more
@kitchen-engineer42
Ships withjoharnessburg

中文版: README_ZH.md John turns unstructured source material into a working knowledge-dense app. It keeps knowledge engineering and app building in one durable run, coordinates large per-entry fan-outs, and leaves auditable events and checkpoints on disk.

928 skills5 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
9
Star history of kitchen-engineer42/joharnessburg on GitHub, a chart by star-history.com

Other skills on joharnessburg.

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills2w309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc2w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react5d252k
@facebook@facebookInstall Skill

Questions about knowledge-extraction.

Which coding agents can use knowledge-extraction?
knowledge-extraction installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.