kw

A knowledge-base workflow for collecting research papers, extracting their main ideas, and connecting those ideas into a searchable body of knowledge. It uses a command-line tool and separate steps for fetching, reading, and synthesis.

In plain words
What is it for?
Use it to fetch a paper by title, identifier, or DOI, process newly added papers, search stored principles, create links between ideas, and run synthesis.
Why use it?
It keeps paper acquisition, reading, and higher-level analysis separate, while maintaining a structured index instead of relying on hand-edited records.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/chenpg2/kw-engine/kw
Any agent
npx skills add chenpg2/kw-engine --skill kw
Clone the repo
git clone --depth 1 https://github.com/chenpg2/kw-engine

Made for: Claude Code, Codex.

Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,681 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00065 $0.01681
Opus 5 $0.00032 $0.00840
Sonnet 5 $0.00013 $0.00336
Haiku 4.5 $0.00006 $0.00168

Measured 2d ago against content hash 29786288b409, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

kw scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/kw/SKILL.md · 110 lines

How it starts

The opening of the file, as written. The whole thing — 110 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/kw — knowledge engine (Loop 1)

You are the orchestrator. Do NOT do fetching/reading/distilling/synthesis yourself — dispatch the subagents. Read .kw/config.yaml and memory/index.json first.

CLI substrate: The kw CLI (from kw-engine package) provides deterministic commands for mutations. Subagents should use these instead of hand-editing index.json:

  • kw add-paper <id> — register a paper (creates scaffold md + index entry)
  • kw add-principle --title … --sig … --math … … — allocate P-####
  • kw add-link <from> <to> <type> — add link (preserves formatting)
  • kw search "<query>" — find relevant principles
  • kw fetch <id> — acquire PDF + validate + register
  • kw reindex — rebuild index.json + SQLite from markdown
  • kw verify — check SCHEMA §6 invariants
  • kw status — show engine state

Hard boundary (cost + separation): never call read_*/search_*/download_* MCP tools or read a paper PDF in this (opus) loop — that wastes opus on text-ingestion and bypasses the engine. Acquisition runs on kw-fetcher; reading runs on kw-reader. The ONLY fetching the orchestrator may do itself is /browse for a NEEDS-BROWSE paywalled paper (interactive, uses the user's institutional access).

Model enforcement — MUST pass model explicitly on every Agent dispatch:

subagent model subagent_type
kw-fetcher sonnet kw-fetcher
kw-reader sonnet kw-reader
kw-distiller opus kw-distiller
kw-synthesizer opus kw-synthesizer
kw-verifier sonnet kw-verifier

Frontmatter model: alone does NOT guarantee the model — the Agent tool inherits the parent session model by default. You MUST pass BOTH subagent_type AND model in every Agent call. Example:

Agent({ subagent_type: "kw-reader", model: "sonnet", prompt: "..." })

If you omit model, the reader/fetcher/verifier will run on opus and waste tokens.

Read the full file on GitHub · 110 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 110 lines · 65 tokens per session scan A 29786288b409

Subscribe to this mod's changes

kw is a skill published in the GitHub repository chenpg2/kw-engine (11 stars, last pushed 2mo ago), licensed MIT. It adds 65 tokens to every session and 1,681 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.